OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_dmmu_tlb.v] - Blame information for rev 200

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 unneback
//////////////////////////////////////////////////////////////////////
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 141 marcus.erl
// $Log: or1200_dmmu_tlb.v,v $
47
// Revision 2.0  2010/06/30 11:00:00  ORSoC
48
// Minor update: 
49
// Bugs fixed, coding style changed. 
50
//
51
// Revision 1.7  2004/06/08 18:17:36  lampret
52
// Non-functional changes. Coding style fixes.
53
//
54 10 unneback
// Revision 1.6  2004/04/05 08:29:57  lampret
55
// Merged branch_qmem into main tree.
56
//
57
// Revision 1.4.4.1  2003/12/09 11:46:48  simons
58
// Mbist nameing changed, Artisan ram instance signal names fixed, some synthesis waning fixed.
59
//
60
// Revision 1.4  2002/10/17 20:04:40  lampret
61
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
62
//
63
// Revision 1.3  2002/02/11 04:33:17  lampret
64
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
65
//
66
// Revision 1.2  2002/01/28 01:16:00  lampret
67
// 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.
68
//
69
// Revision 1.1  2002/01/03 08:16:15  lampret
70
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
71
//
72
// Revision 1.8  2001/10/21 17:57:16  lampret
73
// 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.
74
//
75
// Revision 1.7  2001/10/14 13:12:09  lampret
76
// MP3 version.
77
//
78
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
79
// no message
80
//
81
//
82
 
83
// synopsys translate_off
84
`include "timescale.v"
85
// synopsys translate_on
86
`include "or1200_defines.v"
87
 
88
//
89
// Data TLB
90
//
91
 
92
module or1200_dmmu_tlb(
93
        // Rst and clk
94
        clk, rst,
95
 
96
        // I/F for translation
97
        tlb_en, vaddr, hit, ppn, uwe, ure, swe, sre, ci,
98
 
99
`ifdef OR1200_BIST
100
        // RAM BIST
101
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
102
`endif
103
 
104
        // SPR access
105
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o
106
);
107
 
108
parameter dw = `OR1200_OPERAND_WIDTH;
109
parameter aw = `OR1200_OPERAND_WIDTH;
110
 
111
//
112
// I/O
113
//
114
 
115
//
116
// Clock and reset
117
//
118
input                           clk;
119
input                           rst;
120
 
121
//
122
// I/F for translation
123
//
124
input                           tlb_en;
125
input   [aw-1:0]         vaddr;
126
output                          hit;
127
output  [31:`OR1200_DMMU_PS]    ppn;
128
output                          uwe;
129
output                          ure;
130
output                          swe;
131
output                          sre;
132
output                          ci;
133
 
134
`ifdef OR1200_BIST
135
//
136
// RAM BIST
137
//
138
input mbist_si_i;
139
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
140
output mbist_so_o;
141
`endif
142
 
143
//
144
// SPR access
145
//
146
input                           spr_cs;
147
input                           spr_write;
148
input   [31:0]                   spr_addr;
149
input   [31:0]                   spr_dat_i;
150
output  [31:0]                   spr_dat_o;
151
 
152
//
153
// Internal wires and regs
154
//
155
wire    [`OR1200_DTLB_TAG]      vpn;
156
wire                            v;
157
wire    [`OR1200_DTLB_INDXW-1:0] tlb_index;
158
wire                            tlb_mr_en;
159
wire                            tlb_mr_we;
160
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_in;
161
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_out;
162
wire                            tlb_tr_en;
163
wire                            tlb_tr_we;
164
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_in;
165
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_out;
166
`ifdef OR1200_BIST
167
//
168
// RAM BIST
169
//
170
wire                            mbist_mr_so;
171
wire                            mbist_tr_so;
172
wire                            mbist_mr_si = mbist_si_i;
173
wire                            mbist_tr_si = mbist_mr_so;
174
assign                          mbist_so_o = mbist_tr_so;
175
`endif
176
 
177
//
178
// Implemented bits inside match and translate registers
179
//
180
// dtlbwYmrX: vpn 31-19  v 0
181
// dtlbwYtrX: ppn 31-13  swe 9  sre 8  uwe 7  ure 6
182
//
183
// dtlb memory width:
184
// 19 bits for ppn
185
// 13 bits for vpn
186
// 1 bit for valid
187
// 4 bits for protection
188
// 1 bit for cache inhibit
189
 
190
//
191
// Enable for Match registers
192
//
193
assign tlb_mr_en = tlb_en | (spr_cs & !spr_addr[`OR1200_DTLB_TM_ADDR]);
194
 
195
//
196
// Write enable for Match registers
197
//
198
assign tlb_mr_we = spr_cs & spr_write & !spr_addr[`OR1200_DTLB_TM_ADDR];
199
 
200
//
201
// Enable for Translate registers
202
//
203
assign tlb_tr_en = tlb_en | (spr_cs & spr_addr[`OR1200_DTLB_TM_ADDR]);
204
 
205
//
206
// Write enable for Translate registers
207
//
208
assign tlb_tr_we = spr_cs & spr_write & spr_addr[`OR1200_DTLB_TM_ADDR];
209
 
210
//
211
// Output to SPRS unit
212
//
213
assign spr_dat_o = (spr_cs & !spr_write & !spr_addr[`OR1200_DTLB_TM_ADDR]) ?
214 141 marcus.erl
                        {vpn, tlb_index, {`OR1200_DTLB_TAGW-7{1'b0}}, 1'b0, 5'b00000, v} :
215 10 unneback
                (spr_cs & !spr_write & spr_addr[`OR1200_DTLB_TM_ADDR]) ?
216
                        {ppn, {`OR1200_DMMU_PS-10{1'b0}}, swe, sre, uwe, ure, {4{1'b0}}, ci, 1'b0} :
217
                        32'h00000000;
218
 
219
//
220
// Assign outputs from Match registers
221
//
222
assign {vpn, v} = tlb_mr_ram_out;
223
 
224
//
225
// Assign to Match registers inputs
226
//
227
assign tlb_mr_ram_in = {spr_dat_i[`OR1200_DTLB_TAG], spr_dat_i[`OR1200_DTLBMR_V_BITS]};
228
 
229
//
230
// Assign outputs from Translate registers
231
//
232
assign {ppn, swe, sre, uwe, ure, ci} = tlb_tr_ram_out;
233
 
234
//
235
// Assign to Translate registers inputs
236
//
237
assign tlb_tr_ram_in = {spr_dat_i[31:`OR1200_DMMU_PS],
238
                        spr_dat_i[`OR1200_DTLBTR_SWE_BITS],
239
                        spr_dat_i[`OR1200_DTLBTR_SRE_BITS],
240
                        spr_dat_i[`OR1200_DTLBTR_UWE_BITS],
241
                        spr_dat_i[`OR1200_DTLBTR_URE_BITS],
242
                        spr_dat_i[`OR1200_DTLBTR_CI_BITS]};
243
 
244
//
245
// Generate hit
246
//
247
assign hit = (vpn == vaddr[`OR1200_DTLB_TAG]) & v;
248
 
249
//
250
// TLB index is normally vaddr[18:13]. If it is SPR access then index is
251
// spr_addr[5:0].
252
//
253
assign tlb_index = spr_cs ? spr_addr[`OR1200_DTLB_INDXW-1:0] : vaddr[`OR1200_DTLB_INDX];
254
 
255
//
256
// Instantiation of DTLB Match Registers
257
//
258 141 marcus.erl
//or1200_spram_64x14 dtlb_mr_ram(
259
   or1200_spram #
260
     (
261
      .aw(6),
262
      .dw(14)
263
      )
264
   dtlb_ram
265
     (
266
      .clk(clk),
267 10 unneback
`ifdef OR1200_BIST
268 141 marcus.erl
      // RAM BIST
269
      .mbist_si_i(mbist_mr_si),
270
      .mbist_so_o(mbist_mr_so),
271
      .mbist_ctrl_i(mbist_ctrl_i),
272 10 unneback
`endif
273 141 marcus.erl
      .ce(tlb_mr_en),
274
      .we(tlb_mr_we),
275
      .addr(tlb_index),
276
      .di(tlb_mr_ram_in),
277
      .doq(tlb_mr_ram_out)
278
      );
279
 
280
   //
281
   // Instantiation of DTLB Translate Registers
282
   //
283
   //or1200_spram_64x24 dtlb_tr_ram(
284
   or1200_spram #
285
     (
286
      .aw(6),
287
      .dw(24)
288
      )
289
   dtlb_tr_ram
290
     (
291
      .clk(clk),
292 10 unneback
`ifdef OR1200_BIST
293 141 marcus.erl
      // RAM BIST
294
      .mbist_si_i(mbist_tr_si),
295
      .mbist_so_o(mbist_tr_so),
296
      .mbist_ctrl_i(mbist_ctrl_i),
297 10 unneback
`endif
298 141 marcus.erl
      .ce(tlb_tr_en),
299
      .we(tlb_tr_we),
300
      .addr(tlb_index),
301
      .di(tlb_tr_ram_in),
302
      .doq(tlb_tr_ram_out)
303
      );
304
 
305
endmodule // or1200_dmmu_tlb

powered by: WebSVN 2.1.0

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