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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm3/] [verilog/] [or1200_dmmu_top.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Data MMU top level                                 ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Instantiation of all DMMU blocks.                           ////
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.7.4.2  2003/12/09 11:46:48  simons
48
// Mbist nameing changed, Artisan ram instance signal names fixed, some synthesis waning fixed.
49
//
50
// Revision 1.7.4.1  2003/07/08 15:36:37  lampret
51
// Added embedded memory QMEM.
52
//
53
// Revision 1.7  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.6  2002/03/29 15:16:55  lampret
57
// Some of the warnings fixed.
58
//
59
// Revision 1.5  2002/02/14 15:34:02  simons
60
// Lapsus fixed.
61
//
62
// Revision 1.4  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.3  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.2  2002/01/14 06:18:22  lampret
69
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
70
//
71
// Revision 1.1  2002/01/03 08:16:15  lampret
72
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
73
//
74
// Revision 1.6  2001/10/21 17:57:16  lampret
75
// 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.
76
//
77
// Revision 1.5  2001/10/14 13:12:09  lampret
78
// MP3 version.
79
//
80
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
81
// no message
82
//
83
// Revision 1.1  2001/08/17 08:03:35  lampret
84
// *** empty log message ***
85
//
86
// Revision 1.2  2001/07/22 03:31:53  lampret
87
// Fixed RAM's oen bug. Cache bypass under development.
88
//
89
// Revision 1.1  2001/07/20 00:46:03  lampret
90
// Development version of RTL. Libraries are missing.
91
//
92
//
93
 
94
// synopsys translate_off
95
`include "timescale.v"
96
// synopsys translate_on
97
`include "or1200_defines.v"
98
 
99
//
100
// Data MMU
101
//
102
 
103
module or1200_dmmu_top_cm3(
104
                clk_i_cml_1,
105
                clk_i_cml_2,
106
                cmls,
107
 
108
        // Rst and clk
109
        clk, rst,
110
 
111
        // CPU i/f
112
        dc_en, dmmu_en, supv, dcpu_adr_i, dcpu_cycstb_i, dcpu_we_i,
113
        dcpu_tag_o, dcpu_err_o,
114
 
115
        // SPR access
116
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
117
 
118
`ifdef OR1200_BIST
119
        // RAM BIST
120
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
121
`endif
122
 
123
        // DC i/f
124
        qmemdmmu_err_i, qmemdmmu_tag_i, qmemdmmu_adr_o, qmemdmmu_cycstb_o, qmemdmmu_ci_o
125
);
126
 
127
 
128
input clk_i_cml_1;
129
input clk_i_cml_2;
130
input [1:0] cmls;
131
reg  dc_en_cml_2;
132
reg  dmmu_en_cml_2;
133
reg  dmmu_en_cml_1;
134
reg [ 32 - 1 : 0 ] dcpu_adr_i_cml_2;
135
reg [ 32 - 1 : 0 ] dcpu_adr_i_cml_1;
136
reg  dcpu_cycstb_i_cml_2;
137
reg  fault_cml_2;
138
reg  miss_cml_2;
139
reg  dtlb_done_cml_2;
140
reg  dtlb_done_cml_1;
141
reg [ 31 : 13 ] dcpu_vpn_r_cml_2;
142
reg [ 31 : 13 ] dcpu_vpn_r_cml_1;
143
 
144
 
145
 
146
parameter dw = `OR1200_OPERAND_WIDTH;
147
parameter aw = `OR1200_OPERAND_WIDTH;
148
 
149
//
150
// I/O
151
//
152
 
153
//
154
// Clock and reset
155
//
156
input                           clk;
157
input                           rst;
158
 
159
//
160
// CPU I/F
161
//
162
input                           dc_en;
163
input                           dmmu_en;
164
input                           supv;
165
input   [aw-1:0]         dcpu_adr_i;
166
input                           dcpu_cycstb_i;
167
input                           dcpu_we_i;
168
output  [3:0]                    dcpu_tag_o;
169
output                          dcpu_err_o;
170
 
171
//
172
// SPR access
173
//
174
input                           spr_cs;
175
input                           spr_write;
176
input   [aw-1:0]         spr_addr;
177
input   [31:0]                   spr_dat_i;
178
output  [31:0]                   spr_dat_o;
179
 
180
`ifdef OR1200_BIST
181
//
182
// RAM BIST
183
//
184
input mbist_si_i;
185
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
186
output mbist_so_o;
187
`endif
188
 
189
//
190
// DC I/F
191
//
192
input                           qmemdmmu_err_i;
193
input   [3:0]                    qmemdmmu_tag_i;
194
output  [aw-1:0]         qmemdmmu_adr_o;
195
output                          qmemdmmu_cycstb_o;
196
output                          qmemdmmu_ci_o;
197
 
198
//
199
// Internal wires and regs
200
//
201
wire                            dtlb_spr_access;
202
wire    [31:`OR1200_DMMU_PS]    dtlb_ppn;
203
wire                            dtlb_hit;
204
wire                            dtlb_uwe;
205
wire                            dtlb_ure;
206
wire                            dtlb_swe;
207
wire                            dtlb_sre;
208
wire    [31:0]                   dtlb_dat_o;
209
wire                            dtlb_en;
210
wire                            dtlb_ci;
211
wire                            fault;
212
wire                            miss;
213
`ifdef OR1200_NO_DMMU
214
`else
215
reg                             dtlb_done;
216
reg     [31:`OR1200_DMMU_PS]    dcpu_vpn_r;
217
`endif
218
 
219
//
220
// Implemented bits inside match and translate registers
221
//
222
// dtlbwYmrX: vpn 31-10  v 0
223
// dtlbwYtrX: ppn 31-10  swe 9  sre 8  uwe 7  ure 6
224
//
225
// dtlb memory width:
226
// 19 bits for ppn
227
// 13 bits for vpn
228
// 1 bit for valid
229
// 4 bits for protection
230
// 1 bit for cache inhibit
231
 
232
`ifdef OR1200_NO_DMMU
233
 
234
//
235
// Put all outputs in inactive state
236
//
237
assign spr_dat_o = 32'h00000000;
238
assign qmemdmmu_adr_o = dcpu_adr_i;
239
assign dcpu_tag_o = qmemdmmu_tag_i;
240
assign qmemdmmu_cycstb_o = dcpu_cycstb_i;
241
assign dcpu_err_o = qmemdmmu_err_i;
242
assign qmemdmmu_ci_o = dcpu_adr_i[31]; //`OR1200_DMMU_CI;
243
`ifdef OR1200_BIST
244
assign mbist_so_o = mbist_si_i;
245
`endif
246
 
247
`else
248
 
249
//
250
// DTLB SPR access
251
//
252
// 0A00 - 0AFF  dtlbmr w0
253
// 0A00 - 0A3F  dtlbmr w0 [63:0]
254
//
255
// 0B00 - 0BFF  dtlbtr w0
256
// 0B00 - 0B3F  dtlbtr w0 [63:0]
257
//
258
assign dtlb_spr_access = spr_cs;
259
 
260
//
261
// Tags:
262
//
263
// OR1200_DTAG_TE - TLB miss Exception
264
// OR1200_DTAG_PE - Page fault Exception
265
//
266
assign dcpu_tag_o = miss ? `OR1200_DTAG_TE : fault ? `OR1200_DTAG_PE : qmemdmmu_tag_i;
267
 
268
//
269
// dcpu_err_o
270
//
271
assign dcpu_err_o = miss | fault | qmemdmmu_err_i;
272
 
273
//
274
// Assert dtlb_done one clock cycle after new address and dtlb_en must be active.
275
//
276
 
277
// SynEDA CoreMultiplier
278
// assignment(s): dtlb_done
279
// replace(s): dcpu_cycstb_i, dtlb_done
280
always @(posedge clk or posedge rst)
281
        if (rst)
282
                dtlb_done <= #1 1'b0;
283
        else begin  dtlb_done <= dtlb_done_cml_2; if (dtlb_en)
284
                dtlb_done <= #1 dcpu_cycstb_i_cml_2;
285
        else
286
                dtlb_done <= #1 1'b0; end
287
 
288
//
289
// Cut transfer if something goes wrong with translation. Also delayed signals because of translation delay.
290
//
291
 
292
// SynEDA CoreMultiplier
293
// assignment(s): qmemdmmu_cycstb_o
294
// replace(s): dc_en, dmmu_en, dcpu_cycstb_i, fault, miss, dtlb_done
295
assign qmemdmmu_cycstb_o = (!dc_en_cml_2 & dmmu_en_cml_2) ? ~(miss_cml_2 | fault_cml_2) & dtlb_done_cml_2 & dcpu_cycstb_i_cml_2 : ~(miss_cml_2 | fault_cml_2) & dcpu_cycstb_i_cml_2;
296
//assign qmemdmmu_cycstb_o = (dmmu_en) ? ~(miss | fault) & dcpu_cycstb_i : (miss | fault) ? 1'b0 : dcpu_cycstb_i;
297
 
298
//
299
// Cache Inhibit
300
//
301
assign qmemdmmu_ci_o = dmmu_en ? dtlb_done & dtlb_ci : dcpu_adr_i[31]; //`OR1200_DMMU_CI;
302
 
303
//
304
// Register dcpu_adr_i's VPN for use when DMMU is not enabled but PPN is expected to come
305
// one clock cycle after offset part.
306
//
307
 
308
// SynEDA CoreMultiplier
309
// assignment(s): dcpu_vpn_r
310
// replace(s): dcpu_adr_i, dcpu_vpn_r
311
always @(posedge clk or posedge rst)
312
        if (rst)
313
                dcpu_vpn_r <= #1 {31-`OR1200_DMMU_PS{1'b0}};
314
        else begin  dcpu_vpn_r <= dcpu_vpn_r_cml_2;
315
                dcpu_vpn_r <= #1 dcpu_adr_i_cml_2[31:`OR1200_DMMU_PS]; end
316
 
317
//
318
// Physical address is either translated virtual address or
319
// simply equal when DMMU is disabled
320
//
321
// assign qmemdmmu_adr_o = dmmu_en ? {dtlb_ppn, dcpu_adr_i[`OR1200_DMMU_PS-1:0]} : {dcpu_vpn_r, dcpu_adr_i[`OR1200_DMMU_PS-1:0]};
322
 
323
// SynEDA CoreMultiplier
324
// assignment(s): qmemdmmu_adr_o
325
// replace(s): dmmu_en, dcpu_adr_i
326
assign qmemdmmu_adr_o = dmmu_en_cml_1 ? {dtlb_ppn, dcpu_adr_i_cml_1[`OR1200_DMMU_PS-1:0]} : dcpu_adr_i_cml_1;
327
 
328
//
329
// Output to SPRS unit
330
//
331
assign spr_dat_o = dtlb_spr_access ? dtlb_dat_o : 32'h00000000;
332
 
333
//
334
// Page fault exception logic
335
//
336
 
337
// SynEDA CoreMultiplier
338
// assignment(s): fault
339
// replace(s): dtlb_done
340
assign fault = dtlb_done_cml_1 &
341
                        (  (!dcpu_we_i & !supv & !dtlb_ure) // Load in user mode not enabled
342
                        || (!dcpu_we_i & supv & !dtlb_sre) // Load in supv mode not enabled
343
                        || (dcpu_we_i & !supv & !dtlb_uwe) // Store in user mode not enabled
344
                        || (dcpu_we_i & supv & !dtlb_swe) ); // Store in supv mode not enabled
345
 
346
//
347
// TLB Miss exception logic
348
//
349
 
350
// SynEDA CoreMultiplier
351
// assignment(s): miss
352
// replace(s): dtlb_done
353
assign miss = dtlb_done_cml_1 & !dtlb_hit;
354
 
355
//
356
// DTLB Enable
357
//
358
 
359
// SynEDA CoreMultiplier
360
// assignment(s): dtlb_en
361
// replace(s): dmmu_en, dcpu_cycstb_i
362
assign dtlb_en = dmmu_en_cml_2 & dcpu_cycstb_i_cml_2;
363
 
364
//
365
// Instantiation of DTLB
366
//
367
or1200_dmmu_tlb_cm3 or1200_dmmu_tlb(
368
                .clk_i_cml_1(clk_i_cml_1),
369
                .clk_i_cml_2(clk_i_cml_2),
370
                .cmls(cmls),
371
        // Rst and clk
372
        .clk(clk),
373
        .rst(rst),
374
 
375
        // I/F for translation
376
        .tlb_en(dtlb_en),
377
        .vaddr(dcpu_adr_i),
378
        .hit(dtlb_hit),
379
        .ppn(dtlb_ppn),
380
        .uwe(dtlb_uwe),
381
        .ure(dtlb_ure),
382
        .swe(dtlb_swe),
383
        .sre(dtlb_sre),
384
        .ci(dtlb_ci),
385
 
386
`ifdef OR1200_BIST
387
        // RAM BIST
388
        .mbist_si_i(mbist_si_i),
389
        .mbist_so_o(mbist_so_o),
390
        .mbist_ctrl_i(mbist_ctrl_i),
391
`endif
392
 
393
        // SPR access
394
        .spr_cs(dtlb_spr_access),
395
        .spr_write(spr_write),
396
        .spr_addr(spr_addr),
397
        .spr_dat_i(spr_dat_i),
398
        .spr_dat_o(dtlb_dat_o)
399
);
400
 
401
`endif
402
 
403
 
404
always @ (posedge clk_i_cml_1) begin
405
dmmu_en_cml_1 <= dmmu_en;
406
dcpu_adr_i_cml_1 <= dcpu_adr_i;
407
dtlb_done_cml_1 <= dtlb_done;
408
dcpu_vpn_r_cml_1 <= dcpu_vpn_r;
409
end
410
always @ (posedge clk_i_cml_2) begin
411
dc_en_cml_2 <= dc_en;
412
dmmu_en_cml_2 <= dmmu_en_cml_1;
413
dcpu_adr_i_cml_2 <= dcpu_adr_i_cml_1;
414
dcpu_cycstb_i_cml_2 <= dcpu_cycstb_i;
415
fault_cml_2 <= fault;
416
miss_cml_2 <= miss;
417
dtlb_done_cml_2 <= dtlb_done_cml_1;
418
dcpu_vpn_r_cml_2 <= dcpu_vpn_r_cml_1;
419
end
420
endmodule
421
 

powered by: WebSVN 2.1.0

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