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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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