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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_15/] [or1200/] [rtl/] [verilog/] [or1200_ic_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 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 1200 markom
// Revision 1.7  2002/10/17 20:04:40  lampret
48
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
49
//
50 1063 lampret
// Revision 1.6  2002/03/29 15:16:55  lampret
51
// Some of the warnings fixed.
52
//
53 788 lampret
// Revision 1.5  2002/02/11 04:33:17  lampret
54
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
55
//
56 660 lampret
// Revision 1.4  2002/02/01 19:56:54  lampret
57
// Fixed combinational loops.
58
//
59 636 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 ic.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_ic_top(
100
        // Rst, clk and clock control
101
        clk, rst,
102
 
103
        // External i/f
104
        icbiu_dat_o, icbiu_adr_o, icbiu_cyc_o, icbiu_stb_o, icbiu_we_o, icbiu_sel_o, icbiu_cab_o,
105
        icbiu_dat_i, icbiu_ack_i, icbiu_err_i,
106
 
107
        // Internal i/f
108
        ic_en,
109 660 lampret
        icimmu_adr_i, icimmu_cycstb_i, icimmu_ci_i,
110 788 lampret
        icpu_sel_i, icpu_tag_i,
111 617 lampret
        icpu_dat_o, icpu_ack_o, icimmu_rty_o, icimmu_err_o, icimmu_tag_o,
112 504 lampret
 
113 1063 lampret
`ifdef OR1200_BIST
114
        // RAM BIST
115 1200 markom
        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
output  [dw-1:0]         icbiu_dat_o;
138
output  [31:0]                   icbiu_adr_o;
139
output                          icbiu_cyc_o;
140
output                          icbiu_stb_o;
141
output                          icbiu_we_o;
142
output  [3:0]                    icbiu_sel_o;
143
output                          icbiu_cab_o;
144
input   [dw-1:0]         icbiu_dat_i;
145
input                           icbiu_ack_i;
146
input                           icbiu_err_i;
147
 
148
//
149
// Internal I/F
150
//
151
input                           ic_en;
152
input   [31:0]                   icimmu_adr_i;
153 660 lampret
input                           icimmu_cycstb_i;
154 504 lampret
input                           icimmu_ci_i;
155
input   [3:0]                    icpu_sel_i;
156
input   [3:0]                    icpu_tag_i;
157
output  [dw-1:0]         icpu_dat_o;
158
output                          icpu_ack_o;
159 617 lampret
output                          icimmu_rty_o;
160 504 lampret
output                          icimmu_err_o;
161
output  [3:0]                    icimmu_tag_o;
162
 
163 1063 lampret
`ifdef OR1200_BIST
164 504 lampret
//
165 1063 lampret
// RAM BIST
166
//
167 1200 markom
input                           mbist_si_i;
168
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;       // bist chain shift control
169
output                          mbist_so_o;
170 1063 lampret
`endif
171
 
172
//
173 504 lampret
// SPR access
174
//
175
input                           spr_cs;
176
input                           spr_write;
177
input   [31:0]                   spr_dat_i;
178
 
179
//
180
// Internal wires and regs
181
//
182
wire                            tag_v;
183
wire    [`OR1200_ICTAG_W-2:0]    tag;
184
wire    [dw-1:0]         to_icram;
185
wire    [dw-1:0]         from_icram;
186
wire    [31:0]                   saved_addr;
187
wire    [3:0]                    icram_we;
188
wire                            ictag_we;
189
wire    [31:0]                   ic_addr;
190
wire                            icfsm_biu_read;
191
reg                             tagcomp_miss;
192
wire    [`OR1200_ICINDXH:`OR1200_ICLS]  ictag_addr;
193
wire                            ictag_en;
194
wire                            ictag_v;
195
wire                            ic_inv;
196
wire                            icfsm_first_hit_ack;
197
wire                            icfsm_first_miss_ack;
198
wire                            icfsm_first_miss_err;
199
wire                            icfsm_burst;
200 660 lampret
wire                            icfsm_tag_we;
201 1063 lampret
`ifdef OR1200_BIST
202
//
203
// RAM BIST
204
//
205 1200 markom
wire                            mbist_ram_so;
206
wire                            mbist_tag_so;
207
wire                            mbist_ram_si = mbist_si_i;
208
wire                            mbist_tag_si = mbist_ram_so;
209
assign                          mbist_so_o = mbist_tag_so;
210 1063 lampret
`endif
211 504 lampret
 
212
//
213
// Simple assignments
214
//
215
assign icbiu_adr_o = ic_addr;
216
assign ic_inv = spr_cs & spr_write;
217 660 lampret
assign ictag_we = icfsm_tag_we | ic_inv;
218 504 lampret
assign ictag_addr = ic_inv ? spr_dat_i[`OR1200_ICINDXH:`OR1200_ICLS] : ic_addr[`OR1200_ICINDXH:`OR1200_ICLS];
219
assign ictag_en = ic_inv | ic_en;
220
assign ictag_v = ~ic_inv;
221
 
222
//
223
// Data to BIU is from ICRAM when IC is enabled or from LSU when
224
// IC is disabled
225
//
226
assign icbiu_dat_o = 32'h00000000;
227
 
228
//
229
// Bypases of the IC when IC is disabled
230
//
231 660 lampret
assign icbiu_cyc_o = (ic_en) ? icfsm_biu_read : icimmu_cycstb_i;
232
assign icbiu_stb_o = (ic_en) ? icfsm_biu_read : icimmu_cycstb_i;
233 504 lampret
assign icbiu_we_o = 1'b0;
234
assign icbiu_sel_o = (ic_en & icfsm_biu_read) ? 4'b1111 : icpu_sel_i;
235
assign icbiu_cab_o = (ic_en) ? icfsm_burst : 1'b0;
236 617 lampret
assign icimmu_rty_o = ~icpu_ack_o & ~icimmu_err_o;
237 562 lampret
assign icimmu_tag_o = icimmu_err_o ? `OR1200_ITAG_BE : icpu_tag_i;
238 504 lampret
 
239
//
240
// CPU normal and error termination
241
//
242 617 lampret
assign icpu_ack_o = ic_en ? (icfsm_first_hit_ack | icfsm_first_miss_ack) : icbiu_ack_i;
243 504 lampret
assign icimmu_err_o = ic_en ? icfsm_first_miss_err : icbiu_err_i;
244
 
245
//
246
// Select between claddr generated by IC FSM and addr[3:2] generated by LSU
247
//
248
assign ic_addr = (icfsm_biu_read) ? saved_addr : icimmu_adr_i;
249
 
250
//
251
// Select between input data generated by LSU or by BIU
252
//
253
assign to_icram = icbiu_dat_i;
254
 
255
//
256
// Select between data generated by ICRAM or passed by BIU
257
//
258
assign icpu_dat_o = icfsm_first_miss_ack | !ic_en ? icbiu_dat_i : from_icram;
259
 
260
//
261
// Tag comparison
262
//
263
always @(tag or saved_addr or tag_v) begin
264
        if ((tag != saved_addr[31:`OR1200_ICTAGL]) || !tag_v)
265
                tagcomp_miss = 1'b1;
266
        else
267
                tagcomp_miss = 1'b0;
268
end
269
 
270
//
271
// Instantiation of IC Finite State Machine
272
//
273
or1200_ic_fsm or1200_ic_fsm(
274
        .clk(clk),
275
        .rst(rst),
276
        .ic_en(ic_en),
277 660 lampret
        .icimmu_cycstb_i(icimmu_cycstb_i),
278 562 lampret
        .icimmu_ci_i(icimmu_ci_i),
279 504 lampret
        .tagcomp_miss(tagcomp_miss),
280
        .biudata_valid(icbiu_ack_i),
281
        .biudata_error(icbiu_err_i),
282
        .start_addr(icimmu_adr_i),
283
        .saved_addr(saved_addr),
284
        .icram_we(icram_we),
285
        .biu_read(icfsm_biu_read),
286
        .first_hit_ack(icfsm_first_hit_ack),
287
        .first_miss_ack(icfsm_first_miss_ack),
288
        .first_miss_err(icfsm_first_miss_err),
289 660 lampret
        .burst(icfsm_burst),
290
        .tag_we(icfsm_tag_we)
291 504 lampret
);
292
 
293
//
294
// Instantiation of IC main memory
295
//
296
or1200_ic_ram or1200_ic_ram(
297
        .clk(clk),
298
        .rst(rst),
299 1063 lampret
`ifdef OR1200_BIST
300
        // RAM BIST
301 1200 markom
        .mbist_si_i(mbist_ram_si),
302
        .mbist_so_o(mbist_ram_so),
303
        .mbist_ctrl_i(mbist_ctrl_i),
304 1063 lampret
`endif
305 504 lampret
        .addr(ic_addr[`OR1200_ICINDXH:2]),
306
        .en(ic_en),
307
        .we(icram_we),
308
        .datain(to_icram),
309
        .dataout(from_icram)
310
);
311
 
312
//
313
// Instantiation of IC TAG memory
314
//
315
or1200_ic_tag or1200_ic_tag(
316
        .clk(clk),
317
        .rst(rst),
318 1063 lampret
`ifdef OR1200_BIST
319
        // RAM BIST
320 1200 markom
        .mbist_si_i(mbist_tag_si),
321
        .mbist_so_o(mbist_tag_so),
322
        .mbist_ctrl_i(mbist_ctrl_i),
323 1063 lampret
`endif
324 504 lampret
        .addr(ictag_addr),
325
        .en(ictag_en),
326
        .we(ictag_we),
327
        .datain({ic_addr[31:`OR1200_ICTAGL], ictag_v}),
328
        .tag_v(tag_v),
329
        .tag(tag)
330
);
331
 
332
endmodule

powered by: WebSVN 2.1.0

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