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

Subversion Repositories or1k

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