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

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [orp/] [orp_soc/] [rtl/] [verilog/] [or1200.old/] [or1200_immu_top.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 746 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Instruction 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 IMMU 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.5  2002/02/11 04:33:17  lampret
48
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
49
//
50
// Revision 1.4  2002/02/01 19:56:54  lampret
51
// Fixed combinational loops.
52
//
53
// Revision 1.3  2002/01/28 01:16:00  lampret
54
// 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.
55
//
56
// Revision 1.2  2002/01/14 06:18:22  lampret
57
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
58
//
59
// Revision 1.1  2002/01/03 08:16:15  lampret
60
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
61
//
62
// Revision 1.6  2001/10/21 17:57:16  lampret
63
// 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.
64
//
65
// Revision 1.5  2001/10/14 13:12:09  lampret
66
// MP3 version.
67
//
68
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
69
// no message
70
//
71
// Revision 1.1  2001/08/17 08:03:35  lampret
72
// *** empty log message ***
73
//
74
// Revision 1.2  2001/07/22 03:31:53  lampret
75
// Fixed RAM's oen bug. Cache bypass under development.
76
//
77
// Revision 1.1  2001/07/20 00:46:03  lampret
78
// Development version of RTL. Libraries are missing.
79
//
80
//
81
 
82
// synopsys translate_off
83
`include "timescale.v"
84
// synopsys translate_on
85
`include "or1200_defines.v"
86
 
87
//
88
// Insn MMU
89
//
90
 
91
module or1200_immu_top(
92
        // Rst and clk
93
        clk, rst,
94
 
95
        // CPU i/f
96
        ic_en, immu_en, supv, icpu_adr_i, icpu_cycstb_i,
97
        icpu_adr_o, icpu_tag_o, icpu_rty_o, icpu_err_o,
98
 
99
        // SPR access
100
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
101
 
102
        // IC i/f
103
        icimmu_rty_i, icimmu_err_i, icimmu_tag_i, icimmu_adr_o, icimmu_cycstb_o, icimmu_ci_o
104
);
105
 
106
parameter dw = `OR1200_OPERAND_WIDTH;
107
parameter aw = `OR1200_OPERAND_WIDTH;
108
 
109
//
110
// I/O
111
//
112
 
113
//
114
// Clock and reset
115
//
116
input                           clk;
117
input                           rst;
118
 
119
//
120
// CPU I/F
121
//
122
input                           ic_en;
123
input                           immu_en;
124
input                           supv;
125
input   [aw-1:0]         icpu_adr_i;
126
input                           icpu_cycstb_i;
127
output  [aw-1:0]         icpu_adr_o;
128
output  [3:0]                    icpu_tag_o;
129
output                          icpu_rty_o;
130
output                          icpu_err_o;
131
 
132
//
133
// SPR access
134
//
135
input                           spr_cs;
136
input                           spr_write;
137
input   [aw-1:0]         spr_addr;
138
input   [31:0]                   spr_dat_i;
139
output  [31:0]                   spr_dat_o;
140
 
141
//
142
// IC I/F
143
//
144
input                           icimmu_rty_i;
145
input                           icimmu_err_i;
146
input   [3:0]                    icimmu_tag_i;
147
output  [aw-1:0]         icimmu_adr_o;
148
output                          icimmu_cycstb_o;
149
output                          icimmu_ci_o;
150
 
151
//
152
// Internal wires and regs
153
//
154
wire                            itlb_spr_access;
155
wire    [31:`OR1200_IMMU_PS]    itlb_ppn;
156
wire                            itlb_hit;
157
wire                            itlb_uxe;
158
wire                            itlb_sxe;
159
wire    [31:0]                   itlb_dat_o;
160
wire                            itlb_en;
161
wire                            itlb_ci;
162
wire                            itlb_done;
163
wire                            fault;
164
wire                            miss;
165
reg     [31:0]                   icpu_adr_o;
166
reg                             itlb_en_r;
167
reg     [31:`OR1200_IMMU_PS]    icpu_vpn_r;
168
 
169
//
170
// Implemented bits inside match and translate registers
171
//
172
// itlbwYmrX: vpn 31-10  v 0
173
// itlbwYtrX: ppn 31-10  uxe 7  sxe 6
174
//
175
// itlb memory width:
176
// 19 bits for ppn
177
// 13 bits for vpn
178
// 1 bit for valid
179
// 2 bits for protection
180
// 1 bit for cache inhibit
181
 
182
//
183
// icpu_adr_o
184
//
185
`ifdef OR1200_REGISTERED_OUTPUTS
186
always @(posedge rst or posedge clk)
187
        if (rst)
188
                icpu_adr_o <= #1 32'h0000_0100;
189
        else
190
                icpu_adr_o <= #1 icpu_adr_i;
191
`else
192
Unsupported !!!
193
`endif
194
 
195
`ifdef OR1200_NO_IMMU
196
 
197
//
198
// Put all outputs in inactive state
199
//
200
assign spr_dat_o = 32'h00000000;
201
assign icimmu_adr_o = icpu_adr_i;
202
assign icpu_tag_o = icimmu_tag_i;
203
assign icimmu_cycstb_o = icpu_cycstb_i;
204
assign icpu_rty_o = icimmu_rty_i;
205
assign icpu_err_o = icimmu_err_i;
206
assign icimmu_ci_o = `OR1200_IMMU_CI;
207
 
208
`else
209
 
210
//
211
// ITLB SPR access
212
//
213
// 1200 - 12FF  itlbmr w0
214
// 1200 - 123F  itlbmr w0 [63:0]
215
//
216
// 1300 - 13FF  itlbtr w0
217
// 1300 - 133F  itlbtr w0 [63:0]
218
//
219
assign itlb_spr_access = spr_cs;
220
 
221
//
222
// Tags:
223
//
224
// OR1200_DTAG_TE - TLB miss Exception
225
// OR1200_DTAG_PE - Page fault Exception
226
//
227
assign icpu_tag_o = miss ? `OR1200_DTAG_TE : fault ? `OR1200_DTAG_PE : icimmu_tag_i;
228
 
229
//
230
// icpu_rty_o
231
//
232
// assign icpu_rty_o = !icpu_err_o & icimmu_rty_i;
233
assign icpu_rty_o = icimmu_rty_i;
234
 
235
//
236
// icpu_err_o
237
//
238
assign icpu_err_o = miss | fault | icimmu_err_i;
239
 
240
//
241
// Assert itlb_en_r after one clock cycle
242
//
243
always @(posedge clk or posedge rst)
244
        if (rst)
245
                itlb_en_r <= #1 1'b0;
246
        else
247
                itlb_en_r <= #1 itlb_en;
248
 
249
//
250
// Assert itlb_done one clock cycle after new address is first presented and tlb is enabled.
251
//
252
// assign itlb_done = (icpu_adr_i == icpu_adr_o) & itlb_en_r;
253
assign itlb_done = itlb_en_r;
254
 
255
//
256
// Cut transfer if something goes wrong with translation. If IC is disabled,
257
// use delayed signals.
258
//
259
assign icimmu_cycstb_o = (!ic_en & immu_en) ? ~(miss | fault) & icpu_cycstb_i : (miss | fault) ? 1'b0 : icpu_cycstb_i;
260
 
261
//
262
// Cache Inhibit
263
//
264
assign icimmu_ci_o = immu_en ? itlb_done & itlb_ci : `OR1200_IMMU_CI;
265
 
266
//
267
// Register icpu_adr_i's VPN for use when IMMU 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
                icpu_vpn_r <= #1 {31-`OR1200_IMMU_PS{1'b0}};
273
        else
274
                icpu_vpn_r <= #1 icpu_adr_i[31:`OR1200_IMMU_PS];
275
 
276
//
277
// Physical address is either translated virtual address or
278
// simply equal when IMMU is disabled
279
//
280
assign icimmu_adr_o = immu_en ? {itlb_ppn, icpu_adr_i[`OR1200_IMMU_PS-1:0]} : {icpu_vpn_r, icpu_adr_i[`OR1200_IMMU_PS-1:0]};
281
 
282
//
283
// Output to SPRS unit
284
//
285
assign spr_dat_o = itlb_spr_access ? itlb_dat_o : 32'h00000000;
286
 
287
//
288
// Page fault exception logic
289
//
290
assign fault = itlb_done &
291
                        (  (!supv & !itlb_uxe)          // Execute in user mode not enabled
292
                        || (supv & !itlb_sxe));         // Execute in supv mode not enabled
293
 
294
//
295
// TLB Miss exception logic
296
//
297
assign miss = itlb_done & !itlb_hit;
298
 
299
//
300
// ITLB Enable
301
//
302
assign itlb_en = immu_en & icpu_cycstb_i;
303
 
304
//
305
// Instantiation of ITLB
306
//
307
or1200_immu_tlb or1200_immu_tlb(
308
        // Rst and clk
309
        .clk(clk),
310
        .rst(rst),
311
 
312
        // I/F for translation
313
        .tlb_en(itlb_en),
314
        .vaddr(icpu_adr_i),
315
        .hit(itlb_hit),
316
        .ppn(itlb_ppn),
317
        .uxe(itlb_uxe),
318
        .sxe(itlb_sxe),
319
        .ci(itlb_ci),
320
 
321
        // SPR access
322
        .spr_cs(itlb_spr_access),
323
        .spr_write(spr_write),
324
        .spr_addr(spr_addr),
325
        .spr_dat_i(spr_dat_i),
326
        .spr_dat_o(itlb_dat_o)
327
);
328
 
329
`endif
330
 
331
endmodule

powered by: WebSVN 2.1.0

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