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 1063

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

powered by: WebSVN 2.1.0

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