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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_ic_top.v] - Blame information for rev 1163

Go to most recent revision | 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 1063 lampret
// Revision 1.6  2002/03/29 15:16:55  lampret
48
// Some of the warnings fixed.
49
//
50 788 lampret
// Revision 1.5  2002/02/11 04:33:17  lampret
51
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
52
//
53 660 lampret
// Revision 1.4  2002/02/01 19:56:54  lampret
54
// Fixed combinational loops.
55
//
56 636 lampret
// Revision 1.3  2002/01/28 01:16:00  lampret
57
// 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.
58
//
59 617 lampret
// Revision 1.2  2002/01/14 06:18:22  lampret
60
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
61
//
62 562 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
63
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
64
//
65 504 lampret
// Revision 1.10  2001/10/21 17:57:16  lampret
66
// 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.
67
//
68
// Revision 1.9  2001/10/14 13:12:09  lampret
69
// MP3 version.
70
//
71
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
72
// no message
73
//
74
// Revision 1.4  2001/08/13 03:36:20  lampret
75
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
76
//
77
// Revision 1.3  2001/08/09 13:39:33  lampret
78
// Major clean-up.
79
//
80
// Revision 1.2  2001/07/22 03:31:53  lampret
81
// Fixed RAM's oen bug. Cache bypass under development.
82
//
83
// Revision 1.1  2001/07/20 00:46:03  lampret
84
// Development version of RTL. Libraries are missing.
85
//
86
//
87
 
88
// synopsys translate_off
89
`include "timescale.v"
90
// synopsys translate_on
91
`include "or1200_defines.v"
92
 
93
//
94
// Data cache
95
//
96
module or1200_ic_top(
97
        // Rst, clk and clock control
98
        clk, rst,
99
 
100
        // External i/f
101
        icbiu_dat_o, icbiu_adr_o, icbiu_cyc_o, icbiu_stb_o, icbiu_we_o, icbiu_sel_o, icbiu_cab_o,
102
        icbiu_dat_i, icbiu_ack_i, icbiu_err_i,
103
 
104
        // Internal i/f
105
        ic_en,
106 660 lampret
        icimmu_adr_i, icimmu_cycstb_i, icimmu_ci_i,
107 788 lampret
        icpu_sel_i, icpu_tag_i,
108 617 lampret
        icpu_dat_o, icpu_ack_o, icimmu_rty_o, icimmu_err_o, icimmu_tag_o,
109 504 lampret
 
110 1063 lampret
`ifdef OR1200_BIST
111
        // RAM BIST
112
        scanb_rst, scanb_si, scanb_so, scanb_en, scanb_clk,
113
`endif
114
 
115 504 lampret
        // SPRs
116
        spr_cs, spr_write, spr_dat_i
117
);
118
 
119
parameter dw = `OR1200_OPERAND_WIDTH;
120
 
121
//
122
// I/O
123
//
124
 
125
//
126
// Clock and reset
127
//
128
input                           clk;
129
input                           rst;
130
 
131
//
132
// External I/F
133
//
134
output  [dw-1:0]         icbiu_dat_o;
135
output  [31:0]                   icbiu_adr_o;
136
output                          icbiu_cyc_o;
137
output                          icbiu_stb_o;
138
output                          icbiu_we_o;
139
output  [3:0]                    icbiu_sel_o;
140
output                          icbiu_cab_o;
141
input   [dw-1:0]         icbiu_dat_i;
142
input                           icbiu_ack_i;
143
input                           icbiu_err_i;
144
 
145
//
146
// Internal I/F
147
//
148
input                           ic_en;
149
input   [31:0]                   icimmu_adr_i;
150 660 lampret
input                           icimmu_cycstb_i;
151 504 lampret
input                           icimmu_ci_i;
152
input   [3:0]                    icpu_sel_i;
153
input   [3:0]                    icpu_tag_i;
154
output  [dw-1:0]         icpu_dat_o;
155
output                          icpu_ack_o;
156 617 lampret
output                          icimmu_rty_o;
157 504 lampret
output                          icimmu_err_o;
158
output  [3:0]                    icimmu_tag_o;
159
 
160 1063 lampret
`ifdef OR1200_BIST
161 504 lampret
//
162 1063 lampret
// RAM BIST
163
//
164
input                           scanb_rst,
165
                                scanb_si,
166
                                scanb_en,
167
                                scanb_clk;
168
output                          scanb_so;
169
`endif
170
 
171
//
172 504 lampret
// SPR access
173
//
174
input                           spr_cs;
175
input                           spr_write;
176
input   [31:0]                   spr_dat_i;
177
 
178
//
179
// Internal wires and regs
180
//
181
wire                            tag_v;
182
wire    [`OR1200_ICTAG_W-2:0]    tag;
183
wire    [dw-1:0]         to_icram;
184
wire    [dw-1:0]         from_icram;
185
wire    [31:0]                   saved_addr;
186
wire    [3:0]                    icram_we;
187
wire                            ictag_we;
188
wire    [31:0]                   ic_addr;
189
wire                            icfsm_biu_read;
190
reg                             tagcomp_miss;
191
wire    [`OR1200_ICINDXH:`OR1200_ICLS]  ictag_addr;
192
wire                            ictag_en;
193
wire                            ictag_v;
194
wire                            ic_inv;
195
wire                            icfsm_first_hit_ack;
196
wire                            icfsm_first_miss_ack;
197
wire                            icfsm_first_miss_err;
198
wire                            icfsm_burst;
199 660 lampret
wire                            icfsm_tag_we;
200 1063 lampret
`ifdef OR1200_BIST
201
//
202
// RAM BIST
203
//
204
wire                            scanb_ram_so;
205
wire                            scanb_tag_so;
206
wire                            scanb_ram_si = scanb_si;
207
wire                            scanb_tag_si = scanb_ram_so;
208
assign                          scanb_so = scanb_tag_so;
209
`endif
210 504 lampret
 
211
//
212
// Simple assignments
213
//
214
assign icbiu_adr_o = ic_addr;
215
assign ic_inv = spr_cs & spr_write;
216 660 lampret
assign ictag_we = icfsm_tag_we | ic_inv;
217 504 lampret
assign ictag_addr = ic_inv ? spr_dat_i[`OR1200_ICINDXH:`OR1200_ICLS] : ic_addr[`OR1200_ICINDXH:`OR1200_ICLS];
218
assign ictag_en = ic_inv | ic_en;
219
assign ictag_v = ~ic_inv;
220
 
221
//
222
// Data to BIU is from ICRAM when IC is enabled or from LSU when
223
// IC is disabled
224
//
225
assign icbiu_dat_o = 32'h00000000;
226
 
227
//
228
// Bypases of the IC when IC is disabled
229
//
230 660 lampret
assign icbiu_cyc_o = (ic_en) ? icfsm_biu_read : icimmu_cycstb_i;
231
assign icbiu_stb_o = (ic_en) ? icfsm_biu_read : icimmu_cycstb_i;
232 504 lampret
assign icbiu_we_o = 1'b0;
233
assign icbiu_sel_o = (ic_en & icfsm_biu_read) ? 4'b1111 : icpu_sel_i;
234
assign icbiu_cab_o = (ic_en) ? icfsm_burst : 1'b0;
235 617 lampret
assign icimmu_rty_o = ~icpu_ack_o & ~icimmu_err_o;
236 562 lampret
assign icimmu_tag_o = icimmu_err_o ? `OR1200_ITAG_BE : icpu_tag_i;
237 504 lampret
 
238
//
239
// CPU normal and error termination
240
//
241 617 lampret
assign icpu_ack_o = ic_en ? (icfsm_first_hit_ack | icfsm_first_miss_ack) : icbiu_ack_i;
242 504 lampret
assign icimmu_err_o = ic_en ? icfsm_first_miss_err : icbiu_err_i;
243
 
244
//
245
// Select between claddr generated by IC FSM and addr[3:2] generated by LSU
246
//
247
assign ic_addr = (icfsm_biu_read) ? saved_addr : icimmu_adr_i;
248
 
249
//
250
// Select between input data generated by LSU or by BIU
251
//
252
assign to_icram = icbiu_dat_i;
253
 
254
//
255
// Select between data generated by ICRAM or passed by BIU
256
//
257
assign icpu_dat_o = icfsm_first_miss_ack | !ic_en ? icbiu_dat_i : from_icram;
258
 
259
//
260
// Tag comparison
261
//
262
always @(tag or saved_addr or tag_v) begin
263
        if ((tag != saved_addr[31:`OR1200_ICTAGL]) || !tag_v)
264
                tagcomp_miss = 1'b1;
265
        else
266
                tagcomp_miss = 1'b0;
267
end
268
 
269
//
270
// Instantiation of IC Finite State Machine
271
//
272
or1200_ic_fsm or1200_ic_fsm(
273
        .clk(clk),
274
        .rst(rst),
275
        .ic_en(ic_en),
276 660 lampret
        .icimmu_cycstb_i(icimmu_cycstb_i),
277 562 lampret
        .icimmu_ci_i(icimmu_ci_i),
278 504 lampret
        .tagcomp_miss(tagcomp_miss),
279
        .biudata_valid(icbiu_ack_i),
280
        .biudata_error(icbiu_err_i),
281
        .start_addr(icimmu_adr_i),
282
        .saved_addr(saved_addr),
283
        .icram_we(icram_we),
284
        .biu_read(icfsm_biu_read),
285
        .first_hit_ack(icfsm_first_hit_ack),
286
        .first_miss_ack(icfsm_first_miss_ack),
287
        .first_miss_err(icfsm_first_miss_err),
288 660 lampret
        .burst(icfsm_burst),
289
        .tag_we(icfsm_tag_we)
290 504 lampret
);
291
 
292
//
293
// Instantiation of IC main memory
294
//
295
or1200_ic_ram or1200_ic_ram(
296
        .clk(clk),
297
        .rst(rst),
298 1063 lampret
`ifdef OR1200_BIST
299
        // RAM BIST
300
        .scanb_rst(scanb_rst),
301
        .scanb_si(scanb_ram_si),
302
        .scanb_so(scanb_ram_so),
303
        .scanb_en(scanb_en),
304
        .scanb_clk(scanb_clk),
305
`endif
306 504 lampret
        .addr(ic_addr[`OR1200_ICINDXH:2]),
307
        .en(ic_en),
308
        .we(icram_we),
309
        .datain(to_icram),
310
        .dataout(from_icram)
311
);
312
 
313
//
314
// Instantiation of IC TAG memory
315
//
316
or1200_ic_tag or1200_ic_tag(
317
        .clk(clk),
318
        .rst(rst),
319 1063 lampret
`ifdef OR1200_BIST
320
        // RAM BIST
321
        .scanb_rst(scanb_rst),
322
        .scanb_si(scanb_tag_si),
323
        .scanb_so(scanb_tag_so),
324
        .scanb_en(scanb_en),
325
        .scanb_clk(scanb_clk),
326
`endif
327 504 lampret
        .addr(ictag_addr),
328
        .en(ictag_en),
329
        .we(ictag_we),
330
        .datain({ic_addr[31:`OR1200_ICTAGL], ictag_v}),
331
        .tag_v(tag_v),
332
        .tag(tag)
333
);
334
 
335
endmodule

powered by: WebSVN 2.1.0

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