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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [or1200/] [or1200_dmmu_top.v] - Blame information for rev 483

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 350 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Data MMU top level                                 ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/project,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
// $Log: or1200_dmmu_top.v,v $
45
// Revision 2.0  2010/06/30 11:00:00  ORSoC
46
// Minor update: 
47
// Bugs fixed. 
48
//
49
 
50
// synopsys translate_off
51
`include "timescale.v"
52
// synopsys translate_on
53
`include "or1200_defines.v"
54
 
55
//
56
// Data MMU
57
//
58
 
59
module or1200_dmmu_top(
60
        // Rst and clk
61
        clk, rst,
62
 
63
        // CPU i/f
64
        dc_en, dmmu_en, supv, dcpu_adr_i, dcpu_cycstb_i, dcpu_we_i,
65
        dcpu_tag_o, dcpu_err_o,
66
 
67
        // SPR access
68
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
69
 
70
`ifdef OR1200_BIST
71
        // RAM BIST
72
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
73
`endif
74
 
75 483 julius
`ifdef OR1200_RAM_PARITY
76
        // Parity error indicator
77
        p_err,
78
`endif
79
 
80 350 julius
        // DC i/f
81
        qmemdmmu_err_i, qmemdmmu_tag_i, qmemdmmu_adr_o, qmemdmmu_cycstb_o, qmemdmmu_ci_o
82
);
83
 
84
parameter dw = `OR1200_OPERAND_WIDTH;
85
parameter aw = `OR1200_OPERAND_WIDTH;
86
 
87
//
88
// I/O
89
//
90
 
91
//
92
// Clock and reset
93
//
94
input                           clk;
95
input                           rst;
96
 
97
//
98
// CPU I/F
99
//
100
input                           dc_en;
101
input                           dmmu_en;
102
input                           supv;
103
input   [aw-1:0]         dcpu_adr_i;
104
input                           dcpu_cycstb_i;
105
input                           dcpu_we_i;
106
output  [3:0]                    dcpu_tag_o;
107
output                          dcpu_err_o;
108
 
109
//
110
// SPR access
111
//
112
input                           spr_cs;
113
input                           spr_write;
114
input   [aw-1:0]         spr_addr;
115
input   [31:0]                   spr_dat_i;
116
output  [31:0]                   spr_dat_o;
117
 
118
`ifdef OR1200_BIST
119
//
120
// RAM BIST
121
//
122
input mbist_si_i;
123
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
124
output mbist_so_o;
125
`endif
126
 
127 483 julius
`ifdef OR1200_RAM_PARITY
128
output [1:0]                     p_err;
129
`endif
130
 
131 350 julius
//
132
// DC I/F
133
//
134
input                           qmemdmmu_err_i;
135
input   [3:0]                    qmemdmmu_tag_i;
136
output  [aw-1:0]         qmemdmmu_adr_o;
137
output                          qmemdmmu_cycstb_o;
138
output                          qmemdmmu_ci_o;
139
 
140
//
141
// Internal wires and regs
142
//
143
wire                            dtlb_spr_access;
144
wire    [31:`OR1200_DMMU_PS]    dtlb_ppn;
145
wire                            dtlb_hit;
146
wire                            dtlb_uwe;
147
wire                            dtlb_ure;
148
wire                            dtlb_swe;
149
wire                            dtlb_sre;
150
wire    [31:0]                   dtlb_dat_o;
151
wire                            dtlb_en;
152
wire                            dtlb_ci;
153
wire                            fault;
154
wire                            miss;
155
`ifdef OR1200_NO_DMMU
156
`else
157
reg                             dtlb_done;
158
reg     [31:`OR1200_DMMU_PS]    dcpu_vpn_r;
159
`endif
160
 
161
//
162
// Implemented bits inside match and translate registers
163
//
164
// dtlbwYmrX: vpn 31-10  v 0
165
// dtlbwYtrX: ppn 31-10  swe 9  sre 8  uwe 7  ure 6
166
//
167
// dtlb memory width:
168
// 19 bits for ppn
169
// 13 bits for vpn
170
// 1 bit for valid
171
// 4 bits for protection
172
// 1 bit for cache inhibit
173
 
174
`ifdef OR1200_NO_DMMU
175
 
176
//
177
// Put all outputs in inactive state
178
//
179
assign spr_dat_o = 32'h00000000;
180
assign qmemdmmu_adr_o = dcpu_adr_i;
181
assign dcpu_tag_o = qmemdmmu_tag_i;
182
assign qmemdmmu_cycstb_o = dcpu_cycstb_i;
183
assign dcpu_err_o = qmemdmmu_err_i;
184
assign qmemdmmu_ci_o = `OR1200_DMMU_CI;
185
`ifdef OR1200_BIST
186
assign mbist_so_o = mbist_si_i;
187
`endif
188 483 julius
`ifdef OR1200_RAM_PARITY
189
assign p_err = 0;
190
`endif
191 350 julius
 
192
`else
193
 
194
//
195
// DTLB SPR access
196
//
197
// 0A00 - 0AFF  dtlbmr w0
198
// 0A00 - 0A3F  dtlbmr w0 [63:0]
199
//
200
// 0B00 - 0BFF  dtlbtr w0
201
// 0B00 - 0B3F  dtlbtr w0 [63:0]
202
//
203
assign dtlb_spr_access = spr_cs;
204
 
205
//
206
// Tags:
207
//
208
// OR1200_DTAG_TE - TLB miss Exception
209
// OR1200_DTAG_PE - Page fault Exception
210
//
211
assign dcpu_tag_o = miss ? `OR1200_DTAG_TE : fault ? `OR1200_DTAG_PE : qmemdmmu_tag_i;
212
 
213
//
214
// dcpu_err_o
215
//
216
assign dcpu_err_o = miss | fault | qmemdmmu_err_i;
217
 
218
//
219
// Assert dtlb_done one clock cycle after new address and dtlb_en must be active
220
//
221 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
222
        if (rst == `OR1200_RST_VALUE)
223 350 julius
                dtlb_done <=  1'b0;
224
        else if (dtlb_en)
225
                dtlb_done <=  dcpu_cycstb_i;
226
        else
227
                dtlb_done <=  1'b0;
228
 
229
//
230
// Cut transfer if something goes wrong with translation. Also delayed signals 
231
// because of translation delay.
232
assign qmemdmmu_cycstb_o = (dc_en & dmmu_en) ?
233
                           !(miss | fault) & dtlb_done & dcpu_cycstb_i :
234
                           !(miss | fault) & dcpu_cycstb_i;
235
 
236
 
237
//
238
// Cache Inhibit
239
//
240
assign qmemdmmu_ci_o = dmmu_en ? dtlb_ci : `OR1200_DMMU_CI;
241
 
242
//
243
// Register dcpu_adr_i's VPN for use when DMMU is not enabled but PPN is 
244
// expected to come one clock cycle after offset part.
245
//
246 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
247
        if (rst == `OR1200_RST_VALUE)
248 363 julius
                dcpu_vpn_r <=  {32-`OR1200_DMMU_PS{1'b0}};
249 350 julius
        else
250
                dcpu_vpn_r <=  dcpu_adr_i[31:`OR1200_DMMU_PS];
251
 
252
//
253
// Physical address is either translated virtual address or
254
// simply equal when DMMU is disabled
255
//
256
assign qmemdmmu_adr_o = dmmu_en ? {dtlb_ppn, dcpu_adr_i[`OR1200_DMMU_PS-1:0]} :
257
                                  dcpu_adr_i;
258
 
259
//
260
// Output to SPRS unit
261
//
262
assign spr_dat_o = dtlb_spr_access ? dtlb_dat_o : 32'h00000000;
263
 
264
//
265
// Page fault exception logic
266
//
267
assign fault = dtlb_done &
268
        (  (!dcpu_we_i & !supv & !dtlb_ure) // Load in user mode not enabled
269
           || (!dcpu_we_i & supv & !dtlb_sre) // Load in supv mode not enabled
270
           || (dcpu_we_i & !supv & !dtlb_uwe) // Store in user mode not enabled
271
           || (dcpu_we_i & supv & !dtlb_swe)); // Store in supv mode not enabled
272
 
273
//
274
// TLB Miss exception logic
275
//
276
assign miss = dtlb_done & !dtlb_hit;
277
 
278
//
279
// DTLB Enable
280
//
281
assign dtlb_en = dmmu_en & dcpu_cycstb_i;
282
 
283
//
284
// Instantiation of DTLB
285
//
286
or1200_dmmu_tlb or1200_dmmu_tlb(
287
        // Rst and clk
288
        .clk(clk),
289
        .rst(rst),
290
 
291
        // I/F for translation
292
        .tlb_en(dtlb_en),
293
        .vaddr(dcpu_adr_i),
294
        .hit(dtlb_hit),
295
        .ppn(dtlb_ppn),
296
        .uwe(dtlb_uwe),
297
        .ure(dtlb_ure),
298
        .swe(dtlb_swe),
299
        .sre(dtlb_sre),
300
        .ci(dtlb_ci),
301
 
302
`ifdef OR1200_BIST
303
        // RAM BIST
304
        .mbist_si_i(mbist_si_i),
305
        .mbist_so_o(mbist_so_o),
306
        .mbist_ctrl_i(mbist_ctrl_i),
307
`endif
308
 
309 483 julius
`ifdef OR1200_RAM_PARITY
310
        .p_err(p_err),
311
`endif
312
 
313 350 julius
        // SPR access
314
        .spr_cs(dtlb_spr_access),
315
        .spr_write(spr_write),
316
        .spr_addr(spr_addr),
317
        .spr_dat_i(spr_dat_i),
318
        .spr_dat_o(dtlb_dat_o)
319
);
320
 
321
`endif
322
 
323
endmodule

powered by: WebSVN 2.1.0

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