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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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