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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [rtl/] [or1200/] [rtl/] [verilog/] [or1200_dmmu_tlb.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
//////////////////////////////////////////////////////////////////////
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: or1200_dmmu_tlb.v,v $
47
// Revision 1.7  2004/06/08 18:17:36  lampret
48
// Non-functional changes. Coding style fixes.
49
//
50
// Revision 1.6  2004/04/05 08:29:57  lampret
51
// Merged branch_qmem into main tree.
52
//
53
// Revision 1.4.4.1  2003/12/09 11:46:48  simons
54
// Mbist nameing changed, Artisan ram instance signal names fixed, some synthesis waning fixed.
55
//
56
// Revision 1.4  2002/10/17 20:04:40  lampret
57
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
58
//
59
// 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
// 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
// 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
// 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
// Data TLB
86
//
87
 
88
module or1200_dmmu_tlb(
89
        // Rst and clk
90
        clk, rst,
91
 
92
        // I/F for translation
93
        tlb_en, vaddr, hit, ppn, uwe, ure, swe, sre, ci,
94
 
95
`ifdef OR1200_BIST
96
        // RAM BIST
97
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
98
`endif
99
 
100
        // 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_DMMU_PS]    ppn;
124
output                          uwe;
125
output                          ure;
126
output                          swe;
127
output                          sre;
128
output                          ci;
129
 
130
`ifdef OR1200_BIST
131
//
132
// RAM BIST
133
//
134
input mbist_si_i;
135
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
136
output mbist_so_o;
137
`endif
138
 
139
//
140
// SPR access
141
//
142
input                           spr_cs;
143
input                           spr_write;
144
input   [31:0]                   spr_addr;
145
input   [31:0]                   spr_dat_i;
146
output  [31:0]                   spr_dat_o;
147
 
148
//
149
// Internal wires and regs
150
//
151
wire    [`OR1200_DTLB_TAG]      vpn;
152
wire                            v;
153
wire    [`OR1200_DTLB_INDXW-1:0] tlb_index;
154
wire                            tlb_mr_en;
155
wire                            tlb_mr_we;
156
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_in;
157
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_out;
158
wire                            tlb_tr_en;
159
wire                            tlb_tr_we;
160
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_in;
161
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_out;
162
`ifdef OR1200_BIST
163
//
164
// RAM BIST
165
//
166
wire                            mbist_mr_so;
167
wire                            mbist_tr_so;
168
wire                            mbist_mr_si = mbist_si_i;
169
wire                            mbist_tr_si = mbist_mr_so;
170
assign                          mbist_so_o = mbist_tr_so;
171
`endif
172
 
173
//
174
// Implemented bits inside match and translate registers
175
//
176
// dtlbwYmrX: vpn 31-19  v 0
177
// dtlbwYtrX: ppn 31-13  swe 9  sre 8  uwe 7  ure 6
178
//
179
// dtlb memory width:
180
// 19 bits for ppn
181
// 13 bits for vpn
182
// 1 bit for valid
183
// 4 bits for protection
184
// 1 bit for cache inhibit
185
 
186
//
187
// Enable for Match registers
188
//
189
assign tlb_mr_en = tlb_en | (spr_cs & !spr_addr[`OR1200_DTLB_TM_ADDR]);
190
 
191
//
192
// Write enable for Match registers
193
//
194
assign tlb_mr_we = spr_cs & spr_write & !spr_addr[`OR1200_DTLB_TM_ADDR];
195
 
196
//
197
// Enable for Translate registers
198
//
199
assign tlb_tr_en = tlb_en | (spr_cs & spr_addr[`OR1200_DTLB_TM_ADDR]);
200
 
201
//
202
// Write enable for Translate registers
203
//
204
assign tlb_tr_we = spr_cs & spr_write & spr_addr[`OR1200_DTLB_TM_ADDR];
205
 
206
//
207
// Output to SPRS unit
208
//
209
assign spr_dat_o = (spr_cs & !spr_write & !spr_addr[`OR1200_DTLB_TM_ADDR]) ?
210
                        {vpn, tlb_index & {`OR1200_DTLB_INDXW{v}}, {`OR1200_DTLB_TAGW-7{1'b0}}, 1'b0, 5'b00000, v} :
211
                (spr_cs & !spr_write & spr_addr[`OR1200_DTLB_TM_ADDR]) ?
212
                        {ppn, {`OR1200_DMMU_PS-10{1'b0}}, swe, sre, uwe, ure, {4{1'b0}}, ci, 1'b0} :
213
                        32'h00000000;
214
 
215
//
216
// Assign outputs from Match registers
217
//
218
assign {vpn, v} = tlb_mr_ram_out;
219
 
220
//
221
// Assign to Match registers inputs
222
//
223
assign tlb_mr_ram_in = {spr_dat_i[`OR1200_DTLB_TAG], spr_dat_i[`OR1200_DTLBMR_V_BITS]};
224
 
225
//
226
// Assign outputs from Translate registers
227
//
228
assign {ppn, swe, sre, uwe, ure, ci} = tlb_tr_ram_out;
229
 
230
//
231
// Assign to Translate registers inputs
232
//
233
assign tlb_tr_ram_in = {spr_dat_i[31:`OR1200_DMMU_PS],
234
                        spr_dat_i[`OR1200_DTLBTR_SWE_BITS],
235
                        spr_dat_i[`OR1200_DTLBTR_SRE_BITS],
236
                        spr_dat_i[`OR1200_DTLBTR_UWE_BITS],
237
                        spr_dat_i[`OR1200_DTLBTR_URE_BITS],
238
                        spr_dat_i[`OR1200_DTLBTR_CI_BITS]};
239
 
240
//
241
// Generate hit
242
//
243
assign hit = (vpn == vaddr[`OR1200_DTLB_TAG]) & v;
244
 
245
//
246
// TLB index is normally vaddr[18:13]. If it is SPR access then index is
247
// spr_addr[5:0].
248
//
249
assign tlb_index = spr_cs ? spr_addr[`OR1200_DTLB_INDXW-1:0] : vaddr[`OR1200_DTLB_INDX];
250
 
251
//
252
// Instantiation of DTLB Match Registers
253
//
254
or1200_spram_64x14 dtlb_mr_ram(
255
        .clk(clk),
256
        .rst(rst),
257
`ifdef OR1200_BIST
258
        // RAM BIST
259
        .mbist_si_i(mbist_mr_si),
260
        .mbist_so_o(mbist_mr_so),
261
        .mbist_ctrl_i(mbist_ctrl_i),
262
`endif
263
        .ce(tlb_mr_en),
264
        .we(tlb_mr_we),
265
        .oe(1'b1),
266
        .addr(tlb_index),
267
        .di(tlb_mr_ram_in),
268
        .doq(tlb_mr_ram_out)
269
);
270
 
271
//
272
// Instantiation of DTLB Translate Registers
273
//
274
or1200_spram_64x24 dtlb_tr_ram(
275
        .clk(clk),
276
        .rst(rst),
277
`ifdef OR1200_BIST
278
        // RAM BIST
279
        .mbist_si_i(mbist_tr_si),
280
        .mbist_so_o(mbist_tr_so),
281
        .mbist_ctrl_i(mbist_ctrl_i),
282
`endif
283
        .ce(tlb_tr_en),
284
        .we(tlb_tr_we),
285
        .oe(1'b1),
286
        .addr(tlb_index),
287
        .di(tlb_tr_ram_in),
288
        .doq(tlb_tr_ram_out)
289
);
290
 
291
endmodule

powered by: WebSVN 2.1.0

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