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

Subversion Repositories or1k

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