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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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