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

Subversion Repositories or1200_hp

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

powered by: WebSVN 2.1.0

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