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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm4/] [verilog/] [or1200_dmmu_tlb.v] - Blame information for rev 3

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

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Data 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 DTLB.                                      ////
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.6  2004/04/05 08:29:57  lampret
48
// Merged branch_qmem into main tree.
49
//
50
// Revision 1.4.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.4  2002/10/17 20:04:40  lampret
54
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
55
//
56
// Revision 1.3  2002/02/11 04:33:17  lampret
57
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
58
//
59
// Revision 1.2  2002/01/28 01:16:00  lampret
60
// 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.
61
//
62
// Revision 1.1  2002/01/03 08:16:15  lampret
63
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
64
//
65
// Revision 1.8  2001/10/21 17:57:16  lampret
66
// 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.
67
//
68
// Revision 1.7  2001/10/14 13:12:09  lampret
69
// MP3 version.
70
//
71
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
72
// no message
73
//
74
//
75
 
76
// synopsys translate_off
77
`include "timescale.v"
78
// synopsys translate_on
79
`include "or1200_defines.v"
80
 
81
//
82
// Data TLB
83
//
84
 
85
module or1200_dmmu_tlb_cm4(
86
                clk_i_cml_1,
87
                clk_i_cml_2,
88
                clk_i_cml_3,
89
                cmls,
90
 
91
        // Rst and clk
92
        clk, rst,
93
 
94
        // I/F for translation
95
        tlb_en, vaddr, hit, ppn, uwe, ure, swe, sre, ci,
96
 
97
`ifdef OR1200_BIST
98
        // RAM BIST
99
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
100
`endif
101
 
102
        // SPR access
103
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o
104
);
105
 
106
 
107
input clk_i_cml_1;
108
input clk_i_cml_2;
109
input clk_i_cml_3;
110
input [1:0] cmls;
111
reg [ 32 - 1 : 0 ] vaddr_cml_1;
112
reg  spr_cs_cml_2;
113
reg  spr_cs_cml_1;
114
reg  spr_write_cml_2;
115
reg  spr_write_cml_1;
116
reg [ 31 : 0 ] spr_addr_cml_2;
117
reg [ 31 : 0 ] spr_addr_cml_1;
118
reg [ 31 : 0 ] spr_dat_i_cml_3;
119
reg [ 31 : 0 ] spr_dat_i_cml_2;
120
reg [ 31 : 0 ] spr_dat_i_cml_1;
121
reg [ 31 : 13 + 6 - 1 + 1 ] vpn_cml_1;
122
reg  v_cml_1;
123
reg [ 6 - 1 : 0 ] tlb_index_cml_3;
124
reg [ 6 - 1 : 0 ] tlb_index_cml_2;
125
reg [ 6 - 1 : 0 ] tlb_index_cml_1;
126
reg  tlb_mr_en_cml_3;
127
reg  tlb_mr_we_cml_3;
128
reg  tlb_tr_en_cml_3;
129
reg  tlb_tr_we_cml_3;
130
 
131
 
132
 
133
parameter dw = `OR1200_OPERAND_WIDTH;
134
parameter aw = `OR1200_OPERAND_WIDTH;
135
 
136
//
137
// I/O
138
//
139
 
140
//
141
// Clock and reset
142
//
143
input                           clk;
144
input                           rst;
145
 
146
//
147
// I/F for translation
148
//
149
input                           tlb_en;
150
input   [aw-1:0]         vaddr;
151
output                          hit;
152
output  [31:`OR1200_DMMU_PS]    ppn;
153
output                          uwe;
154
output                          ure;
155
output                          swe;
156
output                          sre;
157
output                          ci;
158
 
159
`ifdef OR1200_BIST
160
//
161
// RAM BIST
162
//
163
input mbist_si_i;
164
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
165
output mbist_so_o;
166
`endif
167
 
168
//
169
// SPR access
170
//
171
input                           spr_cs;
172
input                           spr_write;
173
input   [31:0]                   spr_addr;
174
input   [31:0]                   spr_dat_i;
175
output  [31:0]                   spr_dat_o;
176
 
177
//
178
// Internal wires and regs
179
//
180
wire    [`OR1200_DTLB_TAG]      vpn;
181
wire                            v;
182
wire    [`OR1200_DTLB_INDXW-1:0] tlb_index;
183
wire                            tlb_mr_en;
184
wire                            tlb_mr_we;
185
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_in;
186
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_out;
187
wire                            tlb_tr_en;
188
wire                            tlb_tr_we;
189
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_in;
190
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_out;
191
`ifdef OR1200_BIST
192
//
193
// RAM BIST
194
//
195
wire                            mbist_mr_so;
196
wire                            mbist_tr_so;
197
wire                            mbist_mr_si = mbist_si_i;
198
wire                            mbist_tr_si = mbist_mr_so;
199
assign                          mbist_so_o = mbist_tr_so;
200
`endif
201
 
202
//
203
// Implemented bits inside match and translate registers
204
//
205
// dtlbwYmrX: vpn 31-19  v 0
206
// dtlbwYtrX: ppn 31-13  swe 9  sre 8  uwe 7  ure 6
207
//
208
// dtlb memory width:
209
// 19 bits for ppn
210
// 13 bits for vpn
211
// 1 bit for valid
212
// 4 bits for protection
213
// 1 bit for cache inhibit
214
 
215
//
216
// Enable for Match registers
217
//
218
 
219
// SynEDA CoreMultiplier
220
// assignment(s): tlb_mr_en
221
// replace(s): spr_cs, spr_addr
222
assign tlb_mr_en = tlb_en | (spr_cs_cml_2 & !spr_addr_cml_2[`OR1200_DTLB_TM_ADDR]);
223
 
224
//
225
// Write enable for Match registers
226
//
227
 
228
// SynEDA CoreMultiplier
229
// assignment(s): tlb_mr_we
230
// replace(s): spr_cs, spr_write, spr_addr
231
assign tlb_mr_we = spr_cs_cml_2 & spr_write_cml_2 & !spr_addr_cml_2[`OR1200_DTLB_TM_ADDR];
232
 
233
//
234
// Enable for Translate registers
235
//
236
 
237
// SynEDA CoreMultiplier
238
// assignment(s): tlb_tr_en
239
// replace(s): spr_cs, spr_addr
240
assign tlb_tr_en = tlb_en | (spr_cs_cml_2 & spr_addr_cml_2[`OR1200_DTLB_TM_ADDR]);
241
 
242
//
243
// Write enable for Translate registers
244
//
245
 
246
// SynEDA CoreMultiplier
247
// assignment(s): tlb_tr_we
248
// replace(s): spr_cs, spr_write, spr_addr
249
assign tlb_tr_we = spr_cs_cml_2 & spr_write_cml_2 & spr_addr_cml_2[`OR1200_DTLB_TM_ADDR];
250
 
251
//
252
// Output to SPRS unit
253
//
254
assign spr_dat_o = (spr_cs & !spr_write & !spr_addr[`OR1200_DTLB_TM_ADDR]) ?
255
                        {vpn, tlb_index & {`OR1200_DTLB_INDXW{v}}, {`OR1200_DTLB_TAGW-7{1'b0}}, 1'b0, 5'b00000, v} :
256
                (spr_cs & !spr_write & spr_addr[`OR1200_DTLB_TM_ADDR]) ?
257
                        {ppn, {`OR1200_DMMU_PS-10{1'b0}}, swe, sre, uwe, ure, {4{1'b0}}, ci, 1'b0} :
258
                        32'h00000000;
259
 
260
//
261
// Assign outputs from Match registers
262
//
263
//assign {vpn, v} = tlb_mr_ram_out;
264
assign vpn = tlb_mr_ram_out[13:1];
265
assign v = tlb_mr_ram_out[0];
266
 
267
//
268
// Assign to Match registers inputs
269
//
270
 
271
// SynEDA CoreMultiplier
272
// assignment(s): tlb_mr_ram_in
273
// replace(s): spr_dat_i
274
assign tlb_mr_ram_in = {spr_dat_i_cml_3[`OR1200_DTLB_TAG], spr_dat_i_cml_3[`OR1200_DTLBMR_V_BITS]};
275
 
276
//
277
// Assign outputs from Translate registers
278
//
279
//assign {ppn, swe, sre, uwe, ure, ci} = tlb_tr_ram_out;
280
assign ppn = tlb_tr_ram_out[23:5];
281
assign swe = tlb_tr_ram_out[4];
282
assign sre = tlb_tr_ram_out[3];
283
assign uwe = tlb_tr_ram_out[2];
284
assign ure = tlb_tr_ram_out[1];
285
assign ci = tlb_tr_ram_out[0];
286
 
287
//
288
// Assign to Translate registers inputs
289
//
290
 
291
// SynEDA CoreMultiplier
292
// assignment(s): tlb_tr_ram_in
293
// replace(s): spr_dat_i
294
assign tlb_tr_ram_in = {spr_dat_i_cml_3[31:`OR1200_DMMU_PS],
295
                        spr_dat_i_cml_3[`OR1200_DTLBTR_SWE_BITS],
296
                        spr_dat_i_cml_3[`OR1200_DTLBTR_SRE_BITS],
297
                        spr_dat_i_cml_3[`OR1200_DTLBTR_UWE_BITS],
298
                        spr_dat_i_cml_3[`OR1200_DTLBTR_URE_BITS],
299
                        spr_dat_i_cml_3[`OR1200_DTLBTR_CI_BITS]};
300
 
301
//
302
// Generate hit
303
//
304
 
305
// SynEDA CoreMultiplier
306
// assignment(s): hit
307
// replace(s): vaddr, vpn, v
308
assign hit = (vpn_cml_1 == vaddr_cml_1[`OR1200_DTLB_TAG]) & v_cml_1;
309
 
310
//
311
// TLB index is normally vaddr[18:13]. If it is SPR access then index is
312
// spr_addr[5:0].
313
//
314
assign tlb_index = spr_cs ? spr_addr[`OR1200_DTLB_INDXW-1:0] : vaddr[`OR1200_DTLB_INDX];
315
 
316
`ifdef OR1200_RAM_MODELS_VIRTEX
317
 
318
//
319
//      Non-generic FPGA model instantiations
320
//
321
 
322
wire tlb_mr_en_wire;
323
wire [0 : 0] tlb_mr_we_wire;
324
wire [5 : 0] tlb_index_wire;
325
wire [13 : 0] tlb_mr_ram_in_wire;
326
 
327
 
328
// SynEDA CoreMultiplier
329
// assignment(s): tlb_mr_en_wire
330
// replace(s): tlb_mr_en
331
assign tlb_mr_en_wire = tlb_mr_en_cml_3;
332
 
333
// SynEDA CoreMultiplier
334
// assignment(s): tlb_mr_we_wire
335
// replace(s): tlb_mr_we
336
assign tlb_mr_we_wire = tlb_mr_we_cml_3;
337
 
338
// SynEDA CoreMultiplier
339
// assignment(s): tlb_index_wire
340
// replace(s): tlb_index
341
assign tlb_index_wire = tlb_index_cml_3;
342
assign tlb_mr_ram_in_wire = tlb_mr_ram_in;
343
 
344
dtlb_mr_sub_cm4 dtlb_ram (
345
                .clk_i_cml_1(clk_i_cml_1),
346
                .clk_i_cml_2(clk_i_cml_2),
347
                .clk_i_cml_3(clk_i_cml_3),
348
                .cmls(cmls),
349
        .clka(clk),
350
        .ena(tlb_mr_en_wire),
351
        .wea(tlb_mr_we_wire), // Bus [0 : 0] 
352
        .addra(tlb_index_wire), // Bus [5 : 0] 
353
        .dina(tlb_mr_ram_in_wire), // Bus [13 : 0] 
354
        .clkb(clk),
355
        .addrb(tlb_index_wire),
356
        .doutb(tlb_mr_ram_out)); // Bus [13 : 0]
357
 
358
wire tlb_tr_en_wire;
359
wire [0 : 0] tlb_tr_we_wire;
360
wire [23 : 0] tlb_tr_ram_in_wire;
361
 
362
 
363
// SynEDA CoreMultiplier
364
// assignment(s): tlb_tr_en_wire
365
// replace(s): tlb_tr_en
366
assign tlb_tr_en_wire = tlb_tr_en_cml_3;
367
 
368
// SynEDA CoreMultiplier
369
// assignment(s): tlb_tr_we_wire
370
// replace(s): tlb_tr_we
371
assign tlb_tr_we_wire = tlb_tr_we_cml_3;
372
assign tlb_tr_ram_in_wire = tlb_tr_ram_in;
373
 
374
dtlb_tr_sub_cm4 dtlb_tr_ram (
375
                .clk_i_cml_1(clk_i_cml_1),
376
                .clk_i_cml_2(clk_i_cml_2),
377
                .clk_i_cml_3(clk_i_cml_3),
378
                .cmls(cmls),
379
        .clka(clk),
380
        .ena(tlb_tr_en_wire),
381
        .wea(tlb_tr_we_wire), // Bus [0 : 0] 
382
        .addra(tlb_index_wire), // Bus [5 : 0] 
383
        .dina(tlb_tr_ram_in_wire), // Bus [23 : 0] 
384
        .clkb(clk),
385
        .addrb(tlb_index_wire),
386
        .doutb(tlb_tr_ram_out)); // Bus [23 : 0] 
387
 
388
`else
389
 
390
//
391
// Instantiation of DTLB Match Registers
392
//
393
or1200_spram_64x14 dtlb_mr_ram(
394
        .clk(clk),
395
        .rst(rst),
396
`ifdef OR1200_BIST
397
        // RAM BIST
398
        .mbist_si_i(mbist_mr_si),
399
        .mbist_so_o(mbist_mr_so),
400
        .mbist_ctrl_i(mbist_ctrl_i),
401
`endif
402
        .ce(tlb_mr_en),
403
        .we(tlb_mr_we),
404
        .oe(1'b1),
405
        .addr(tlb_index),
406
        .di(tlb_mr_ram_in),
407
        .doq(tlb_mr_ram_out)
408
);
409
 
410
//
411
// Instantiation of DTLB Translate Registers
412
//
413
or1200_spram_64x24 dtlb_tr_ram(
414
        .clk(clk),
415
        .rst(rst),
416
`ifdef OR1200_BIST
417
        // RAM BIST
418
        .mbist_si_i(mbist_tr_si),
419
        .mbist_so_o(mbist_tr_so),
420
        .mbist_ctrl_i(mbist_ctrl_i),
421
`endif
422
        .ce(tlb_tr_en),
423
        .we(tlb_tr_we),
424
        .oe(1'b1),
425
        .addr(tlb_index),
426
        .di(tlb_tr_ram_in),
427
        .doq(tlb_tr_ram_out)
428
);
429
`endif
430
 
431
 
432
always @ (posedge clk_i_cml_1) begin
433
vaddr_cml_1 <= vaddr;
434
spr_cs_cml_1 <= spr_cs;
435
spr_write_cml_1 <= spr_write;
436
spr_addr_cml_1 <= spr_addr;
437
spr_dat_i_cml_1 <= spr_dat_i;
438
vpn_cml_1 <= vpn;
439
v_cml_1 <= v;
440
tlb_index_cml_1 <= tlb_index;
441
end
442
always @ (posedge clk_i_cml_2) begin
443
spr_cs_cml_2 <= spr_cs_cml_1;
444
spr_write_cml_2 <= spr_write_cml_1;
445
spr_addr_cml_2 <= spr_addr_cml_1;
446
spr_dat_i_cml_2 <= spr_dat_i_cml_1;
447
tlb_index_cml_2 <= tlb_index_cml_1;
448
end
449
always @ (posedge clk_i_cml_3) begin
450
spr_dat_i_cml_3 <= spr_dat_i_cml_2;
451
tlb_index_cml_3 <= tlb_index_cml_2;
452
tlb_mr_en_cml_3 <= tlb_mr_en;
453
tlb_mr_we_cml_3 <= tlb_mr_we;
454
tlb_tr_en_cml_3 <= tlb_tr_en;
455
tlb_tr_we_cml_3 <= tlb_tr_we;
456
end
457
endmodule
458
 

powered by: WebSVN 2.1.0

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