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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_16/] [or1200/] [rtl/] [verilog/] [or1200_immu_tlb.v] - Blame information for rev 660

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

powered by: WebSVN 2.1.0

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