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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm2/] [verilog/] [or1200_dc_top.v] - Blame information for rev 2

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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