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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_dmmu_top.v] - Blame information for rev 562

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Data 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 DMMU 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 562 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
48
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
49
//
50 504 lampret
// Revision 1.6  2001/10/21 17:57:16  lampret
51
// 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.
52
//
53
// Revision 1.5  2001/10/14 13:12:09  lampret
54
// MP3 version.
55
//
56
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
57
// no message
58
//
59
// Revision 1.1  2001/08/17 08:03:35  lampret
60
// *** empty log message ***
61
//
62
// Revision 1.2  2001/07/22 03:31:53  lampret
63
// Fixed RAM's oen bug. Cache bypass under development.
64
//
65
// Revision 1.1  2001/07/20 00:46:03  lampret
66
// Development version of RTL. Libraries are missing.
67
//
68
//
69
 
70
// synopsys translate_off
71
`include "timescale.v"
72
// synopsys translate_on
73
`include "or1200_defines.v"
74
 
75
//
76
// Data MMU
77
//
78
 
79
module or1200_dmmu_top(
80
        // Rst and clk
81
        clk, rst,
82
 
83
        // CPU i/f
84
        dc_en, dmmu_en, supv, dcpu_adr_i, dcpu_cyc_i, dcpu_stb_i, dcpu_we_i,
85
        dcpu_tag_o, dcpu_err_o,
86
 
87
        // SPR access
88
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
89
 
90
        // DC i/f
91
        dcdmmu_err_i, dcdmmu_tag_i, dcdmmu_adr_o, dcdmmu_cyc_o, dcdmmu_stb_o, dcdmmu_ci_o
92
);
93
 
94
parameter dw = `OR1200_OPERAND_WIDTH;
95
parameter aw = `OR1200_OPERAND_WIDTH;
96
 
97
//
98
// I/O
99
//
100
 
101
//
102
// Clock and reset
103
//
104
input                           clk;
105
input                           rst;
106
 
107
//
108
// CPU I/F
109
//
110
input                           dc_en;
111
input                           dmmu_en;
112
input                           supv;
113
input   [aw-1:0]         dcpu_adr_i;
114
input                           dcpu_cyc_i;
115
input                           dcpu_stb_i;
116
input                           dcpu_we_i;
117
output  [3:0]                    dcpu_tag_o;
118
output                          dcpu_err_o;
119
 
120
//
121
// SPR access
122
//
123
input                           spr_cs;
124
input                           spr_write;
125
input   [aw-1:0]         spr_addr;
126
input   [31:0]                   spr_dat_i;
127
output  [31:0]                   spr_dat_o;
128
 
129
//
130
// DC I/F
131
//
132
input                           dcdmmu_err_i;
133
input   [3:0]                    dcdmmu_tag_i;
134
output  [aw-1:0]         dcdmmu_adr_o;
135
output                          dcdmmu_cyc_o;
136
output                          dcdmmu_stb_o;
137
output                          dcdmmu_ci_o;
138
 
139
//
140
// Internal wires and regs
141
//
142
wire                            dtlb_spr_access;
143
wire    [31:`OR1200_DMMU_PS]    dtlb_ppn;
144
wire                            dtlb_hit;
145
wire                            dtlb_uwe;
146
wire                            dtlb_ure;
147
wire                            dtlb_swe;
148
wire                            dtlb_sre;
149
wire    [31:0]                   dtlb_dat_o;
150
wire                            dtlb_en;
151
wire                            dtlb_ci;
152
wire                            dtlb_done;
153
wire                            fault;
154
wire                            miss;
155
reg                             dcpu_cyc_dlyd;
156
reg                             dcpu_stb_dlyd;
157
 
158
//
159
// Implemented bits inside match and translate registers
160
//
161
// dtlbwYmrX: vpn 31-10  v 0
162
// dtlbwYtrX: ppn 31-10  swe 9  sre 8  uwe 7  ure 6
163
//
164
// dtlb memory width:
165
// 19 bits for ppn
166
// 13 bits for vpn
167
// 1 bit for valid
168
// 4 bits for protection
169
// 1 bit for cache inhibit
170
 
171
`ifdef OR1200_NO_DMMU
172
 
173
//
174
// Put all outputs in inactive state
175
//
176
assign spr_dat_o = 32'h00000000;
177
assign dcdmmu_adr_o = dcpu_adr_i;
178
assign dcpu_tag_o = dcdmmu_tag_i;
179
assign dcdmmu_cyc_o = dcpu_cyc_i;
180
assign dcdmmu_stb_o = dcpu_stb_i;
181
assign dcpu_err_o = dcdmmu_err_i;
182
assign dcdmmu_ci_o = !dcpu_adr_i[30];
183
 
184
`else
185
 
186
//
187
// DTLB SPR access
188
//
189
// 0A00 - 0AFF  dtlbmr w0
190
// 0A00 - 0A3F  dtlbmr w0 [63:0]
191
//
192
// 0B00 - 0BFF  dtlbtr w0
193
// 0B00 - 0B3F  dtlbtr w0 [63:0]
194
//
195
assign dtlb_spr_access = spr_cs;
196
 
197
//
198
// Tags:
199
//
200
// OR1200_DTAG_TE - TLB miss Exception
201
// OR1200_DTAG_PE - Page fault Exception
202
//
203
assign dcpu_tag_o = miss ? `OR1200_DTAG_TE : fault ? `OR1200_DTAG_PE : dcdmmu_tag_i;
204
 
205
//
206
// dcpu_err_o
207
//
208
assign dcpu_err_o = miss | fault | dcdmmu_err_i;
209
 
210
//
211
// Delay WISHBONE control signals in case DC is disabled and DMMU is
212
// enabled to prevent premature external BIU access.
213
//
214
always @(posedge rst or posedge clk)
215
        if (rst)
216
                dcpu_cyc_dlyd <= #1 1'b0;
217
        else
218
                dcpu_cyc_dlyd <= #1 ~(miss | fault) & dcpu_cyc_i;
219
always @(posedge rst or posedge clk)
220
        if (rst)
221
                dcpu_stb_dlyd <= #1 1'b0;
222
        else
223
                dcpu_stb_dlyd <= #1 ~(miss | fault) & dcpu_stb_i;
224
 
225
//
226
// Cut transfer if something goes wrong with translation. If DC is disabled,
227
// use delayed signals.
228
//
229
assign dcdmmu_cyc_o = (!dc_en & dmmu_en) ? ~(miss | fault) & dcpu_cyc_dlyd : (miss | fault) ? 1'b0 : dcpu_cyc_i;
230
assign dcdmmu_stb_o = (!dc_en & dmmu_en) ? ~(miss | fault) & dcpu_stb_dlyd : (miss | fault) ? 1'b0 : dcpu_stb_i;
231
 
232
//
233
// Cache Inhibit
234
//
235 562 lampret
assign dcdmmu_ci_o = dmmu_en ? dtlb_done & dtlb_ci : 1'b0;
236 504 lampret
 
237
//
238
// Physical address is either translated virtual address or
239
// simply equal when DMMU is disabled
240
//
241
assign dcdmmu_adr_o = dmmu_en ? {dtlb_ppn, dcpu_adr_i[`OR1200_DMMU_PS-1:0]} : dcpu_adr_i;
242
 
243
//
244
// Output to SPRS unit
245
//
246
assign spr_dat_o = dtlb_spr_access ? dtlb_dat_o : 32'h00000000;
247
 
248
//
249
// Page fault exception logic
250
//
251
assign fault = dtlb_en & dtlb_done &
252
                        (  (!dcpu_we_i & !supv & !dtlb_ure) // Load in user mode not enabled
253
                        || (!dcpu_we_i & supv & !dtlb_sre) // Load in supv mode not enabled
254
                        || (dcpu_we_i & !supv & !dtlb_uwe) // Store in user mode not enabled
255
                        || (dcpu_we_i & supv & !dtlb_swe) ); // Store in supv mode not enabled
256
 
257
//
258
// TLB Miss exception logic
259
//
260
assign miss = dtlb_en & dtlb_done & !dtlb_hit;
261
 
262
//
263
// DTLB Enable
264
//
265
assign dtlb_en = dmmu_en & dcpu_cyc_i & dcpu_stb_i;
266
 
267
//
268
// Instantiation of DTLB
269
//
270
or1200_dmmu_tlb or1200_dmmu_tlb(
271
        // Rst and clk
272
        .clk(clk),
273
        .rst(rst),
274
 
275
        // I/F for translation
276
        .tlb_en(dtlb_en),
277
        .vaddr(dcpu_adr_i),
278
        .hit(dtlb_hit),
279
        .ppn(dtlb_ppn),
280
        .uwe(dtlb_uwe),
281
        .ure(dtlb_ure),
282
        .swe(dtlb_swe),
283
        .sre(dtlb_sre),
284
        .ci(dtlb_ci),
285
        .done(dtlb_done),
286
 
287
        // SPR access
288
        .spr_cs(dtlb_spr_access),
289
        .spr_write(spr_write),
290
        .spr_addr(spr_addr),
291
        .spr_dat_i(spr_dat_i),
292
        .spr_dat_o(dtlb_dat_o)
293
);
294
 
295
`endif
296
 
297
endmodule

powered by: WebSVN 2.1.0

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