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

Subversion Repositories claw

[/] [claw/] [trunk/] [or1200_cpu/] [or1200_dmmu_top.v] - Blame information for rev 2

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

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