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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_orig/] [verilog/] [or1200_immu_tlb.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
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
// Revision 1.8  2004/04/05 08:29:57  lampret
48
// Merged branch_qmem into main tree.
49
//
50
// 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
// Revision 1.6  2002/10/28 16:34:32  mohor
54
// RAMs wrong connected to the BIST scan chain.
55
//
56
// 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
// 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
// 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
// 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
// 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
// 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
        tlb_en, vaddr, hit, ppn, uxe, sxe, ci,
97
 
98
`ifdef OR1200_BIST
99
        // RAM BIST
100
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
101
`endif
102
 
103
        // 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
`ifdef OR1200_BIST
132
//
133
// RAM BIST
134
//
135
input mbist_si_i;
136
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
137
output mbist_so_o;
138
`endif
139
 
140
//
141
// 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
// 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
//
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
assign spr_dat_o = (!spr_write & !spr_addr[`OR1200_ITLB_TM_ADDR]) ?
209
                        {vpn, tlb_index & {`OR1200_ITLB_INDXW{v}}, {`OR1200_ITLB_TAGW-7{1'b0}}, 1'b0, 5'b00000, v} :
210
                (!spr_write & spr_addr[`OR1200_ITLB_TM_ADDR]) ?
211
                        {ppn, {`OR1200_IMMU_PS-8{1'b0}}, uxe, sxe, {4{1'b0}}, ci, 1'b0} :
212
                        32'h00000000;
213
 
214
//
215
// Assign outputs from Match registers
216
//
217
//assign {vpn, v} = tlb_mr_ram_out;
218
assign vpn = tlb_mr_ram_out[13:1];
219
assign v = tlb_mr_ram_out[0];
220
 
221
//
222
// Assign to Match registers inputs
223
//
224
assign tlb_mr_ram_in = {spr_dat_i[`OR1200_ITLB_TAG], spr_dat_i[`OR1200_ITLBMR_V_BITS]};
225
 
226
//
227
// Assign outputs from Translate registers
228
//
229
//assign {ppn, uxe, sxe, ci} = tlb_tr_ram_out;
230
assign ppn = tlb_tr_ram_out[21:3];
231
assign uxe = tlb_tr_ram_out[2];
232
assign sxe = tlb_tr_ram_out[1];
233
assign ci = tlb_tr_ram_out[0];
234
 
235
//
236
// Assign to Translate registers inputs
237
//
238
assign tlb_tr_ram_in = {spr_dat_i[31:`OR1200_IMMU_PS],
239
                        spr_dat_i[`OR1200_ITLBTR_UXE_BITS],
240
                        spr_dat_i[`OR1200_ITLBTR_SXE_BITS],
241
                        spr_dat_i[`OR1200_ITLBTR_CI_BITS]};
242
 
243
//
244
// Generate hit
245
//
246
assign hit = (vpn == vaddr[`OR1200_ITLB_TAG]) & v;
247
 
248
//
249
// TLB index is normally vaddr[18:13]. If it is SPR access then index is
250
// spr_addr[5:0].
251
//
252
assign tlb_index = spr_cs ? spr_addr[`OR1200_ITLB_INDXW-1:0] : vaddr[`OR1200_ITLB_INDX];
253
 
254
 
255
`ifdef OR1200_BIST
256
assign itlb_mr_ram_si = mbist_si_i;
257
assign itlb_tr_ram_si = itlb_mr_ram_so;
258
assign mbist_so_o = itlb_tr_ram_so;
259
`endif
260
 
261
 
262
`ifdef OR1200_RAM_MODELS_VIRTEX
263
 
264
//
265
//      Non-generic FPGA model instantiations
266
//
267
 
268
wire tlb_tr_en_wire;
269
wire [0 : 0] tlb_tr_we_wire;
270
wire [5 : 0] tlb_index_wire;
271
wire [21 : 0] tlb_tr_ram_in_wire;
272
 
273
assign tlb_tr_en_wire = tlb_tr_en;
274
assign tlb_tr_we_wire = tlb_tr_we;
275
assign tlb_index_wire = tlb_index;
276
assign tlb_tr_ram_in_wire = tlb_tr_ram_in;
277
 
278
itlb_tr_sub itlb_tr_ram (
279
        .clka(clk),
280
        .ena(tlb_tr_en_wire),
281
        .wea(tlb_tr_we_wire), // Bus [0 : 0] 
282
        .addra(tlb_index_wire), // Bus [5 : 0] 
283
        .dina(tlb_tr_ram_in_wire), // Bus [21 : 0] 
284
        .clkb(clk),
285
        .addrb(tlb_index_wire),
286
        .doutb(tlb_tr_ram_out)); // Bus [21 : 0] 
287
 
288
wire tlb_mr_en_wire;
289
wire [0 : 0] tlb_mr_we_wire;
290
wire [13 : 0] tlb_mr_ram_in_wire;
291
 
292
assign tlb_mr_en_wire = tlb_mr_en;
293
assign tlb_mr_we_wire = tlb_mr_we;
294
assign tlb_mr_ram_in_wire = tlb_mr_ram_in;
295
 
296
itlb_mr_sub itlb_mr_ram (
297
        .clka(clk),
298
        .ena(tlb_mr_en_wire),
299
        .wea(tlb_mr_we_wire), // Bus [0 : 0] 
300
        .addra(tlb_index_wire), // Bus [5 : 0] 
301
        .dina(tlb_mr_ram_in_wire), // Bus [13 : 0] 
302
        .clkb(clk),
303
        .addrb(tlb_index_wire),
304
        .doutb(tlb_mr_ram_out)); // Bus [13 : 0]
305
 
306
`else
307
 
308
 
309
//
310
// Instantiation of ITLB Translate Registers
311
//
312
or1200_spram_64x22 itlb_tr_ram(
313
        .clk(clk),
314
        .rst(rst),
315
`ifdef OR1200_BIST
316
        // RAM BIST
317
        .mbist_si_i(itlb_tr_ram_si),
318
        .mbist_so_o(itlb_tr_ram_so),
319
        .mbist_ctrl_i(mbist_ctrl_i),
320
`endif
321
        .ce(tlb_tr_en),
322
        .we(tlb_tr_we),
323
        .oe(1'b1),
324
        .addr(tlb_index),
325
        .di(tlb_tr_ram_in),
326
        .doq(tlb_tr_ram_out)
327
);
328
 
329
 
330
//
331
// Instantiation of ITLB Match Registers
332
//
333
or1200_spram_64x14 itlb_mr_ram(
334
        .clk(clk),
335
        .rst(rst),
336
`ifdef OR1200_BIST
337
        // RAM BIST
338
        .mbist_si_i(itlb_mr_ram_si),
339
        .mbist_so_o(itlb_mr_ram_so),
340
        .mbist_ctrl_i(mbist_ctrl_i),
341
`endif
342
        .ce(tlb_mr_en),
343
        .we(tlb_mr_we),
344
        .oe(1'b1),
345
        .addr(tlb_index),
346
        .di(tlb_mr_ram_in),
347
        .doq(tlb_mr_ram_out)
348
);
349
 
350
`endif
351
 
352
endmodule

powered by: WebSVN 2.1.0

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