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 617

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

powered by: WebSVN 2.1.0

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