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

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [orp/] [orp_soc/] [rtl/] [verilog/] [or1200.old/] [or1200_dmmu_tlb.v] - Blame information for rev 746

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

Line No. Rev Author Line
1 746 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
// Revision 1.3  2002/02/11 04:33:17  lampret
48
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
49
//
50
// Revision 1.2  2002/01/28 01:16:00  lampret
51
// 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.
52
//
53
// Revision 1.1  2002/01/03 08:16:15  lampret
54
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
55
//
56
// Revision 1.8  2001/10/21 17:57:16  lampret
57
// 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.
58
//
59
// Revision 1.7  2001/10/14 13:12:09  lampret
60
// MP3 version.
61
//
62
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
63
// no message
64
//
65
//
66
 
67
// synopsys translate_off
68
`include "timescale.v"
69
// synopsys translate_on
70
`include "or1200_defines.v"
71
 
72
//
73
// Data TLB
74
//
75
 
76
module or1200_dmmu_tlb(
77
        // Rst and clk
78
        clk, rst,
79
 
80
        // I/F for translation
81
        tlb_en, vaddr, hit, ppn, uwe, ure, swe, sre, ci,
82
 
83
        // SPR access
84
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o
85
);
86
 
87
parameter dw = `OR1200_OPERAND_WIDTH;
88
parameter aw = `OR1200_OPERAND_WIDTH;
89
 
90
//
91
// I/O
92
//
93
 
94
//
95
// Clock and reset
96
//
97
input                           clk;
98
input                           rst;
99
 
100
//
101
// I/F for translation
102
//
103
input                           tlb_en;
104
input   [aw-1:0]         vaddr;
105
output                          hit;
106
output  [31:`OR1200_DMMU_PS]    ppn;
107
output                          uwe;
108
output                          ure;
109
output                          swe;
110
output                          sre;
111
output                          ci;
112
 
113
//
114
// SPR access
115
//
116
input                           spr_cs;
117
input                           spr_write;
118
input   [31:0]                   spr_addr;
119
input   [31:0]                   spr_dat_i;
120
output  [31:0]                   spr_dat_o;
121
 
122
//
123
// Internal wires and regs
124
//
125
wire    [`OR1200_DTLB_TAG]      vpn;
126
wire                            v;
127
wire    [`OR1200_DTLB_INDXW-1:0] tlb_index;
128
wire                            tlb_mr_en;
129
wire                            tlb_mr_we;
130
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_in;
131
wire    [`OR1200_DTLBMRW-1:0]    tlb_mr_ram_out;
132
wire                            tlb_tr_en;
133
wire                            tlb_tr_we;
134
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_in;
135
wire    [`OR1200_DTLBTRW-1:0]    tlb_tr_ram_out;
136
 
137
//
138
// Implemented bits inside match and translate registers
139
//
140
// dtlbwYmrX: vpn 31-19  v 0
141
// dtlbwYtrX: ppn 31-13  swe 9  sre 8  uwe 7  ure 6
142
//
143
// dtlb memory width:
144
// 19 bits for ppn
145
// 13 bits for vpn
146
// 1 bit for valid
147
// 4 bits for protection
148
// 1 bit for cache inhibit
149
 
150
//
151
// Enable for Match registers
152
//
153
assign tlb_mr_en = tlb_en | (spr_cs & !spr_addr[`OR1200_DTLB_TM_ADDR]);
154
 
155
//
156
// Write enable for Match registers
157
//
158
assign tlb_mr_we = spr_cs & spr_write & !spr_addr[`OR1200_DTLB_TM_ADDR];
159
 
160
//
161
// Enable for Translate registers
162
//
163
assign tlb_tr_en = tlb_en | (spr_cs & spr_addr[`OR1200_DTLB_TM_ADDR]);
164
 
165
//
166
// Write enable for Translate registers
167
//
168
assign tlb_tr_we = spr_cs & spr_write & spr_addr[`OR1200_DTLB_TM_ADDR];
169
 
170
//
171
// Output to SPRS unit
172
//
173
assign spr_dat_o = (spr_cs & !spr_write & !spr_addr[`OR1200_DTLB_TM_ADDR]) ?
174
                        {vpn, tlb_index & {`OR1200_DTLB_INDXW{v}}, {`OR1200_DTLB_TAGW-7{1'b0}}, 1'b0, 5'b00000, v} :
175
                (spr_cs & !spr_write & spr_addr[`OR1200_DTLB_TM_ADDR]) ?
176
                        {ppn, {`OR1200_DMMU_PS-10{1'b0}}, swe, sre, uwe, ure, {4{1'b0}}, ci, 1'b0} :
177
                        32'h00000000;
178
 
179
//
180
// Assign outputs from Match registers
181
//
182
assign {vpn, v} = tlb_mr_ram_out;
183
 
184
//
185
// Assign to Match registers inputs
186
//
187
assign tlb_mr_ram_in = {spr_dat_i[`OR1200_DTLB_TAG], spr_dat_i[`OR1200_DTLBMR_V_BITS]};
188
 
189
//
190
// Assign outputs from Translate registers
191
//
192
assign {ppn, swe, sre, uwe, ure, ci} = tlb_tr_ram_out;
193
 
194
//
195
// Assign to Translate registers inputs
196
//
197
assign tlb_tr_ram_in = {spr_dat_i[31:`OR1200_DMMU_PS],
198
                        spr_dat_i[`OR1200_DTLBTR_SWE_BITS],
199
                        spr_dat_i[`OR1200_DTLBTR_SRE_BITS],
200
                        spr_dat_i[`OR1200_DTLBTR_UWE_BITS],
201
                        spr_dat_i[`OR1200_DTLBTR_URE_BITS],
202
                        spr_dat_i[`OR1200_DTLBTR_CI_BITS]};
203
 
204
//
205
// Generate hit
206
//
207
assign hit = (vpn == vaddr[`OR1200_DTLB_TAG]) & v;
208
 
209
//
210
// TLB index is normally vaddr[18:13]. If it is SPR access then index is
211
// spr_addr[5:0].
212
//
213
assign tlb_index = spr_cs ? spr_addr[`OR1200_DTLB_INDXW-1:0] : vaddr[`OR1200_DTLB_INDX];
214
 
215
//
216
// Instantiation of DTLB Match Registers
217
//
218
or1200_spram_64x14 dtlb_mr_ram(
219
        .clk(clk),
220
        .rst(rst),
221
        .ce(tlb_mr_en),
222
        .we(tlb_mr_we),
223
        .oe(1'b1),
224
        .addr(tlb_index),
225
        .di(tlb_mr_ram_in),
226
        .do(tlb_mr_ram_out)
227
);
228
 
229
//
230
// Instantiation of DTLB Translate Registers
231
//
232
or1200_spram_64x24 dtlb_tr_ram(
233
        .clk(clk),
234
        .rst(rst),
235
        .ce(tlb_tr_en),
236
        .we(tlb_tr_we),
237
        .oe(1'b1),
238
        .addr(tlb_index),
239
        .di(tlb_tr_ram_in),
240
        .do(tlb_tr_ram_out)
241
);
242
 
243
endmodule

powered by: WebSVN 2.1.0

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