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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [or1200/] [rtl/] [verilog/] [immu.v] - Blame information for rev 218

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

Line No. Rev Author Line
1 218 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Insn MMU top level                                 ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Instantiation of all IMMU blocks.                           ////
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.5  2001/10/14 13:12:09  lampret
48
// MP3 version.
49
//
50
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
51
// no message
52
//
53
// Revision 1.1  2001/08/17 08:03:35  lampret
54
// *** empty log message ***
55
//
56
// Revision 1.2  2001/07/22 03:31:53  lampret
57
// Fixed RAM's oen bug. Cache bypass under development.
58
//
59
// Revision 1.1  2001/07/20 00:46:03  lampret
60
// Development version of RTL. Libraries are missing.
61
//
62
//
63
 
64
// synopsys translate_off
65
`include "timescale.v"
66
// synopsys translate_on
67
`include "defines.v"
68
 
69
//
70
// Insn MMU
71
//
72
 
73
module immu(
74
        // Rst and clk
75
        clk, rst,
76
 
77
        // Fetch i/f
78
        immu_en, supv, immufetch_vaddr, immufetch_op, immufetch_stall,
79
 
80
        // Except I/F
81
        immuexcept_miss, immuexcept_fault,
82
 
83
        // SPR access
84
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
85
 
86
        // IC i/f
87
        icimmu_paddr
88
);
89
 
90
parameter dw = `OPERAND_WIDTH;
91
parameter aw = `OPERAND_WIDTH;
92
 
93
//
94
// I/O
95
//
96
 
97
//
98
// Clock and reset
99
//
100
input                           clk;
101
input                           rst;
102
 
103
//
104
// FETCH I/F
105
//
106
input                           immu_en;
107
input                           supv;
108
input   [aw-1:0]         immufetch_vaddr;
109
input                           immufetch_op;
110
output                          immufetch_stall;
111
 
112
//
113
// Exception I/F
114
//
115
output                          immuexcept_miss;
116
output                          immuexcept_fault;
117
 
118
//
119
// SPR access
120
//
121
input                           spr_cs;
122
input                           spr_write;
123
input   [aw-1:0]         spr_addr;
124
input   [31:0]                   spr_dat_i;
125
output  [31:0]                   spr_dat_o;
126
 
127
//
128
// IC I/F
129
//
130
output  [aw-1:0]         icimmu_paddr;
131
 
132
//
133
// Internal wires and regs
134
//
135
wire                            itlb_spr_access;
136
wire    [31:13]                 itlb_ppn;
137
wire                            itlb_hit;
138
wire                            itlb_uxe;
139
wire                            itlb_sxe;
140
wire    [31:0]                   itlb_dat_o;
141
 
142
//
143
// Implemented bits inside match and translate registers
144
//
145
// itlbwYmrX: vpn 31-10  v 0
146
// itlbwYtrX: ppn 31-10  uxe 7  sxe 6
147
//
148
// itlb memory width:
149
// 19 bits for ppn
150
// 13 bits for vpn
151
// 1 bit for valid
152
// 2 bits for protection
153
 
154
`ifdef OR1200_NO_IMMU
155
 
156
//
157
// Put all outputs in inactive state
158
//
159
assign immufetch_stall = 1'b0;
160
assign immuexcept_miss = 1'b0;
161
assign immuexcept_fault = 1'b0;
162
assign spr_dat_o = 32'h00000000;
163
assign icimmu_paddr = immufetch_vaddr;
164
 
165
`else
166
 
167
//
168
// ITLB SPR access
169
//
170
// 1400 - 1600  itlbmr w0-3
171
// 1400 - 1480  itlbmr w0
172
// 1400 - 1440  itlbmr w0 [63:0]
173
//
174
// 1600 - 1800  itlbtr w0-3
175
// 1600 - 1680  itlbtr w0
176
// 1600 - 1640  itlbtr w0 [63:0]
177
//
178
assign itlb_spr_access = spr_cs & spr_addr[10];
179
 
180
//
181
// Physical address is either translated virtual address or
182
// simply equal when IMMU is disabled
183
//
184
assign icimmu_paddr = immu_en ? {itlb_ppn, immufetch_vaddr[12:0]} : immufetch_vaddr;
185
 
186
//
187
// Output to SPRS unit
188
//
189
assign spr_dat_o = itlb_spr_access ? itlb_dat_o : 32'h00000000;
190
 
191
//
192
// IMMU stall
193
//
194
assign immufetch_stall = 1'b0;
195
 
196
//
197
// Page fault exception logic
198
//
199
assign immuexcept_fault = immu_en &&
200
                        (  (immufetch_op & !supv & !itlb_uxe) // Fetch in user mode not enabled
201
                        || (immufetch_op & supv & !itlb_sxe) ); // Fetch in supv mode not enabled
202
 
203
//
204
// TLB Miss exception logic
205
//
206
assign immuexcept_miss = immufetch_op && immu_en && !itlb_hit;
207
 
208
//
209
// Instantiation of ITLB
210
//
211
itlb itlb(
212
        // Rst and clk
213
        .clk(clk),
214
        .rst(rst),
215
 
216
        // I/F for translation
217
        .tlb_en(immu_en),
218
        .vaddr(immufetch_vaddr),
219
        .hit(itlb_hit),
220
        .ppn(itlb_ppn),
221
        .uxe(itlb_uxe),
222
        .sxe(itlb_sxe),
223
 
224
        // SPR access
225
        .spr_cs(itlb_spr_access),
226
        .spr_write(spr_write),
227
        .spr_addr(spr_addr),
228
        .spr_dat_i(spr_dat_i),
229
        .spr_dat_o(itlb_dat_o)
230
);
231
 
232
`endif
233
 
234
endmodule

powered by: WebSVN 2.1.0

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