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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm4/] [verilog/] [or1200_ic_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 IC 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.7.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.7.4.1  2003/07/08 15:36:37  lampret
51
// Added embedded memory QMEM.
52
//
53
// Revision 1.7  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.6  2002/03/29 15:16:55  lampret
57
// Some of the warnings fixed.
58
//
59
// Revision 1.5  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.4  2002/02/01 19:56:54  lampret
63
// Fixed combinational loops.
64
//
65
// Revision 1.3  2002/01/28 01:16:00  lampret
66
// 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.
67
//
68
// Revision 1.2  2002/01/14 06:18:22  lampret
69
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
70
//
71
// Revision 1.1  2002/01/03 08:16:15  lampret
72
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
73
//
74
// Revision 1.10  2001/10/21 17:57:16  lampret
75
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from ic.v and ic.v. Fixed CR+LF.
76
//
77
// Revision 1.9  2001/10/14 13:12:09  lampret
78
// MP3 version.
79
//
80
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
81
// no message
82
//
83
// Revision 1.4  2001/08/13 03:36:20  lampret
84
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
85
//
86
// Revision 1.3  2001/08/09 13:39:33  lampret
87
// Major clean-up.
88
//
89
// Revision 1.2  2001/07/22 03:31:53  lampret
90
// Fixed RAM's oen bug. Cache bypass under development.
91
//
92
// Revision 1.1  2001/07/20 00:46:03  lampret
93
// Development version of RTL. Libraries are missing.
94
//
95
//
96
 
97
// synopsys translate_off
98
`include "timescale.v"
99
// synopsys translate_on
100
`include "or1200_defines.v"
101
 
102
//
103
// Data cache
104
//
105
module or1200_ic_top_cm4(
106
                clk_i_cml_1,
107
                clk_i_cml_2,
108
                clk_i_cml_3,
109
                cmls,
110
 
111
        // Rst, clk and clock control
112
        clk, rst,
113
 
114
        // External i/f
115
        icbiu_dat_o, icbiu_adr_o, icbiu_cyc_o, icbiu_stb_o, icbiu_we_o, icbiu_sel_o, icbiu_cab_o,
116
        icbiu_dat_i, icbiu_ack_i, icbiu_err_i,
117
 
118
        // Internal i/f
119
        ic_en,
120
        icqmem_adr_i, icqmem_cycstb_i, icqmem_ci_i,
121
        icqmem_sel_i, icqmem_tag_i,
122
        icqmem_dat_o, icqmem_ack_o, icqmem_rty_o, icqmem_err_o, icqmem_tag_o,
123
 
124
`ifdef OR1200_BIST
125
        // RAM BIST
126
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
127
`endif
128
 
129
        // SPRs
130
        spr_cs, spr_write, spr_dat_i
131
);
132
 
133
 
134
input clk_i_cml_1;
135
input clk_i_cml_2;
136
input clk_i_cml_3;
137
input [1:0] cmls;
138
reg  icbiu_ack_i_cml_1;
139
reg  ic_en_cml_3;
140
reg  ic_en_cml_2;
141
reg  ic_en_cml_1;
142
reg  icqmem_err_o_cml_3;
143
reg  icqmem_err_o_cml_2;
144
reg  icqmem_err_o_cml_1;
145
reg  spr_write_cml_3;
146
reg  spr_write_cml_2;
147
reg  spr_write_cml_1;
148
reg [ 31 : 0 ] spr_dat_i_cml_3;
149
reg [ 31 : 0 ] spr_dat_i_cml_2;
150
reg [ 31 : 0 ] spr_dat_i_cml_1;
151
reg  tag_v_cml_1;
152
reg [ 32 - 1 : 0 ] from_icram_cml_3;
153
reg [ 32 - 1 : 0 ] from_icram_cml_2;
154
reg [ 32 - 1 : 0 ] from_icram_cml_1;
155
reg [ 31 : 0 ] saved_addr_cml_3;
156
reg [ 31 : 0 ] saved_addr_cml_2;
157
reg [ 31 : 0 ] saved_addr_cml_1;
158
reg  icfsm_biu_read_cml_3;
159
reg  icfsm_first_miss_ack_cml_3;
160
reg  icfsm_first_miss_ack_cml_2;
161
reg  icfsm_first_miss_ack_cml_1;
162
reg  tag_comp_3_cml_1;
163
reg  tag_comp_2_cml_1;
164
reg  tag_comp_1_cml_1;
165
reg  tag_comp_0_cml_1;
166
 
167
 
168
 
169
parameter dw = `OR1200_OPERAND_WIDTH;
170
 
171
//
172
// I/O
173
//
174
 
175
//
176
// Clock and reset
177
//
178
input                           clk;
179
input                           rst;
180
 
181
//
182
// External I/F
183
//
184
output  [dw-1:0]         icbiu_dat_o;
185
output  [31:0]                   icbiu_adr_o;
186
output                          icbiu_cyc_o;
187
output                          icbiu_stb_o;
188
output                          icbiu_we_o;
189
output  [3:0]                    icbiu_sel_o;
190
output                          icbiu_cab_o;
191
input   [dw-1:0]         icbiu_dat_i;
192
input                           icbiu_ack_i;
193
input                           icbiu_err_i;
194
 
195
//
196
// Internal I/F
197
//
198
input                           ic_en;
199
input   [31:0]                   icqmem_adr_i;
200
input                           icqmem_cycstb_i;
201
input                           icqmem_ci_i;
202
input   [3:0]                    icqmem_sel_i;
203
input   [3:0]                    icqmem_tag_i;
204
output  [dw-1:0]         icqmem_dat_o;
205
output                          icqmem_ack_o;
206
output                          icqmem_rty_o;
207
output                          icqmem_err_o;
208
output  [3:0]                    icqmem_tag_o;
209
 
210
`ifdef OR1200_BIST
211
//
212
// RAM BIST
213
//
214
input mbist_si_i;
215
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
216
output mbist_so_o;
217
`endif
218
 
219
//
220
// SPR access
221
//
222
input                           spr_cs;
223
input                           spr_write;
224
input   [31:0]                   spr_dat_i;
225
 
226
//
227
// Internal wires and regs
228
//
229
wire                            tag_v;
230
wire    [`OR1200_ICTAG_W-2:0]    tag;
231
wire    [dw-1:0]         to_icram;
232
wire    [dw-1:0]         from_icram;
233
wire    [31:0]                   saved_addr;
234
wire    [3:0]                    icram_we;
235
wire                            ictag_we;
236
wire    [31:0]                   ic_addr;
237
wire                            icfsm_biu_read;
238
reg                             tagcomp_miss;
239
wire    [`OR1200_ICINDXH:`OR1200_ICLS]  ictag_addr;
240
wire                            ictag_en;
241
wire                            ictag_v;
242
wire                            ic_inv;
243
wire                            icfsm_first_hit_ack;
244
wire                            icfsm_first_miss_ack;
245
wire                            icfsm_first_miss_err;
246
wire                            icfsm_burst;
247
wire                            icfsm_tag_we;
248
`ifdef OR1200_BIST
249
//
250
// RAM BIST
251
//
252
wire                            mbist_ram_so;
253
wire                            mbist_tag_so;
254
wire                            mbist_ram_si = mbist_si_i;
255
wire                            mbist_tag_si = mbist_ram_so;
256
assign                          mbist_so_o = mbist_tag_so;
257
`endif
258
 
259
//
260
// Simple assignments
261
//
262
assign icbiu_adr_o = ic_addr;
263
 
264
// SynEDA CoreMultiplier
265
// assignment(s): ic_inv
266
// replace(s): spr_write
267
assign ic_inv = spr_cs & spr_write_cml_3;
268
assign ictag_we = icfsm_tag_we | ic_inv;
269
 
270
// SynEDA CoreMultiplier
271
// assignment(s): ictag_addr
272
// replace(s): spr_dat_i
273
assign ictag_addr = ic_inv ? spr_dat_i_cml_3[`OR1200_ICINDXH:`OR1200_ICLS] : ic_addr[`OR1200_ICINDXH:`OR1200_ICLS];
274
 
275
// SynEDA CoreMultiplier
276
// assignment(s): ictag_en
277
// replace(s): ic_en
278
assign ictag_en = ic_inv | ic_en_cml_3;
279
assign ictag_v = ~ic_inv;
280
 
281
//
282
// Data to BIU is from ICRAM when IC is enabled or from LSU when
283
// IC is disabled
284
//
285
assign icbiu_dat_o = 32'h00000000;
286
 
287
//
288
// Bypases of the IC when IC is disabled
289
//
290
 
291
// SynEDA CoreMultiplier
292
// assignment(s): icbiu_cyc_o
293
// replace(s): ic_en, icfsm_biu_read
294
assign icbiu_cyc_o = (ic_en_cml_3) ? icfsm_biu_read_cml_3 : icqmem_cycstb_i;
295
 
296
// SynEDA CoreMultiplier
297
// assignment(s): icbiu_stb_o
298
// replace(s): ic_en, icfsm_biu_read
299
assign icbiu_stb_o = (ic_en_cml_3) ? icfsm_biu_read_cml_3 : icqmem_cycstb_i;
300
assign icbiu_we_o = 1'b0;
301
 
302
// SynEDA CoreMultiplier
303
// assignment(s): icbiu_sel_o
304
// replace(s): ic_en, icfsm_biu_read
305
assign icbiu_sel_o = (ic_en_cml_3 & icfsm_biu_read_cml_3) ? 4'b1111 : icqmem_sel_i;
306
 
307
// SynEDA CoreMultiplier
308
// assignment(s): icbiu_cab_o
309
// replace(s): ic_en
310
assign icbiu_cab_o = (ic_en_cml_3) ? icfsm_burst : 1'b0;
311
 
312
// SynEDA CoreMultiplier
313
// assignment(s): icqmem_rty_o
314
// replace(s): icqmem_err_o
315
assign icqmem_rty_o = ~icqmem_ack_o & ~icqmem_err_o_cml_1;
316
 
317
// SynEDA CoreMultiplier
318
// assignment(s): icqmem_tag_o
319
// replace(s): icqmem_err_o
320
assign icqmem_tag_o = icqmem_err_o_cml_3 ? `OR1200_ITAG_BE : icqmem_tag_i;
321
 
322
//
323
// CPU normal and error termination
324
//
325
 
326
// SynEDA CoreMultiplier
327
// assignment(s): icqmem_ack_o
328
// replace(s): icbiu_ack_i, ic_en, icfsm_first_miss_ack
329
assign icqmem_ack_o = ic_en_cml_1 ? (icfsm_first_hit_ack | icfsm_first_miss_ack_cml_1) : icbiu_ack_i_cml_1;
330
assign icqmem_err_o = ic_en ? icfsm_first_miss_err : icbiu_err_i;
331
 
332
//
333
// Select between claddr generated by IC FSM and addr[3:2] generated by LSU
334
//
335
 
336
// SynEDA CoreMultiplier
337
// assignment(s): ic_addr
338
// replace(s): saved_addr, icfsm_biu_read
339
assign ic_addr = (icfsm_biu_read_cml_3) ? saved_addr_cml_3 : icqmem_adr_i;
340
 
341
//
342
// Select between input data generated by LSU or by BIU
343
//
344
assign to_icram = icbiu_dat_i;
345
 
346
//
347
// Select between data generated by ICRAM or passed by BIU
348
//
349
 
350
// SynEDA CoreMultiplier
351
// assignment(s): icqmem_dat_o
352
// replace(s): ic_en, from_icram, icfsm_first_miss_ack
353
assign icqmem_dat_o = icfsm_first_miss_ack_cml_3 | !ic_en_cml_3 ? icbiu_dat_i : from_icram_cml_3;
354
 
355
//
356
// Tag comparison
357
//
358
wire    tag_comp_3;
359
wire    tag_comp_2;
360
wire    tag_comp_1;
361
wire    tag_comp_0;
362
 
363
assign tag_comp_3 = (tag[`OR1200_ICTAG_W-2:15] != saved_addr[31:`OR1200_ICTAGL + 15]);
364
assign tag_comp_2 = (tag[14:10] != saved_addr[`OR1200_ICTAGL + 14:`OR1200_ICTAGL + 10]);
365
assign tag_comp_1 = (tag[9:5] != saved_addr[`OR1200_ICTAGL + 9:`OR1200_ICTAGL + 5]);
366
assign tag_comp_0 = (tag[4:0] != saved_addr[`OR1200_ICTAGL + 4: `OR1200_ICTAGL]);
367
 
368
 
369
// SynEDA CoreMultiplier
370
// assignment(s): tagcomp_miss
371
// replace(s): tag_v, tag_comp_3, tag_comp_2, tag_comp_1, tag_comp_0
372
always @(tag or saved_addr or tag_v_cml_1) begin
373
        //if ((tag != saved_addr[31:`OR1200_ICTAGL]) || !tag_v)
374
        if ((tag_comp_3_cml_1 | tag_comp_2_cml_1 | tag_comp_1_cml_1 | tag_comp_0_cml_1) || !tag_v_cml_1)
375
                tagcomp_miss = 1'b1;
376
        else
377
                tagcomp_miss = 1'b0;
378
end
379
 
380
//
381
// Instantiation of IC Finite State Machine
382
//
383
or1200_ic_fsm_cm4 or1200_ic_fsm(
384
                .clk_i_cml_1(clk_i_cml_1),
385
                .clk_i_cml_2(clk_i_cml_2),
386
                .clk_i_cml_3(clk_i_cml_3),
387
        .clk(clk),
388
        .rst(rst),
389
        .ic_en(ic_en),
390
        .icqmem_cycstb_i(icqmem_cycstb_i),
391
        .icqmem_ci_i(icqmem_ci_i),
392
        .tagcomp_miss(tagcomp_miss),
393
        .biudata_valid(icbiu_ack_i),
394
        .biudata_error(icbiu_err_i),
395
        .start_addr(icqmem_adr_i),
396
        .saved_addr(saved_addr),
397
        .icram_we(icram_we),
398
        .biu_read(icfsm_biu_read),
399
        .first_hit_ack(icfsm_first_hit_ack),
400
        .first_miss_ack(icfsm_first_miss_ack),
401
        .first_miss_err(icfsm_first_miss_err),
402
        .burst(icfsm_burst),
403
        .tag_we(icfsm_tag_we)
404
);
405
 
406
//
407
// Instantiation of IC main memory
408
//
409
wire [`OR1200_ICINDXH:2] addr_ic_ram;
410
assign addr_ic_ram = ic_addr[`OR1200_ICINDXH:2];
411
or1200_ic_ram_cm4 or1200_ic_ram(
412
                .clk_i_cml_1(clk_i_cml_1),
413
                .clk_i_cml_2(clk_i_cml_2),
414
                .clk_i_cml_3(clk_i_cml_3),
415
                .cmls(cmls),
416
        .clk(clk),
417
        .rst(rst),
418
`ifdef OR1200_BIST
419
        // RAM BIST
420
        .mbist_si_i(mbist_ram_si),
421
        .mbist_so_o(mbist_ram_so),
422
        .mbist_ctrl_i(mbist_ctrl_i),
423
`endif
424
        .addr(addr_ic_ram),
425
        .en(ic_en),
426
        .we(icram_we),
427
        .datain(to_icram),
428
        .dataout(from_icram)
429
);
430
 
431
//
432
// Instantiation of IC TAG memory
433
//
434
wire [31:`OR1200_ICTAGL - 1] ic_tag_datain;
435
assign ic_tag_datain = {ic_addr[31:`OR1200_ICTAGL], ictag_v};
436
or1200_ic_tag_cm4 or1200_ic_tag(
437
                .clk_i_cml_1(clk_i_cml_1),
438
                .clk_i_cml_2(clk_i_cml_2),
439
                .clk_i_cml_3(clk_i_cml_3),
440
                .cmls(cmls),
441
        .clk(clk),
442
        .rst(rst),
443
`ifdef OR1200_BIST
444
        // RAM BIST
445
        .mbist_si_i(mbist_tag_si),
446
        .mbist_so_o(mbist_tag_so),
447
        .mbist_ctrl_i(mbist_ctrl_i),
448
`endif
449
        .addr(ictag_addr),
450
        .en(ictag_en),
451
        .we(ictag_we),
452
        .datain(ic_tag_datain),
453
        .tag_v(tag_v),
454
        .tag(tag)
455
);
456
 
457
 
458
always @ (posedge clk_i_cml_1) begin
459
icbiu_ack_i_cml_1 <= icbiu_ack_i;
460
ic_en_cml_1 <= ic_en;
461
icqmem_err_o_cml_1 <= icqmem_err_o;
462
spr_write_cml_1 <= spr_write;
463
spr_dat_i_cml_1 <= spr_dat_i;
464
tag_v_cml_1 <= tag_v;
465
from_icram_cml_1 <= from_icram;
466
saved_addr_cml_1 <= saved_addr;
467
icfsm_first_miss_ack_cml_1 <= icfsm_first_miss_ack;
468
tag_comp_3_cml_1 <= tag_comp_3;
469
tag_comp_2_cml_1 <= tag_comp_2;
470
tag_comp_1_cml_1 <= tag_comp_1;
471
tag_comp_0_cml_1 <= tag_comp_0;
472
end
473
always @ (posedge clk_i_cml_2) begin
474
ic_en_cml_2 <= ic_en_cml_1;
475
icqmem_err_o_cml_2 <= icqmem_err_o_cml_1;
476
spr_write_cml_2 <= spr_write_cml_1;
477
spr_dat_i_cml_2 <= spr_dat_i_cml_1;
478
from_icram_cml_2 <= from_icram_cml_1;
479
saved_addr_cml_2 <= saved_addr_cml_1;
480
icfsm_first_miss_ack_cml_2 <= icfsm_first_miss_ack_cml_1;
481
end
482
always @ (posedge clk_i_cml_3) begin
483
ic_en_cml_3 <= ic_en_cml_2;
484
icqmem_err_o_cml_3 <= icqmem_err_o_cml_2;
485
spr_write_cml_3 <= spr_write_cml_2;
486
spr_dat_i_cml_3 <= spr_dat_i_cml_2;
487
from_icram_cml_3 <= from_icram_cml_2;
488
saved_addr_cml_3 <= saved_addr_cml_2;
489
icfsm_biu_read_cml_3 <= icfsm_biu_read;
490
icfsm_first_miss_ack_cml_3 <= icfsm_first_miss_ack_cml_2;
491
end
492
endmodule
493
 

powered by: WebSVN 2.1.0

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