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

Subversion Repositories or1k

[/] [or1k/] [branches/] [branch_qmem/] [or1200/] [rtl/] [verilog/] [or1200_dc_top.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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