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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm2/] [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_cm2(
104
                clk_i_cml_1,
105
                cmls,
106
 
107
        // Rst and clk
108
        clk, rst,
109
 
110
        // CPU i/f
111
        dc_en, dmmu_en, supv, dcpu_adr_i, dcpu_cycstb_i, dcpu_we_i,
112
        dcpu_tag_o, dcpu_err_o,
113
 
114
        // SPR access
115
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
116
 
117
`ifdef OR1200_BIST
118
        // RAM BIST
119
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
120
`endif
121
 
122
        // DC i/f
123
        qmemdmmu_err_i, qmemdmmu_tag_i, qmemdmmu_adr_o, qmemdmmu_cycstb_o, qmemdmmu_ci_o
124
);
125
 
126
 
127
input clk_i_cml_1;
128
input cmls;
129
reg  dc_en_cml_1;
130
reg  dmmu_en_cml_1;
131
reg [ 32 - 1 : 0 ] dcpu_adr_i_cml_1;
132
reg  dcpu_cycstb_i_cml_1;
133
reg  dtlb_spr_access_cml_1;
134
reg [ 31 : 13 ] dtlb_ppn_cml_1;
135
reg [ 31 : 0 ] dtlb_dat_o_cml_1;
136
reg  fault_cml_1;
137
reg  miss_cml_1;
138
reg  dtlb_done_cml_1;
139
reg [ 31 : 13 ] dcpu_vpn_r_cml_1;
140
 
141
 
142
 
143
parameter dw = `OR1200_OPERAND_WIDTH;
144
parameter aw = `OR1200_OPERAND_WIDTH;
145
 
146
//
147
// I/O
148
//
149
 
150
//
151
// Clock and reset
152
//
153
input                           clk;
154
input                           rst;
155
 
156
//
157
// CPU I/F
158
//
159
input                           dc_en;
160
input                           dmmu_en;
161
input                           supv;
162
input   [aw-1:0]         dcpu_adr_i;
163
input                           dcpu_cycstb_i;
164
input                           dcpu_we_i;
165
output  [3:0]                    dcpu_tag_o;
166
output                          dcpu_err_o;
167
 
168
//
169
// SPR access
170
//
171
input                           spr_cs;
172
input                           spr_write;
173
input   [aw-1:0]         spr_addr;
174
input   [31:0]                   spr_dat_i;
175
output  [31:0]                   spr_dat_o;
176
 
177
`ifdef OR1200_BIST
178
//
179
// RAM BIST
180
//
181
input mbist_si_i;
182
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
183
output mbist_so_o;
184
`endif
185
 
186
//
187
// DC I/F
188
//
189
input                           qmemdmmu_err_i;
190
input   [3:0]                    qmemdmmu_tag_i;
191
output  [aw-1:0]         qmemdmmu_adr_o;
192
output                          qmemdmmu_cycstb_o;
193
output                          qmemdmmu_ci_o;
194
 
195
//
196
// Internal wires and regs
197
//
198
wire                            dtlb_spr_access;
199
wire    [31:`OR1200_DMMU_PS]    dtlb_ppn;
200
wire                            dtlb_hit;
201
wire                            dtlb_uwe;
202
wire                            dtlb_ure;
203
wire                            dtlb_swe;
204
wire                            dtlb_sre;
205
wire    [31:0]                   dtlb_dat_o;
206
wire                            dtlb_en;
207
wire                            dtlb_ci;
208
wire                            fault;
209
wire                            miss;
210
`ifdef OR1200_NO_DMMU
211
`else
212
reg                             dtlb_done;
213
reg     [31:`OR1200_DMMU_PS]    dcpu_vpn_r;
214
`endif
215
 
216
//
217
// Implemented bits inside match and translate registers
218
//
219
// dtlbwYmrX: vpn 31-10  v 0
220
// dtlbwYtrX: ppn 31-10  swe 9  sre 8  uwe 7  ure 6
221
//
222
// dtlb memory width:
223
// 19 bits for ppn
224
// 13 bits for vpn
225
// 1 bit for valid
226
// 4 bits for protection
227
// 1 bit for cache inhibit
228
 
229
`ifdef OR1200_NO_DMMU
230
 
231
//
232
// Put all outputs in inactive state
233
//
234
assign spr_dat_o = 32'h00000000;
235
assign qmemdmmu_adr_o = dcpu_adr_i;
236
assign dcpu_tag_o = qmemdmmu_tag_i;
237
assign qmemdmmu_cycstb_o = dcpu_cycstb_i;
238
assign dcpu_err_o = qmemdmmu_err_i;
239
assign qmemdmmu_ci_o = dcpu_adr_i[31]; //`OR1200_DMMU_CI;
240
`ifdef OR1200_BIST
241
assign mbist_so_o = mbist_si_i;
242
`endif
243
 
244
`else
245
 
246
//
247
// DTLB SPR access
248
//
249
// 0A00 - 0AFF  dtlbmr w0
250
// 0A00 - 0A3F  dtlbmr w0 [63:0]
251
//
252
// 0B00 - 0BFF  dtlbtr w0
253
// 0B00 - 0B3F  dtlbtr w0 [63:0]
254
//
255
assign dtlb_spr_access = spr_cs;
256
 
257
//
258
// Tags:
259
//
260
// OR1200_DTAG_TE - TLB miss Exception
261
// OR1200_DTAG_PE - Page fault Exception
262
//
263
assign dcpu_tag_o = miss ? `OR1200_DTAG_TE : fault ? `OR1200_DTAG_PE : qmemdmmu_tag_i;
264
 
265
//
266
// dcpu_err_o
267
//
268
assign dcpu_err_o = miss | fault | qmemdmmu_err_i;
269
 
270
//
271
// Assert dtlb_done one clock cycle after new address and dtlb_en must be active.
272
//
273
 
274
// SynEDA CoreMultiplier
275
// assignment(s): dtlb_done
276
// replace(s): dcpu_cycstb_i, dtlb_done
277
always @(posedge clk or posedge rst)
278
        if (rst)
279
                dtlb_done <= #1 1'b0;
280
        else begin  dtlb_done <= dtlb_done_cml_1; if (dtlb_en)
281
                dtlb_done <= #1 dcpu_cycstb_i_cml_1;
282
        else
283
                dtlb_done <= #1 1'b0; end
284
 
285
//
286
// Cut transfer if something goes wrong with translation. Also delayed signals because of translation delay.
287
//
288
 
289
// SynEDA CoreMultiplier
290
// assignment(s): qmemdmmu_cycstb_o
291
// replace(s): dc_en, dmmu_en, dcpu_cycstb_i, fault, miss, dtlb_done
292
assign qmemdmmu_cycstb_o = (!dc_en_cml_1 & dmmu_en_cml_1) ? ~(miss_cml_1 | fault_cml_1) & dtlb_done_cml_1 & dcpu_cycstb_i_cml_1 : ~(miss_cml_1 | fault_cml_1) & dcpu_cycstb_i_cml_1;
293
//assign qmemdmmu_cycstb_o = (dmmu_en) ? ~(miss | fault) & dcpu_cycstb_i : (miss | fault) ? 1'b0 : dcpu_cycstb_i;
294
 
295
//
296
// Cache Inhibit
297
//
298
assign qmemdmmu_ci_o = dmmu_en ? dtlb_done & dtlb_ci : dcpu_adr_i[31]; //`OR1200_DMMU_CI;
299
 
300
//
301
// Register dcpu_adr_i's VPN for use when DMMU is not enabled but PPN is expected to come
302
// one clock cycle after offset part.
303
//
304
 
305
// SynEDA CoreMultiplier
306
// assignment(s): dcpu_vpn_r
307
// replace(s): dcpu_adr_i, dcpu_vpn_r
308
always @(posedge clk or posedge rst)
309
        if (rst)
310
                dcpu_vpn_r <= #1 {31-`OR1200_DMMU_PS{1'b0}};
311
        else begin  dcpu_vpn_r <= dcpu_vpn_r_cml_1;
312
                dcpu_vpn_r <= #1 dcpu_adr_i_cml_1[31:`OR1200_DMMU_PS]; end
313
 
314
//
315
// Physical address is either translated virtual address or
316
// simply equal when DMMU is disabled
317
//
318
// 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]};
319
 
320
// SynEDA CoreMultiplier
321
// assignment(s): qmemdmmu_adr_o
322
// replace(s): dmmu_en, dcpu_adr_i, dtlb_ppn
323
assign qmemdmmu_adr_o = dmmu_en_cml_1 ? {dtlb_ppn_cml_1, dcpu_adr_i_cml_1[`OR1200_DMMU_PS-1:0]} : dcpu_adr_i_cml_1;
324
 
325
//
326
// Output to SPRS unit
327
//
328
 
329
// SynEDA CoreMultiplier
330
// assignment(s): spr_dat_o
331
// replace(s): dtlb_spr_access, dtlb_dat_o
332
assign spr_dat_o = dtlb_spr_access_cml_1 ? dtlb_dat_o_cml_1 : 32'h00000000;
333
 
334
//
335
// Page fault exception logic
336
//
337
assign fault = dtlb_done &
338
                        (  (!dcpu_we_i & !supv & !dtlb_ure) // Load in user mode not enabled
339
                        || (!dcpu_we_i & supv & !dtlb_sre) // Load in supv mode not enabled
340
                        || (dcpu_we_i & !supv & !dtlb_uwe) // Store in user mode not enabled
341
                        || (dcpu_we_i & supv & !dtlb_swe) ); // Store in supv mode not enabled
342
 
343
//
344
// TLB Miss exception logic
345
//
346
assign miss = dtlb_done & !dtlb_hit;
347
 
348
//
349
// DTLB Enable
350
//
351
 
352
// SynEDA CoreMultiplier
353
// assignment(s): dtlb_en
354
// replace(s): dmmu_en, dcpu_cycstb_i
355
assign dtlb_en = dmmu_en_cml_1 & dcpu_cycstb_i_cml_1;
356
 
357
//
358
// Instantiation of DTLB
359
//
360
or1200_dmmu_tlb_cm2 or1200_dmmu_tlb(
361
                .clk_i_cml_1(clk_i_cml_1),
362
                .cmls(cmls),
363
        // Rst and clk
364
        .clk(clk),
365
        .rst(rst),
366
 
367
        // I/F for translation
368
        .tlb_en(dtlb_en),
369
        .vaddr(dcpu_adr_i),
370
        .hit(dtlb_hit),
371
        .ppn(dtlb_ppn),
372
        .uwe(dtlb_uwe),
373
        .ure(dtlb_ure),
374
        .swe(dtlb_swe),
375
        .sre(dtlb_sre),
376
        .ci(dtlb_ci),
377
 
378
`ifdef OR1200_BIST
379
        // RAM BIST
380
        .mbist_si_i(mbist_si_i),
381
        .mbist_so_o(mbist_so_o),
382
        .mbist_ctrl_i(mbist_ctrl_i),
383
`endif
384
 
385
        // SPR access
386
        .spr_cs(dtlb_spr_access),
387
        .spr_write(spr_write),
388
        .spr_addr(spr_addr),
389
        .spr_dat_i(spr_dat_i),
390
        .spr_dat_o(dtlb_dat_o)
391
);
392
 
393
`endif
394
 
395
 
396
always @ (posedge clk_i_cml_1) begin
397
dc_en_cml_1 <= dc_en;
398
dmmu_en_cml_1 <= dmmu_en;
399
dcpu_adr_i_cml_1 <= dcpu_adr_i;
400
dcpu_cycstb_i_cml_1 <= dcpu_cycstb_i;
401
dtlb_spr_access_cml_1 <= dtlb_spr_access;
402
dtlb_ppn_cml_1 <= dtlb_ppn;
403
dtlb_dat_o_cml_1 <= dtlb_dat_o;
404
fault_cml_1 <= fault;
405
miss_cml_1 <= miss;
406
dtlb_done_cml_1 <= dtlb_done;
407
dcpu_vpn_r_cml_1 <= dcpu_vpn_r;
408
end
409
endmodule
410
 

powered by: WebSVN 2.1.0

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