OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_immu_tlb.v] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Instruction TLB                                    ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Instantiation of ITLB.                                      ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 1293 lampret
// Revision 1.8  2004/04/05 08:29:57  lampret
48
// Merged branch_qmem into main tree.
49
//
50 1267 lampret
// Revision 1.6.4.1  2003/12/09 11:46:48  simons
51
// Mbist nameing changed, Artisan ram instance signal names fixed, some synthesis waning fixed.
52
//
53 1200 markom
// Revision 1.6  2002/10/28 16:34:32  mohor
54
// RAMs wrong connected to the BIST scan chain.
55
//
56 1079 mohor
// Revision 1.5  2002/10/17 20:04:40  lampret
57
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
58
//
59 1063 lampret
// Revision 1.4  2002/08/14 06:23:50  lampret
60
// Disabled ITLB translation when 1) doing access to ITLB SPRs or 2) crossing page. This modification was tested only with parts of IMMU test - remaining test cases needs to be run.
61
//
62 958 lampret
// Revision 1.3  2002/02/11 04:33:17  lampret
63
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
64
//
65 660 lampret
// Revision 1.2  2002/01/28 01:16:00  lampret
66
// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.
67
//
68 617 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
69
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
70
//
71 504 lampret
// Revision 1.8  2001/10/21 17:57:16  lampret
72
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
73
//
74
// Revision 1.7  2001/10/14 13:12:09  lampret
75
// MP3 version.
76
//
77
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
78
// no message
79
//
80
//
81
 
82
// synopsys translate_off
83
`include "timescale.v"
84
// synopsys translate_on
85
`include "or1200_defines.v"
86
 
87
//
88
// Insn TLB
89
//
90
 
91
module or1200_immu_tlb(
92
        // Rst and clk
93
        clk, rst,
94
 
95
        // I/F for translation
96 617 lampret
        tlb_en, vaddr, hit, ppn, uxe, sxe, ci,
97 504 lampret
 
98 1063 lampret
`ifdef OR1200_BIST
99
        // RAM BIST
100 1200 markom
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
101 1063 lampret
`endif
102
 
103 504 lampret
        // SPR access
104
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o
105
);
106
 
107
parameter dw = `OR1200_OPERAND_WIDTH;
108
parameter aw = `OR1200_OPERAND_WIDTH;
109
 
110
//
111
// I/O
112
//
113
 
114
//
115
// Clock and reset
116
//
117
input                           clk;
118
input                           rst;
119
 
120
//
121
// I/F for translation
122
//
123
input                           tlb_en;
124
input   [aw-1:0]         vaddr;
125
output                          hit;
126
output  [31:`OR1200_IMMU_PS]    ppn;
127
output                          uxe;
128
output                          sxe;
129
output                          ci;
130
 
131 1063 lampret
`ifdef OR1200_BIST
132 504 lampret
//
133 1063 lampret
// RAM BIST
134
//
135 1267 lampret
input mbist_si_i;
136
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
137
output mbist_so_o;
138 1063 lampret
`endif
139
 
140
//
141 504 lampret
// SPR access
142
//
143
input                           spr_cs;
144
input                           spr_write;
145
input   [31:0]                   spr_addr;
146
input   [31:0]                   spr_dat_i;
147
output  [31:0]                   spr_dat_o;
148
 
149
//
150
// Internal wires and regs
151
//
152
wire    [`OR1200_ITLB_TAG]      vpn;
153
wire                            v;
154
wire    [`OR1200_ITLB_INDXW-1:0] tlb_index;
155
wire                            tlb_mr_en;
156
wire                            tlb_mr_we;
157
wire    [`OR1200_ITLBMRW-1:0]    tlb_mr_ram_in;
158
wire    [`OR1200_ITLBMRW-1:0]    tlb_mr_ram_out;
159
wire                            tlb_tr_en;
160
wire                            tlb_tr_we;
161
wire    [`OR1200_ITLBTRW-1:0]    tlb_tr_ram_in;
162
wire    [`OR1200_ITLBTRW-1:0]    tlb_tr_ram_out;
163
 
164 1079 mohor
// BIST
165
`ifdef OR1200_BIST
166
wire                        itlb_mr_ram_si;
167
wire                        itlb_mr_ram_so;
168
wire                        itlb_tr_ram_si;
169
wire                        itlb_tr_ram_so;
170
`endif
171
 
172 504 lampret
//
173
// Implemented bits inside match and translate registers
174
//
175
// itlbwYmrX: vpn 31-19  v 0
176
// itlbwYtrX: ppn 31-13  uxe 7  sxe 6
177
//
178
// itlb memory width:
179
// 19 bits for ppn
180
// 13 bits for vpn
181
// 1 bit for valid
182
// 2 bits for protection
183
// 1 bit for cache inhibit
184
 
185
//
186
// Enable for Match registers
187
//
188
assign tlb_mr_en = tlb_en | (spr_cs & !spr_addr[`OR1200_ITLB_TM_ADDR]);
189
 
190
//
191
// Write enable for Match registers
192
//
193
assign tlb_mr_we = spr_cs & spr_write & !spr_addr[`OR1200_ITLB_TM_ADDR];
194
 
195
//
196
// Enable for Translate registers
197
//
198
assign tlb_tr_en = tlb_en | (spr_cs & spr_addr[`OR1200_ITLB_TM_ADDR]);
199
 
200
//
201
// Write enable for Translate registers
202
//
203
assign tlb_tr_we = spr_cs & spr_write & spr_addr[`OR1200_ITLB_TM_ADDR];
204
 
205
//
206
// Output to SPRS unit
207
//
208 958 lampret
assign spr_dat_o = (!spr_write & !spr_addr[`OR1200_ITLB_TM_ADDR]) ?
209 660 lampret
                        {vpn, tlb_index & {`OR1200_ITLB_INDXW{v}}, {`OR1200_ITLB_TAGW-7{1'b0}}, 1'b0, 5'b00000, v} :
210 958 lampret
                (!spr_write & spr_addr[`OR1200_ITLB_TM_ADDR]) ?
211 617 lampret
                        {ppn, {`OR1200_IMMU_PS-8{1'b0}}, uxe, sxe, {4{1'b0}}, ci, 1'b0} :
212 504 lampret
                        32'h00000000;
213
 
214
//
215
// Assign outputs from Match registers
216
//
217
assign {vpn, v} = tlb_mr_ram_out;
218
 
219
//
220
// Assign to Match registers inputs
221
//
222
assign tlb_mr_ram_in = {spr_dat_i[`OR1200_ITLB_TAG], spr_dat_i[`OR1200_ITLBMR_V_BITS]};
223
 
224
//
225
// Assign outputs from Translate registers
226
//
227
assign {ppn, uxe, sxe, ci} = tlb_tr_ram_out;
228
 
229
//
230
// Assign to Translate registers inputs
231
//
232
assign tlb_tr_ram_in = {spr_dat_i[31:`OR1200_IMMU_PS],
233 617 lampret
                        spr_dat_i[`OR1200_ITLBTR_UXE_BITS],
234 504 lampret
                        spr_dat_i[`OR1200_ITLBTR_SXE_BITS],
235
                        spr_dat_i[`OR1200_ITLBTR_CI_BITS]};
236
 
237
//
238
// Generate hit
239
//
240
assign hit = (vpn == vaddr[`OR1200_ITLB_TAG]) & v;
241
 
242
//
243
// TLB index is normally vaddr[18:13]. If it is SPR access then index is
244
// spr_addr[5:0].
245
//
246
assign tlb_index = spr_cs ? spr_addr[`OR1200_ITLB_INDXW-1:0] : vaddr[`OR1200_ITLB_INDX];
247
 
248 1079 mohor
 
249
`ifdef OR1200_BIST
250 1200 markom
assign itlb_mr_ram_si = mbist_si_i;
251 1079 mohor
assign itlb_tr_ram_si = itlb_mr_ram_so;
252 1200 markom
assign mbist_so_o = itlb_tr_ram_so;
253 1079 mohor
`endif
254
 
255
 
256 504 lampret
//
257
// Instantiation of ITLB Match Registers
258
//
259
or1200_spram_64x14 itlb_mr_ram(
260
        .clk(clk),
261
        .rst(rst),
262 1063 lampret
`ifdef OR1200_BIST
263
        // RAM BIST
264 1200 markom
        .mbist_si_i(itlb_mr_ram_si),
265
        .mbist_so_o(itlb_mr_ram_so),
266
        .mbist_ctrl_i(mbist_ctrl_i),
267 1063 lampret
`endif
268 504 lampret
        .ce(tlb_mr_en),
269
        .we(tlb_mr_we),
270
        .oe(1'b1),
271
        .addr(tlb_index),
272
        .di(tlb_mr_ram_in),
273 1293 lampret
        .doq(tlb_mr_ram_out)
274 504 lampret
);
275
 
276
//
277
// Instantiation of ITLB Translate Registers
278
//
279
or1200_spram_64x22 itlb_tr_ram(
280
        .clk(clk),
281
        .rst(rst),
282 1063 lampret
`ifdef OR1200_BIST
283
        // RAM BIST
284 1200 markom
        .mbist_si_i(itlb_tr_ram_si),
285
        .mbist_so_o(itlb_tr_ram_so),
286
        .mbist_ctrl_i(mbist_ctrl_i),
287 1063 lampret
`endif
288 504 lampret
        .ce(tlb_tr_en),
289
        .we(tlb_tr_we),
290
        .oe(1'b1),
291
        .addr(tlb_index),
292
        .di(tlb_tr_ram_in),
293 1293 lampret
        .doq(tlb_tr_ram_out)
294 504 lampret
);
295
 
296
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.