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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_13/] [or1200/] [rtl/] [verilog/] [or1200_immu_top.v] - Blame information for rev 636

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

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

powered by: WebSVN 2.1.0

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