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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Instruction TLB                                    ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Instantiation of ITLB.                                      ////
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 1214 simons
// Revision 1.6  2002/10/28 16:34:32  mohor
48
// RAMs wrong connected to the BIST scan chain.
49
//
50 1079 mohor
// Revision 1.5  2002/10/17 20:04:40  lampret
51
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
52
//
53 1063 lampret
// Revision 1.4  2002/08/14 06:23:50  lampret
54
// Disabled ITLB translation when 1) doing access to ITLB SPRs or 2) crossing page. This modification was tested only with parts of IMMU test - remaining test cases needs to be run.
55
//
56 958 lampret
// Revision 1.3  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.2  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.1  2002/01/03 08:16:15  lampret
63
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
64
//
65 504 lampret
// Revision 1.8  2001/10/21 17:57:16  lampret
66
// 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.
67
//
68
// Revision 1.7  2001/10/14 13:12:09  lampret
69
// MP3 version.
70
//
71
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
72
// no message
73
//
74
//
75
 
76
// synopsys translate_off
77
`include "timescale.v"
78
// synopsys translate_on
79
`include "or1200_defines.v"
80
 
81
//
82
// Insn TLB
83
//
84
 
85
module or1200_immu_tlb(
86
        // Rst and clk
87
        clk, rst,
88
 
89
        // I/F for translation
90 617 lampret
        tlb_en, vaddr, hit, ppn, uxe, sxe, ci,
91 504 lampret
 
92 1063 lampret
`ifdef OR1200_BIST
93
        // RAM BIST
94 1214 simons
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
95 1063 lampret
`endif
96
 
97 504 lampret
        // SPR access
98
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o
99
);
100
 
101
parameter dw = `OR1200_OPERAND_WIDTH;
102
parameter aw = `OR1200_OPERAND_WIDTH;
103
 
104
//
105
// I/O
106
//
107
 
108
//
109
// Clock and reset
110
//
111
input                           clk;
112
input                           rst;
113
 
114
//
115
// I/F for translation
116
//
117
input                           tlb_en;
118
input   [aw-1:0]         vaddr;
119
output                          hit;
120
output  [31:`OR1200_IMMU_PS]    ppn;
121
output                          uxe;
122
output                          sxe;
123
output                          ci;
124
 
125 1063 lampret
`ifdef OR1200_BIST
126 504 lampret
//
127 1063 lampret
// RAM BIST
128
//
129 1214 simons
input mbist_si_i;
130
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
131
output mbist_so_o;
132 1063 lampret
`endif
133
 
134
//
135 504 lampret
// SPR access
136
//
137
input                           spr_cs;
138
input                           spr_write;
139
input   [31:0]                   spr_addr;
140
input   [31:0]                   spr_dat_i;
141
output  [31:0]                   spr_dat_o;
142
 
143
//
144
// Internal wires and regs
145
//
146
wire    [`OR1200_ITLB_TAG]      vpn;
147
wire                            v;
148
wire    [`OR1200_ITLB_INDXW-1:0] tlb_index;
149
wire                            tlb_mr_en;
150
wire                            tlb_mr_we;
151
wire    [`OR1200_ITLBMRW-1:0]    tlb_mr_ram_in;
152
wire    [`OR1200_ITLBMRW-1:0]    tlb_mr_ram_out;
153
wire                            tlb_tr_en;
154
wire                            tlb_tr_we;
155
wire    [`OR1200_ITLBTRW-1:0]    tlb_tr_ram_in;
156
wire    [`OR1200_ITLBTRW-1:0]    tlb_tr_ram_out;
157
 
158 1079 mohor
// BIST
159
`ifdef OR1200_BIST
160
wire                        itlb_mr_ram_si;
161
wire                        itlb_mr_ram_so;
162
wire                        itlb_tr_ram_si;
163
wire                        itlb_tr_ram_so;
164
`endif
165
 
166 504 lampret
//
167
// Implemented bits inside match and translate registers
168
//
169
// itlbwYmrX: vpn 31-19  v 0
170
// itlbwYtrX: ppn 31-13  uxe 7  sxe 6
171
//
172
// itlb memory width:
173
// 19 bits for ppn
174
// 13 bits for vpn
175
// 1 bit for valid
176
// 2 bits for protection
177
// 1 bit for cache inhibit
178
 
179
//
180
// Enable for Match registers
181
//
182
assign tlb_mr_en = tlb_en | (spr_cs & !spr_addr[`OR1200_ITLB_TM_ADDR]);
183
 
184
//
185
// Write enable for Match registers
186
//
187
assign tlb_mr_we = spr_cs & spr_write & !spr_addr[`OR1200_ITLB_TM_ADDR];
188
 
189
//
190
// Enable for Translate registers
191
//
192
assign tlb_tr_en = tlb_en | (spr_cs & spr_addr[`OR1200_ITLB_TM_ADDR]);
193
 
194
//
195
// Write enable for Translate registers
196
//
197
assign tlb_tr_we = spr_cs & spr_write & spr_addr[`OR1200_ITLB_TM_ADDR];
198
 
199
//
200
// Output to SPRS unit
201
//
202 958 lampret
assign spr_dat_o = (!spr_write & !spr_addr[`OR1200_ITLB_TM_ADDR]) ?
203 660 lampret
                        {vpn, tlb_index & {`OR1200_ITLB_INDXW{v}}, {`OR1200_ITLB_TAGW-7{1'b0}}, 1'b0, 5'b00000, v} :
204 958 lampret
                (!spr_write & spr_addr[`OR1200_ITLB_TM_ADDR]) ?
205 617 lampret
                        {ppn, {`OR1200_IMMU_PS-8{1'b0}}, uxe, sxe, {4{1'b0}}, ci, 1'b0} :
206 504 lampret
                        32'h00000000;
207
 
208
//
209
// Assign outputs from Match registers
210
//
211
assign {vpn, v} = tlb_mr_ram_out;
212
 
213
//
214
// Assign to Match registers inputs
215
//
216
assign tlb_mr_ram_in = {spr_dat_i[`OR1200_ITLB_TAG], spr_dat_i[`OR1200_ITLBMR_V_BITS]};
217
 
218
//
219
// Assign outputs from Translate registers
220
//
221
assign {ppn, uxe, sxe, ci} = tlb_tr_ram_out;
222
 
223
//
224
// Assign to Translate registers inputs
225
//
226
assign tlb_tr_ram_in = {spr_dat_i[31:`OR1200_IMMU_PS],
227 617 lampret
                        spr_dat_i[`OR1200_ITLBTR_UXE_BITS],
228 504 lampret
                        spr_dat_i[`OR1200_ITLBTR_SXE_BITS],
229
                        spr_dat_i[`OR1200_ITLBTR_CI_BITS]};
230
 
231
//
232
// Generate hit
233
//
234
assign hit = (vpn == vaddr[`OR1200_ITLB_TAG]) & v;
235
 
236
//
237
// TLB index is normally vaddr[18:13]. If it is SPR access then index is
238
// spr_addr[5:0].
239
//
240
assign tlb_index = spr_cs ? spr_addr[`OR1200_ITLB_INDXW-1:0] : vaddr[`OR1200_ITLB_INDX];
241
 
242 1079 mohor
 
243
`ifdef OR1200_BIST
244 1214 simons
assign itlb_mr_ram_si = mbist_si_i;
245 1079 mohor
assign itlb_tr_ram_si = itlb_mr_ram_so;
246 1214 simons
assign mbist_so_o = itlb_tr_ram_so;
247 1079 mohor
`endif
248
 
249
 
250 504 lampret
//
251
// Instantiation of ITLB Match Registers
252
//
253
or1200_spram_64x14 itlb_mr_ram(
254
        .clk(clk),
255
        .rst(rst),
256 1063 lampret
`ifdef OR1200_BIST
257
        // RAM BIST
258 1214 simons
        .mbist_si_i(itlb_mr_ram_si),
259
        .mbist_so_o(itlb_mr_ram_so),
260
        .mbist_ctrl_i(mbist_ctrl_i),
261 1063 lampret
`endif
262 504 lampret
        .ce(tlb_mr_en),
263
        .we(tlb_mr_we),
264
        .oe(1'b1),
265
        .addr(tlb_index),
266
        .di(tlb_mr_ram_in),
267
        .do(tlb_mr_ram_out)
268
);
269
 
270
//
271
// Instantiation of ITLB Translate Registers
272
//
273
or1200_spram_64x22 itlb_tr_ram(
274
        .clk(clk),
275
        .rst(rst),
276 1063 lampret
`ifdef OR1200_BIST
277
        // RAM BIST
278 1214 simons
        .mbist_si_i(itlb_tr_ram_si),
279
        .mbist_so_o(itlb_tr_ram_so),
280
        .mbist_ctrl_i(mbist_ctrl_i),
281 1063 lampret
`endif
282 504 lampret
        .ce(tlb_tr_en),
283
        .we(tlb_tr_we),
284
        .oe(1'b1),
285
        .addr(tlb_index),
286
        .di(tlb_tr_ram_in),
287
        .do(tlb_tr_ram_out)
288
);
289
 
290
endmodule

powered by: WebSVN 2.1.0

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