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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [or1200/] [or1200_ic_top.v] - Blame information for rev 483

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 350 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3 415 julius
////  OR1200's Instruction Cache top level                        ////
4 350 julius
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://opencores.org/project,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
// $Log: or1200_ic_top.v,v $
45
// Revision 2.0  2010/06/30 11:00:00  ORSoC
46
// No update 
47
 
48
// synopsys translate_off
49
`include "timescale.v"
50
// synopsys translate_on
51
`include "or1200_defines.v"
52
 
53
//
54 415 julius
// Instruction cache top
55 350 julius
//
56
module or1200_ic_top(
57
        // Rst, clk and clock control
58
        clk, rst,
59
 
60
        // External i/f
61 415 julius
        icbiu_dat_o, icbiu_adr_o, icbiu_cyc_o, icbiu_stb_o, icbiu_we_o,
62
        icbiu_sel_o, icbiu_cab_o, icbiu_dat_i, icbiu_ack_i, icbiu_err_i,
63 350 julius
 
64
        // Internal i/f
65
        ic_en,
66 415 julius
        icqmem_adr_i, icqmem_cycstb_i, icqmem_ci_i, icqmem_sel_i, icqmem_tag_i,
67 350 julius
        icqmem_dat_o, icqmem_ack_o, icqmem_rty_o, icqmem_err_o, icqmem_tag_o,
68
 
69
`ifdef OR1200_BIST
70
        // RAM BIST
71
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
72
`endif
73
 
74 483 julius
`ifdef OR1200_RAM_PARITY
75
        // Parity error indicator
76
        p_err,
77
`endif
78
 
79 350 julius
        // SPRs
80
        spr_cs, spr_write, spr_dat_i
81
);
82
 
83
parameter dw = `OR1200_OPERAND_WIDTH;
84
 
85
//
86
// I/O
87
//
88
 
89
//
90
// Clock and reset
91
//
92
input                           clk;
93
input                           rst;
94
 
95
//
96
// External I/F
97
//
98
output  [dw-1:0]         icbiu_dat_o;
99
output  [31:0]                   icbiu_adr_o;
100
output                          icbiu_cyc_o;
101
output                          icbiu_stb_o;
102
output                          icbiu_we_o;
103
output  [3:0]                    icbiu_sel_o;
104
output                          icbiu_cab_o;
105
input   [dw-1:0]         icbiu_dat_i;
106
input                           icbiu_ack_i;
107
input                           icbiu_err_i;
108
 
109
//
110
// Internal I/F
111
//
112
input                           ic_en;
113
input   [31:0]                   icqmem_adr_i;
114
input                           icqmem_cycstb_i;
115
input                           icqmem_ci_i;
116
input   [3:0]                    icqmem_sel_i;
117
input   [3:0]                    icqmem_tag_i;
118
output  [dw-1:0]         icqmem_dat_o;
119
output                          icqmem_ack_o;
120
output                          icqmem_rty_o;
121
output                          icqmem_err_o;
122
output  [3:0]                    icqmem_tag_o;
123
 
124
`ifdef OR1200_BIST
125
//
126
// RAM BIST
127
//
128
input mbist_si_i;
129
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
130
output mbist_so_o;
131
`endif
132
 
133 483 julius
`ifdef OR1200_RAM_PARITY
134
output [1:0]                     p_err;
135
`endif
136
 
137 350 julius
//
138
// SPR access
139
//
140
input                           spr_cs;
141
input                           spr_write;
142
input   [31:0]                   spr_dat_i;
143
 
144
//
145
// Internal wires and regs
146
//
147
wire                            tag_v;
148
wire    [`OR1200_ICTAG_W-2:0]    tag;
149
wire    [dw-1:0]         to_icram;
150
wire    [dw-1:0]         from_icram;
151
wire    [31:0]                   saved_addr;
152
wire    [3:0]                    icram_we;
153
wire                            ictag_we;
154
wire    [31:0]                   ic_addr;
155
wire                            icfsm_biu_read;
156 483 julius
 
157
//reg                           tagcomp_miss;
158
   wire                         tagcomp_miss;
159
 
160 350 julius
wire    [`OR1200_ICINDXH:`OR1200_ICLS]  ictag_addr;
161
wire                            ictag_en;
162
wire                            ictag_v;
163
wire                            ic_inv;
164
wire                            icfsm_first_hit_ack;
165
wire                            icfsm_first_miss_ack;
166
wire                            icfsm_first_miss_err;
167
wire                            icfsm_burst;
168
wire                            icfsm_tag_we;
169 415 julius
reg                             ic_inv_q;
170
 
171 350 julius
`ifdef OR1200_BIST
172
//
173
// RAM BIST
174
//
175
wire                            mbist_ram_so;
176
wire                            mbist_tag_so;
177
wire                            mbist_ram_si = mbist_si_i;
178
wire                            mbist_tag_si = mbist_ram_so;
179
assign                          mbist_so_o = mbist_tag_so;
180
`endif
181
 
182 483 julius
`ifdef OR1200_RAM_PARITY
183
wire [1:0]                       p_err_wire;
184
// Indicate an error if we're reading from the RAM (hit)
185
// Additionally, mask with tag_v as tag ram is properly cleared during
186
// init, whereas the instruction RAM is not.
187
assign p_err[0] = (icqmem_ack_o & (!icfsm_first_miss_ack | ic_en)) &
188
                  (tag_v & !p_err[1]) ? p_err_wire[0] : 0;
189
// Whenever there's a tag parity error and we have an instruction fetch
190
assign p_err[1] = (ictag_en & !ictag_we) ? p_err_wire[1] : 0;
191
 
192
`else
193
 
194
`endif
195
 
196 350 julius
//
197
// Simple assignments
198
//
199
assign icbiu_adr_o = ic_addr;
200
assign ic_inv = spr_cs & spr_write;
201
assign ictag_we = icfsm_tag_we | ic_inv;
202
assign ictag_addr = ic_inv ?
203
                    spr_dat_i[`OR1200_ICINDXH:`OR1200_ICLS] :
204
                    ic_addr[`OR1200_ICINDXH:`OR1200_ICLS];
205
assign ictag_en = ic_inv | ic_en;
206
assign ictag_v = ~ic_inv;
207
 
208
//
209
// Data to BIU is from ICRAM when IC is enabled or from LSU when
210
// IC is disabled
211
//
212
assign icbiu_dat_o = 32'h00000000;
213
 
214
//
215
// Bypases of the IC when IC is disabled
216
//
217
assign icbiu_cyc_o = (ic_en) ? icfsm_biu_read : icqmem_cycstb_i;
218
assign icbiu_stb_o = (ic_en) ? icfsm_biu_read : icqmem_cycstb_i;
219
assign icbiu_we_o = 1'b0;
220
assign icbiu_sel_o = (ic_en & icfsm_biu_read) ? 4'b1111 : icqmem_sel_i;
221
assign icbiu_cab_o = (ic_en) ? icfsm_burst : 1'b0;
222
assign icqmem_rty_o = ~icqmem_ack_o & ~icqmem_err_o;
223
assign icqmem_tag_o = icqmem_err_o ? `OR1200_ITAG_BE : icqmem_tag_i;
224
 
225
//
226
// CPU normal and error termination
227
//
228
assign icqmem_ack_o = ic_en ? (icfsm_first_hit_ack | icfsm_first_miss_ack) : icbiu_ack_i;
229
assign icqmem_err_o = ic_en ? icfsm_first_miss_err : icbiu_err_i;
230
 
231
//
232
// Select between claddr generated by IC FSM and addr[3:2] generated by LSU
233
//
234
assign ic_addr = (icfsm_biu_read) ? saved_addr : icqmem_adr_i;
235
 
236
//
237
// Select between input data generated by LSU or by BIU
238
//
239
assign to_icram = icbiu_dat_i;
240
 
241
//
242
// Select between data generated by ICRAM or passed by BIU
243
//
244
assign icqmem_dat_o = icfsm_first_miss_ack | !ic_en ? icbiu_dat_i : from_icram;
245
 
246
//
247 415 julius
// Detect falling edge of IC invalidate signal
248
// 
249
always @(posedge clk or `OR1200_RST_EVENT rst)
250
   if (rst==`OR1200_RST_VALUE)
251
     ic_inv_q <= 1'b0;
252
   else
253
     ic_inv_q <= ic_inv;
254
 
255
 
256
//
257 350 julius
// Tag comparison
258
//
259 415 julius
// During line invalidate, ensure it stays the same
260 483 julius
assign tagcomp_miss = ((tag != saved_addr[31:`OR1200_ICTAGL]) | !tag_v
261
`ifdef OR1200_RAM_PARITY
262
              | (|p_err_wire)
263
`endif
264
                          );
265
 
266 350 julius
//
267
// Instantiation of IC Finite State Machine
268
//
269
or1200_ic_fsm or1200_ic_fsm(
270
        .clk(clk),
271
        .rst(rst),
272
        .ic_en(ic_en),
273
        .icqmem_cycstb_i(icqmem_cycstb_i),
274
        .icqmem_ci_i(icqmem_ci_i),
275
        .tagcomp_miss(tagcomp_miss),
276
        .biudata_valid(icbiu_ack_i),
277
        .biudata_error(icbiu_err_i),
278
        .start_addr(icqmem_adr_i),
279
        .saved_addr(saved_addr),
280
        .icram_we(icram_we),
281
        .biu_read(icfsm_biu_read),
282
        .first_hit_ack(icfsm_first_hit_ack),
283
        .first_miss_ack(icfsm_first_miss_ack),
284
        .first_miss_err(icfsm_first_miss_err),
285
        .burst(icfsm_burst),
286
        .tag_we(icfsm_tag_we)
287
);
288
 
289
//
290
// Instantiation of IC main memory
291
//
292
or1200_ic_ram or1200_ic_ram(
293
        .clk(clk),
294
        .rst(rst),
295
`ifdef OR1200_BIST
296
        // RAM BIST
297
        .mbist_si_i(mbist_ram_si),
298
        .mbist_so_o(mbist_ram_so),
299
        .mbist_ctrl_i(mbist_ctrl_i),
300
`endif
301 483 julius
`ifdef OR1200_RAM_PARITY
302
        .p_err(p_err_wire[0]),
303
`endif
304 350 julius
        .addr(ic_addr[`OR1200_ICINDXH:2]),
305
        .en(ic_en),
306
        .we(icram_we),
307
        .datain(to_icram),
308
        .dataout(from_icram)
309
);
310
 
311
//
312
// Instantiation of IC TAG memory
313
//
314
or1200_ic_tag or1200_ic_tag(
315
        .clk(clk),
316
        .rst(rst),
317
`ifdef OR1200_BIST
318
        // RAM BIST
319
        .mbist_si_i(mbist_tag_si),
320
        .mbist_so_o(mbist_tag_so),
321
        .mbist_ctrl_i(mbist_ctrl_i),
322
`endif
323 483 julius
`ifdef OR1200_RAM_PARITY
324
        .p_err(p_err_wire[1]),
325
`endif
326 350 julius
        .addr(ictag_addr),
327
        .en(ictag_en),
328
        .we(ictag_we),
329
        .datain({ic_addr[31:`OR1200_ICTAGL], ictag_v}),
330
        .tag_v(tag_v),
331
        .tag(tag)
332
);
333
 
334
endmodule

powered by: WebSVN 2.1.0

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