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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_1/] [or1200/] [rtl/] [verilog/] [or1200_dmmu_tlb.v] - Blame information for rev 504

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

powered by: WebSVN 2.1.0

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