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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_dmmu_top.v] - Blame information for rev 142

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

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

powered by: WebSVN 2.1.0

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