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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_15/] [or1200/] [rtl/] [verilog/] [or1200_dmmu_top.v] - Blame information for rev 1200

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

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

powered by: WebSVN 2.1.0

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