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

Subversion Repositories openriscdevboard

[/] [openriscdevboard/] [trunk/] [cyc2-openrisc/] [rtl/] [or1200/] [or1200_dc_top.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Data Cache 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 DC 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.1  2006/12/21 16:46:58  vak
48
// Initial revision imported from
49
// http://www.opencores.org/cvsget.cgi/or1k/orp/orp_soc/rtl/verilog.
50
//
51
// Revision 1.8  2004/04/05 08:29:57  lampret
52
// Merged branch_qmem into main tree.
53
//
54
// Revision 1.6.4.2  2003/12/09 11:46:48  simons
55
// Mbist nameing changed, Artisan ram instance signal names fixed, some synthesis waning fixed.
56
//
57
// Revision 1.6.4.1  2003/07/08 15:36:37  lampret
58
// Added embedded memory QMEM.
59
//
60
// Revision 1.6  2002/10/17 20:04:40  lampret
61
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
62
//
63
// Revision 1.5  2002/08/18 19:54:47  lampret
64
// Added store buffer.
65
//
66
// Revision 1.4  2002/02/11 04:33:17  lampret
67
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
68
//
69
// Revision 1.3  2002/01/28 01:16:00  lampret
70
// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.
71
//
72
// Revision 1.2  2002/01/14 06:18:22  lampret
73
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
74
//
75
// Revision 1.1  2002/01/03 08:16:15  lampret
76
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
77
//
78
// Revision 1.10  2001/10/21 17:57:16  lampret
79
// 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.
80
//
81
// Revision 1.9  2001/10/14 13:12:09  lampret
82
// MP3 version.
83
//
84
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
85
// no message
86
//
87
// Revision 1.4  2001/08/13 03:36:20  lampret
88
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
89
//
90
// Revision 1.3  2001/08/09 13:39:33  lampret
91
// Major clean-up.
92
//
93
// Revision 1.2  2001/07/22 03:31:53  lampret
94
// Fixed RAM's oen bug. Cache bypass under development.
95
//
96
// Revision 1.1  2001/07/20 00:46:03  lampret
97
// Development version of RTL. Libraries are missing.
98
//
99
//
100
 
101
// synopsys translate_off
102
`include "timescale.v"
103
// synopsys translate_on
104
`include "or1200_defines.v"
105
 
106
//
107
// Data cache
108
//
109
module or1200_dc_top(
110
        // Rst, clk and clock control
111
        clk, rst,
112
 
113
        // External i/f
114
        dcsb_dat_o, dcsb_adr_o, dcsb_cyc_o, dcsb_stb_o, dcsb_we_o, dcsb_sel_o, dcsb_cab_o,
115
        dcsb_dat_i, dcsb_ack_i, dcsb_err_i,
116
 
117
        // Internal i/f
118
        dc_en,
119
        dcqmem_adr_i, dcqmem_cycstb_i, dcqmem_ci_i,
120
        dcqmem_we_i, dcqmem_sel_i, dcqmem_tag_i, dcqmem_dat_i,
121
        dcqmem_dat_o, dcqmem_ack_o, dcqmem_rty_o, dcqmem_err_o, dcqmem_tag_o,
122
 
123
`ifdef OR1200_BIST
124
        // RAM BIST
125
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
126
`endif
127
 
128
        // SPRs
129
        spr_cs, spr_write, spr_dat_i
130
);
131
 
132
parameter dw = `OR1200_OPERAND_WIDTH;
133
 
134
//
135
// I/O
136
//
137
 
138
//
139
// Clock and reset
140
//
141
input                           clk;
142
input                           rst;
143
 
144
//
145
// External I/F
146
//
147
output  [dw-1:0]         dcsb_dat_o;
148
output  [31:0]                   dcsb_adr_o;
149
output                          dcsb_cyc_o;
150
output                          dcsb_stb_o;
151
output                          dcsb_we_o;
152
output  [3:0]                    dcsb_sel_o;
153
output                          dcsb_cab_o;
154
input   [dw-1:0]         dcsb_dat_i;
155
input                           dcsb_ack_i;
156
input                           dcsb_err_i;
157
 
158
//
159
// Internal I/F
160
//
161
input                           dc_en;
162
input   [31:0]                   dcqmem_adr_i;
163
input                           dcqmem_cycstb_i;
164
input                           dcqmem_ci_i;
165
input                           dcqmem_we_i;
166
input   [3:0]                    dcqmem_sel_i;
167
input   [3:0]                    dcqmem_tag_i;
168
input   [dw-1:0]         dcqmem_dat_i;
169
output  [dw-1:0]         dcqmem_dat_o;
170
output                          dcqmem_ack_o;
171
output                          dcqmem_rty_o;
172
output                          dcqmem_err_o;
173
output  [3:0]                    dcqmem_tag_o;
174
 
175
`ifdef OR1200_BIST
176
//
177
// RAM BIST
178
//
179
input mbist_si_i;
180
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
181
output mbist_so_o;
182
`endif
183
 
184
//
185
// SPR access
186
//
187
input                           spr_cs;
188
input                           spr_write;
189
input   [31:0]                   spr_dat_i;
190
 
191
//
192
// Internal wires and regs
193
//
194
wire                            tag_v;
195
wire    [`OR1200_DCTAG_W-2:0]    tag;
196
wire    [dw-1:0]         to_dcram;
197
wire    [dw-1:0]         from_dcram;
198
wire    [31:0]                   saved_addr;
199
wire    [3:0]                    dcram_we;
200
wire                            dctag_we;
201
wire    [31:0]                   dc_addr;
202
wire                            dcfsm_biu_read;
203
wire                            dcfsm_biu_write;
204
reg                             tagcomp_miss;
205
wire    [`OR1200_DCINDXH:`OR1200_DCLS]  dctag_addr;
206
wire                            dctag_en;
207
wire                            dctag_v;
208
wire                            dc_inv;
209
wire                            dcfsm_first_hit_ack;
210
wire                            dcfsm_first_miss_ack;
211
wire                            dcfsm_first_miss_err;
212
wire                            dcfsm_burst;
213
wire                            dcfsm_tag_we;
214
`ifdef OR1200_BIST
215
//
216
// RAM BIST
217
//
218
wire                            mbist_ram_so;
219
wire                            mbist_tag_so;
220
wire                            mbist_ram_si = mbist_si_i;
221
wire                            mbist_tag_si = mbist_ram_so;
222
assign                          mbist_so_o = mbist_tag_so;
223
`endif
224
 
225
//
226
// Simple assignments
227
//
228
assign dcsb_adr_o = dc_addr;
229
assign dc_inv = spr_cs & spr_write;
230
assign dctag_we = dcfsm_tag_we | dc_inv;
231
assign dctag_addr = dc_inv ? spr_dat_i[`OR1200_DCINDXH:`OR1200_DCLS] : dc_addr[`OR1200_DCINDXH:`OR1200_DCLS];
232
assign dctag_en = dc_inv | dc_en;
233
assign dctag_v = ~dc_inv;
234
 
235
//
236
// Data to BIU is from DCRAM when DC is enabled or from LSU when
237
// DC is disabled
238
//
239
assign dcsb_dat_o = dcqmem_dat_i;
240
 
241
//
242
// Bypases of the DC when DC is disabled
243
//
244
assign dcsb_cyc_o = (dc_en) ? dcfsm_biu_read | dcfsm_biu_write : dcqmem_cycstb_i;
245
assign dcsb_stb_o = (dc_en) ? dcfsm_biu_read | dcfsm_biu_write : dcqmem_cycstb_i;
246
assign dcsb_we_o = (dc_en) ? dcfsm_biu_write : dcqmem_we_i;
247
assign dcsb_sel_o = (dc_en & dcfsm_biu_read & !dcfsm_biu_write & !dcqmem_ci_i) ? 4'b1111 : dcqmem_sel_i;
248
assign dcsb_cab_o = (dc_en) ? dcfsm_burst : 1'b0;
249
assign dcqmem_rty_o = ~dcqmem_ack_o;
250
assign dcqmem_tag_o = dcqmem_err_o ? `OR1200_DTAG_BE : dcqmem_tag_i;
251
 
252
//
253
// DC/LSU normal and error termination
254
//
255
assign dcqmem_ack_o = dc_en ? dcfsm_first_hit_ack | dcfsm_first_miss_ack : dcsb_ack_i;
256
assign dcqmem_err_o = dc_en ? dcfsm_first_miss_err : dcsb_err_i;
257
 
258
//
259
// Select between claddr generated by DC FSM and addr[3:2] generated by LSU
260
//
261
//assign dc_addr = (dcfsm_biu_read | dcfsm_biu_write) ? saved_addr : dcqmem_adr_i;
262
 
263
//
264
// Select between input data generated by LSU or by BIU
265
//
266
assign to_dcram = (dcfsm_biu_read) ? dcsb_dat_i : dcqmem_dat_i;
267
 
268
//
269
// Select between data generated by DCRAM or passed by BIU
270
//
271
assign dcqmem_dat_o = dcfsm_first_miss_ack | !dc_en ? dcsb_dat_i : from_dcram;
272
 
273
//
274
// Tag comparison
275
//
276
always @(tag or saved_addr or tag_v) begin
277
        if ((tag != saved_addr[31:`OR1200_DCTAGL]) || !tag_v)
278
                tagcomp_miss = 1'b1;
279
        else
280
                tagcomp_miss = 1'b0;
281
end
282
 
283
//
284
// Instantiation of DC Finite State Machine
285
//
286
or1200_dc_fsm or1200_dc_fsm(
287
        .clk(clk),
288
        .rst(rst),
289
        .dc_en(dc_en),
290
        .dcqmem_cycstb_i(dcqmem_cycstb_i),
291
        .dcqmem_ci_i(dcqmem_ci_i),
292
        .dcqmem_we_i(dcqmem_we_i),
293
        .dcqmem_sel_i(dcqmem_sel_i),
294
        .tagcomp_miss(tagcomp_miss),
295
        .biudata_valid(dcsb_ack_i),
296
        .biudata_error(dcsb_err_i),
297
        .start_addr(dcqmem_adr_i),
298
        .saved_addr(saved_addr),
299
        .dcram_we(dcram_we),
300
        .biu_read(dcfsm_biu_read),
301
        .biu_write(dcfsm_biu_write),
302
        .first_hit_ack(dcfsm_first_hit_ack),
303
        .first_miss_ack(dcfsm_first_miss_ack),
304
        .first_miss_err(dcfsm_first_miss_err),
305
        .burst(dcfsm_burst),
306
        .tag_we(dcfsm_tag_we),
307
        .dc_addr(dc_addr)
308
);
309
 
310
//
311
// Instantiation of DC main memory
312
//
313
or1200_dc_ram or1200_dc_ram(
314
        .clk(clk),
315
        .rst(rst),
316
`ifdef OR1200_BIST
317
        // RAM BIST
318
        .mbist_si_i(mbist_ram_si),
319
        .mbist_so_o(mbist_ram_so),
320
        .mbist_ctrl_i(mbist_ctrl_i),
321
`endif
322
        .addr(dc_addr[`OR1200_DCINDXH:2]),
323
        .en(dc_en),
324
        .we(dcram_we),
325
        .datain(to_dcram),
326
        .dataout(from_dcram)
327
);
328
 
329
//
330
// Instantiation of DC TAG memory
331
//
332
or1200_dc_tag or1200_dc_tag(
333
        .clk(clk),
334
        .rst(rst),
335
`ifdef OR1200_BIST
336
        // RAM BIST
337
        .mbist_si_i(mbist_tag_si),
338
        .mbist_so_o(mbist_tag_so),
339
        .mbist_ctrl_i(mbist_ctrl_i),
340
`endif
341
        .addr(dctag_addr),
342
        .en(dctag_en),
343
        .we(dctag_we),
344
        .datain({dc_addr[31:`OR1200_DCTAGL], dctag_v}),
345
        .tag_v(tag_v),
346
        .tag(tag)
347
);
348
 
349
endmodule

powered by: WebSVN 2.1.0

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