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

Subversion Repositories openrisc_me

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

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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