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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_25/] [or1200/] [rtl/] [verilog/] [or1200_dmmu_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 Data 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 DTLB.                                      ////
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.4  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.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
// Data TLB
77
//
78
 
79
module or1200_dmmu_tlb(
80
        // Rst and clk
81
        clk, rst,
82
 
83
        // I/F for translation
84 617 lampret
        tlb_en, vaddr, hit, ppn, uwe, ure, swe, sre, ci,
85 504 lampret
 
86 1063 lampret
`ifdef OR1200_BIST
87
        // RAM BIST
88 1214 simons
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
89 1063 lampret
`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_DMMU_PS]    ppn;
115
output                          uwe;
116
output                          ure;
117
output                          swe;
118
output                          sre;
119
output                          ci;
120
 
121 1063 lampret
`ifdef OR1200_BIST
122 504 lampret
//
123 1063 lampret
// RAM BIST
124
//
125 1214 simons
input mbist_si_i;
126
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
127
output mbist_so_o;
128 1063 lampret
`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_DTLB_TAG]      vpn;
143
wire                            v;
144
wire    [`OR1200_DTLB_INDXW-1:0] tlb_index;
145
wire                            tlb_mr_en;
146
wire                            tlb_mr_we;
147
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_in;
148
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_out;
149
wire                            tlb_tr_en;
150
wire                            tlb_tr_we;
151
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_in;
152
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_out;
153 1063 lampret
`ifdef OR1200_BIST
154
//
155
// RAM BIST
156
//
157 1214 simons
wire                            mbist_mr_so;
158
wire                            mbist_tr_so;
159
wire                            mbist_mr_si = mbist_si_i;
160
wire                            mbist_tr_si = mbist_mr_so;
161
assign                          mbist_so_o = mbist_tr_so;
162 1063 lampret
`endif
163 504 lampret
 
164
//
165
// Implemented bits inside match and translate registers
166
//
167
// dtlbwYmrX: vpn 31-19  v 0
168
// dtlbwYtrX: ppn 31-13  swe 9  sre 8  uwe 7  ure 6
169
//
170
// dtlb memory width:
171
// 19 bits for ppn
172
// 13 bits for vpn
173
// 1 bit for valid
174
// 4 bits for protection
175
// 1 bit for cache inhibit
176
 
177
//
178
// Enable for Match registers
179
//
180
assign tlb_mr_en = tlb_en | (spr_cs & !spr_addr[`OR1200_DTLB_TM_ADDR]);
181
 
182
//
183
// Write enable for Match registers
184
//
185
assign tlb_mr_we = spr_cs & spr_write & !spr_addr[`OR1200_DTLB_TM_ADDR];
186
 
187
//
188
// Enable for Translate registers
189
//
190
assign tlb_tr_en = tlb_en | (spr_cs & spr_addr[`OR1200_DTLB_TM_ADDR]);
191
 
192
//
193
// Write enable for Translate registers
194
//
195
assign tlb_tr_we = spr_cs & spr_write & spr_addr[`OR1200_DTLB_TM_ADDR];
196
 
197
//
198
// Output to SPRS unit
199
//
200
assign spr_dat_o = (spr_cs & !spr_write & !spr_addr[`OR1200_DTLB_TM_ADDR]) ?
201 660 lampret
                        {vpn, tlb_index & {`OR1200_DTLB_INDXW{v}}, {`OR1200_DTLB_TAGW-7{1'b0}}, 1'b0, 5'b00000, v} :
202 504 lampret
                (spr_cs & !spr_write & spr_addr[`OR1200_DTLB_TM_ADDR]) ?
203 617 lampret
                        {ppn, {`OR1200_DMMU_PS-10{1'b0}}, swe, sre, uwe, ure, {4{1'b0}}, ci, 1'b0} :
204 504 lampret
                        32'h00000000;
205
 
206
//
207
// Assign outputs from Match registers
208
//
209
assign {vpn, v} = tlb_mr_ram_out;
210
 
211
//
212
// Assign to Match registers inputs
213
//
214
assign tlb_mr_ram_in = {spr_dat_i[`OR1200_DTLB_TAG], spr_dat_i[`OR1200_DTLBMR_V_BITS]};
215
 
216
//
217
// Assign outputs from Translate registers
218
//
219
assign {ppn, swe, sre, uwe, ure, ci} = tlb_tr_ram_out;
220
 
221
//
222
// Assign to Translate registers inputs
223
//
224
assign tlb_tr_ram_in = {spr_dat_i[31:`OR1200_DMMU_PS],
225
                        spr_dat_i[`OR1200_DTLBTR_SWE_BITS],
226
                        spr_dat_i[`OR1200_DTLBTR_SRE_BITS],
227
                        spr_dat_i[`OR1200_DTLBTR_UWE_BITS],
228
                        spr_dat_i[`OR1200_DTLBTR_URE_BITS],
229
                        spr_dat_i[`OR1200_DTLBTR_CI_BITS]};
230
 
231
//
232
// Generate hit
233
//
234
assign hit = (vpn == vaddr[`OR1200_DTLB_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_DTLB_INDXW-1:0] : vaddr[`OR1200_DTLB_INDX];
241
 
242
//
243
// Instantiation of DTLB Match Registers
244
//
245
or1200_spram_64x14 dtlb_mr_ram(
246
        .clk(clk),
247
        .rst(rst),
248 1063 lampret
`ifdef OR1200_BIST
249
        // RAM BIST
250 1214 simons
        .mbist_si_i(mbist_mr_si),
251
        .mbist_so_o(mbist_mr_so),
252
        .mbist_ctrl_i(mbist_ctrl_i),
253 1063 lampret
`endif
254 504 lampret
        .ce(tlb_mr_en),
255
        .we(tlb_mr_we),
256
        .oe(1'b1),
257
        .addr(tlb_index),
258
        .di(tlb_mr_ram_in),
259
        .do(tlb_mr_ram_out)
260
);
261
 
262
//
263
// Instantiation of DTLB Translate Registers
264
//
265
or1200_spram_64x24 dtlb_tr_ram(
266
        .clk(clk),
267
        .rst(rst),
268 1063 lampret
`ifdef OR1200_BIST
269
        // RAM BIST
270 1214 simons
        .mbist_si_i(mbist_tr_si),
271
        .mbist_so_o(mbist_tr_so),
272
        .mbist_ctrl_i(mbist_ctrl_i),
273 1063 lampret
`endif
274 504 lampret
        .ce(tlb_tr_en),
275
        .we(tlb_tr_we),
276
        .oe(1'b1),
277
        .addr(tlb_index),
278
        .di(tlb_tr_ram_in),
279
        .do(tlb_tr_ram_out)
280
);
281
 
282
endmodule

powered by: WebSVN 2.1.0

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