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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm4/] [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_cm4(
103
                clk_i_cml_1,
104
                clk_i_cml_2,
105
                clk_i_cml_3,
106
                cmls,
107
 
108
        // Rst, clk and clock control
109
        clk, rst,
110
 
111
        // External i/f
112
        dcsb_dat_o, dcsb_adr_o, dcsb_cyc_o, dcsb_stb_o, dcsb_we_o, dcsb_sel_o, dcsb_cab_o,
113
        dcsb_dat_i, dcsb_ack_i, dcsb_err_i,
114
 
115
        // Internal i/f
116
        dc_en,
117
        dcqmem_adr_i, dcqmem_cycstb_i, dcqmem_ci_i,
118
        dcqmem_we_i, dcqmem_sel_i, dcqmem_tag_i, dcqmem_dat_i,
119
        dcqmem_dat_o, dcqmem_ack_o, dcqmem_rty_o, dcqmem_err_o, dcqmem_tag_o,
120
 
121
`ifdef OR1200_BIST
122
        // RAM BIST
123
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
124
`endif
125
 
126
        // SPRs
127
        spr_cs, spr_write, spr_dat_i
128
);
129
 
130
 
131
input clk_i_cml_1;
132
input clk_i_cml_2;
133
input clk_i_cml_3;
134
input [1:0] cmls;
135
reg [ 32 - 1 : 0 ] dcsb_dat_i_cml_3;
136
reg  dc_en_cml_3;
137
reg  dc_en_cml_2;
138
reg  dc_en_cml_1;
139
reg  dcqmem_ci_i_cml_3;
140
reg  dcqmem_ci_i_cml_2;
141
reg  dcqmem_ci_i_cml_1;
142
reg  dcqmem_ack_o_cml_1;
143
reg  spr_write_cml_2;
144
reg  spr_write_cml_1;
145
reg [ 31 : 0 ] spr_dat_i_cml_2;
146
reg [ 31 : 0 ] spr_dat_i_cml_1;
147
reg [ 32 - 1 : 0 ] from_dcram_cml_2;
148
reg [ 31 : 0 ] dc_addr_cml_3;
149
reg  dcfsm_biu_read_cml_3;
150
reg  dcfsm_biu_write_cml_3;
151
reg  dc_inv_cml_3;
152
reg  dcfsm_first_miss_ack_cml_2;
153
reg  dcfsm_first_miss_ack_cml_1;
154
 
155
 
156
 
157
parameter dw = `OR1200_OPERAND_WIDTH;
158
 
159
//
160
// I/O
161
//
162
 
163
//
164
// Clock and reset
165
//
166
input                           clk;
167
input                           rst;
168
 
169
//
170
// External I/F
171
//
172
output  [dw-1:0]         dcsb_dat_o;
173
output  [31:0]                   dcsb_adr_o;
174
output                          dcsb_cyc_o;
175
output                          dcsb_stb_o;
176
output                          dcsb_we_o;
177
output  [3:0]                    dcsb_sel_o;
178
output                          dcsb_cab_o;
179
input   [dw-1:0]         dcsb_dat_i;
180
input                           dcsb_ack_i;
181
input                           dcsb_err_i;
182
 
183
//
184
// Internal I/F
185
//
186
input                           dc_en;
187
input   [31:0]                   dcqmem_adr_i;
188
input                           dcqmem_cycstb_i;
189
input                           dcqmem_ci_i;
190
input                           dcqmem_we_i;
191
input   [3:0]                    dcqmem_sel_i;
192
input   [3:0]                    dcqmem_tag_i;
193
input   [dw-1:0]         dcqmem_dat_i;
194
output  [dw-1:0]         dcqmem_dat_o;
195
output                          dcqmem_ack_o;
196
output                          dcqmem_rty_o;
197
output                          dcqmem_err_o;
198
output  [3:0]                    dcqmem_tag_o;
199
 
200
`ifdef OR1200_BIST
201
//
202
// RAM BIST
203
//
204
input mbist_si_i;
205
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
206
output mbist_so_o;
207
`endif
208
 
209
//
210
// SPR access
211
//
212
input                           spr_cs;
213
input                           spr_write;
214
input   [31:0]                   spr_dat_i;
215
 
216
//
217
// Internal wires and regs
218
//
219
wire                            tag_v;
220
wire    [`OR1200_DCTAG_W-2:0]    tag;
221
wire    [dw-1:0]         to_dcram;
222
wire    [dw-1:0]         from_dcram;
223
wire    [31:0]                   saved_addr;
224
wire    [3:0]                    dcram_we;
225
wire                            dctag_we;
226
wire    [31:0]                   dc_addr;
227
wire                            dcfsm_biu_read;
228
wire                            dcfsm_biu_write;
229
reg                             tagcomp_miss;
230
wire    [`OR1200_DCINDXH:`OR1200_DCLS]  dctag_addr;
231
wire                            dctag_en;
232
wire                            dctag_v;
233
wire                            dc_inv;
234
wire                            dcfsm_first_hit_ack;
235
wire                            dcfsm_first_miss_ack;
236
wire                            dcfsm_first_miss_err;
237
wire                            dcfsm_burst;
238
wire                            dcfsm_tag_we;
239
`ifdef OR1200_BIST
240
//
241
// RAM BIST
242
//
243
wire                            mbist_ram_so;
244
wire                            mbist_tag_so;
245
wire                            mbist_ram_si = mbist_si_i;
246
wire                            mbist_tag_si = mbist_ram_so;
247
assign                          mbist_so_o = mbist_tag_so;
248
`endif
249
 
250
//
251
// Simple assignments
252
//
253
 
254
// SynEDA CoreMultiplier
255
// assignment(s): dcsb_adr_o
256
// replace(s): dc_addr
257
assign dcsb_adr_o = dc_addr_cml_3;
258
 
259
// SynEDA CoreMultiplier
260
// assignment(s): dc_inv
261
// replace(s): spr_write
262
assign dc_inv = spr_cs & spr_write_cml_2;
263
 
264
// SynEDA CoreMultiplier
265
// assignment(s): dctag_we
266
// replace(s): dc_inv
267
assign dctag_we = dcfsm_tag_we | dc_inv_cml_3;
268
 
269
// SynEDA CoreMultiplier
270
// assignment(s): dctag_addr
271
// replace(s): spr_dat_i
272
assign dctag_addr = dc_inv ? spr_dat_i_cml_2[`OR1200_DCINDXH:`OR1200_DCLS] : dc_addr[`OR1200_DCINDXH:`OR1200_DCLS];
273
 
274
// SynEDA CoreMultiplier
275
// assignment(s): dctag_en
276
// replace(s): dc_en, dc_inv
277
assign dctag_en = dc_inv_cml_3 | dc_en_cml_3;
278
assign dctag_v = ~dc_inv_cml_3;
279
 
280
//
281
// Data to BIU is from DCRAM when DC is enabled or from LSU when
282
// DC is disabled
283
//
284
assign dcsb_dat_o = dcqmem_dat_i;
285
 
286
//
287
// Bypases of the DC when DC is disabled
288
//
289
 
290
// SynEDA CoreMultiplier
291
// assignment(s): dcsb_cyc_o
292
// replace(s): dc_en, dcfsm_biu_read, dcfsm_biu_write
293
assign dcsb_cyc_o = (dc_en_cml_3) ? dcfsm_biu_read_cml_3 | dcfsm_biu_write_cml_3 : dcqmem_cycstb_i;
294
 
295
// SynEDA CoreMultiplier
296
// assignment(s): dcsb_stb_o
297
// replace(s): dc_en, dcfsm_biu_read, dcfsm_biu_write
298
assign dcsb_stb_o = (dc_en_cml_3) ? dcfsm_biu_read_cml_3 | dcfsm_biu_write_cml_3 : dcqmem_cycstb_i;
299
 
300
// SynEDA CoreMultiplier
301
// assignment(s): dcsb_we_o
302
// replace(s): dc_en, dcfsm_biu_write
303
assign dcsb_we_o = (dc_en_cml_3) ? dcfsm_biu_write_cml_3 : dcqmem_we_i;
304
 
305
// SynEDA CoreMultiplier
306
// assignment(s): dcsb_sel_o
307
// replace(s): dc_en, dcqmem_ci_i, dcfsm_biu_read, dcfsm_biu_write
308
assign dcsb_sel_o = (dc_en_cml_3 & dcfsm_biu_read_cml_3 & !dcfsm_biu_write_cml_3 & !dcqmem_ci_i_cml_3) ? 4'b1111 : dcqmem_sel_i;
309
 
310
// SynEDA CoreMultiplier
311
// assignment(s): dcsb_cab_o
312
// replace(s): dc_en
313
assign dcsb_cab_o = (dc_en_cml_3) ? dcfsm_burst : 1'b0;
314
 
315
// SynEDA CoreMultiplier
316
// assignment(s): dcqmem_rty_o
317
// replace(s): dcqmem_ack_o
318
assign dcqmem_rty_o = ~dcqmem_ack_o_cml_1;
319
assign dcqmem_tag_o = dcqmem_err_o ? `OR1200_DTAG_BE : dcqmem_tag_i;
320
 
321
//
322
// DC/LSU normal and error termination
323
//
324
assign dcqmem_ack_o = dc_en ? dcfsm_first_hit_ack | dcfsm_first_miss_ack : dcsb_ack_i;
325
 
326
// SynEDA CoreMultiplier
327
// assignment(s): dcqmem_err_o
328
// replace(s): dc_en
329
assign dcqmem_err_o = dc_en_cml_1 ? dcfsm_first_miss_err : dcsb_err_i;
330
 
331
//
332
// Select between claddr generated by DC FSM and addr[3:2] generated by LSU
333
//
334
//assign dc_addr = (dcfsm_biu_read | dcfsm_biu_write) ? saved_addr : dcqmem_adr_i;
335
 
336
//
337
// Select between input data generated by LSU or by BIU
338
//
339
 
340
// SynEDA CoreMultiplier
341
// assignment(s): to_dcram
342
// replace(s): dcsb_dat_i, dcfsm_biu_read
343
assign to_dcram = (dcfsm_biu_read_cml_3) ? dcsb_dat_i_cml_3 : dcqmem_dat_i;
344
 
345
//
346
// Select between data generated by DCRAM or passed by BIU
347
//
348
 
349
// SynEDA CoreMultiplier
350
// assignment(s): dcqmem_dat_o
351
// replace(s): dc_en, from_dcram, dcfsm_first_miss_ack
352
assign dcqmem_dat_o = dcfsm_first_miss_ack_cml_2 | !dc_en_cml_2 ? dcsb_dat_i : from_dcram_cml_2;
353
 
354
//
355
// Tag comparison
356
//
357
always @(tag or saved_addr or tag_v) begin
358
        if ((tag != saved_addr[31:`OR1200_DCTAGL]) || !tag_v)
359
                tagcomp_miss = 1'b1;
360
        else
361
                tagcomp_miss = 1'b0;
362
end
363
 
364
//
365
// Instantiation of DC Finite State Machine
366
//
367
or1200_dc_fsm_cm4 or1200_dc_fsm(
368
                .clk_i_cml_1(clk_i_cml_1),
369
                .clk_i_cml_2(clk_i_cml_2),
370
                .clk_i_cml_3(clk_i_cml_3),
371
        .clk(clk),
372
        .rst(rst),
373
        .dc_en(dc_en),
374
        .dcqmem_cycstb_i(dcqmem_cycstb_i),
375
        .dcqmem_ci_i(dcqmem_ci_i),
376
        .dcqmem_we_i(dcqmem_we_i),
377
        .dcqmem_sel_i(dcqmem_sel_i),
378
        .tagcomp_miss(tagcomp_miss),
379
        .biudata_valid(dcsb_ack_i),
380
        .biudata_error(dcsb_err_i),
381
        .start_addr(dcqmem_adr_i),
382
        .saved_addr(saved_addr),
383
        .dcram_we(dcram_we),
384
        .biu_read(dcfsm_biu_read),
385
        .biu_write(dcfsm_biu_write),
386
        .first_hit_ack(dcfsm_first_hit_ack),
387
        .first_miss_ack(dcfsm_first_miss_ack),
388
        .first_miss_err(dcfsm_first_miss_err),
389
        .burst(dcfsm_burst),
390
        .tag_we(dcfsm_tag_we),
391
        .dc_addr(dc_addr)
392
);
393
 
394
//
395
// Instantiation of DC main memory
396
//
397
or1200_dc_ram_cm4 or1200_dc_ram(
398
                .clk_i_cml_1(clk_i_cml_1),
399
                .clk_i_cml_2(clk_i_cml_2),
400
                .clk_i_cml_3(clk_i_cml_3),
401
                .cmls(cmls),
402
        .clk(clk),
403
        .rst(rst),
404
`ifdef OR1200_BIST
405
        // RAM BIST
406
        .mbist_si_i(mbist_ram_si),
407
        .mbist_so_o(mbist_ram_so),
408
        .mbist_ctrl_i(mbist_ctrl_i),
409
`endif
410
        .addr(dc_addr[`OR1200_DCINDXH:2]),
411
        .en(dc_en),
412
        .we(dcram_we),
413
        .datain(to_dcram),
414
        .dataout(from_dcram)
415
);
416
 
417
//
418
// Instantiation of DC TAG memory
419
//
420
wire [31:`OR1200_DCTAGL - 1] dc_tag_datain;
421
 
422
// SynEDA CoreMultiplier
423
// assignment(s): dc_tag_datain
424
// replace(s): dc_addr
425
assign dc_tag_datain = {dc_addr_cml_3[31:`OR1200_DCTAGL], dctag_v};
426
or1200_dc_tag_cm4 or1200_dc_tag(
427
                .clk_i_cml_1(clk_i_cml_1),
428
                .clk_i_cml_2(clk_i_cml_2),
429
                .clk_i_cml_3(clk_i_cml_3),
430
                .cmls(cmls),
431
        .clk(clk),
432
        .rst(rst),
433
`ifdef OR1200_BIST
434
        // RAM BIST
435
        .mbist_si_i(mbist_tag_si),
436
        .mbist_so_o(mbist_tag_so),
437
        .mbist_ctrl_i(mbist_ctrl_i),
438
`endif
439
        .addr(dctag_addr),
440
        .en(dctag_en),
441
        .we(dctag_we),
442
        .datain(dc_tag_datain),
443
        .tag_v(tag_v),
444
        .tag(tag)
445
);
446
 
447
 
448
always @ (posedge clk_i_cml_1) begin
449
dc_en_cml_1 <= dc_en;
450
dcqmem_ci_i_cml_1 <= dcqmem_ci_i;
451
dcqmem_ack_o_cml_1 <= dcqmem_ack_o;
452
spr_write_cml_1 <= spr_write;
453
spr_dat_i_cml_1 <= spr_dat_i;
454
dcfsm_first_miss_ack_cml_1 <= dcfsm_first_miss_ack;
455
end
456
always @ (posedge clk_i_cml_2) begin
457
dc_en_cml_2 <= dc_en_cml_1;
458
dcqmem_ci_i_cml_2 <= dcqmem_ci_i_cml_1;
459
spr_write_cml_2 <= spr_write_cml_1;
460
spr_dat_i_cml_2 <= spr_dat_i_cml_1;
461
from_dcram_cml_2 <= from_dcram;
462
dcfsm_first_miss_ack_cml_2 <= dcfsm_first_miss_ack_cml_1;
463
end
464
always @ (posedge clk_i_cml_3) begin
465
dcsb_dat_i_cml_3 <= dcsb_dat_i;
466
dc_en_cml_3 <= dc_en_cml_2;
467
dcqmem_ci_i_cml_3 <= dcqmem_ci_i_cml_2;
468
dc_addr_cml_3 <= dc_addr;
469
dcfsm_biu_read_cml_3 <= dcfsm_biu_read;
470
dcfsm_biu_write_cml_3 <= dcfsm_biu_write;
471
dc_inv_cml_3 <= dc_inv;
472
end
473
endmodule
474
 

powered by: WebSVN 2.1.0

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