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 504

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
// Revision 1.10  2001/10/21 17:57:16  lampret
48
// 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.
49
//
50
// Revision 1.9  2001/10/14 13:12:09  lampret
51
// MP3 version.
52
//
53
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
54
// no message
55
//
56
// Revision 1.4  2001/08/13 03:36:20  lampret
57
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
58
//
59
// Revision 1.3  2001/08/09 13:39:33  lampret
60
// Major clean-up.
61
//
62
// Revision 1.2  2001/07/22 03:31:53  lampret
63
// Fixed RAM's oen bug. Cache bypass under development.
64
//
65
// Revision 1.1  2001/07/20 00:46:03  lampret
66
// Development version of RTL. Libraries are missing.
67
//
68
//
69
 
70
// synopsys translate_off
71
`include "timescale.v"
72
// synopsys translate_on
73
`include "or1200_defines.v"
74
 
75
//
76
// Data cache
77
//
78
module or1200_ic_top(
79
        // Rst, clk and clock control
80
        clk, rst,
81
 
82
        // External i/f
83
        icbiu_dat_o, icbiu_adr_o, icbiu_cyc_o, icbiu_stb_o, icbiu_we_o, icbiu_sel_o, icbiu_cab_o,
84
        icbiu_dat_i, icbiu_ack_i, icbiu_err_i,
85
 
86
        // Internal i/f
87
        ic_en,
88
        icimmu_adr_i, icimmu_cyc_i, icimmu_stb_i, icimmu_ci_i,
89
        icpu_we_i, icpu_sel_i, icpu_tag_i,
90
        icpu_dat_o, icpu_ack_o, icpu_rty_o, icimmu_err_o, icimmu_tag_o,
91
 
92
        // SPRs
93
        spr_cs, spr_write, spr_dat_i
94
);
95
 
96
parameter dw = `OR1200_OPERAND_WIDTH;
97
 
98
//
99
// I/O
100
//
101
 
102
//
103
// Clock and reset
104
//
105
input                           clk;
106
input                           rst;
107
 
108
//
109
// External I/F
110
//
111
output  [dw-1:0]         icbiu_dat_o;
112
output  [31:0]                   icbiu_adr_o;
113
output                          icbiu_cyc_o;
114
output                          icbiu_stb_o;
115
output                          icbiu_we_o;
116
output  [3:0]                    icbiu_sel_o;
117
output                          icbiu_cab_o;
118
input   [dw-1:0]         icbiu_dat_i;
119
input                           icbiu_ack_i;
120
input                           icbiu_err_i;
121
 
122
//
123
// Internal I/F
124
//
125
input                           ic_en;
126
input   [31:0]                   icimmu_adr_i;
127
input                           icimmu_cyc_i;
128
input                           icimmu_stb_i;
129
input                           icimmu_ci_i;
130
input                           icpu_we_i;
131
input   [3:0]                    icpu_sel_i;
132
input   [3:0]                    icpu_tag_i;
133
output  [dw-1:0]         icpu_dat_o;
134
output                          icpu_ack_o;
135
output                          icpu_rty_o;
136
output                          icimmu_err_o;
137
output  [3:0]                    icimmu_tag_o;
138
 
139
//
140
// SPR access
141
//
142
input                           spr_cs;
143
input                           spr_write;
144
input   [31:0]                   spr_dat_i;
145
 
146
//
147
// Internal wires and regs
148
//
149
wire                            tag_v;
150
wire    [`OR1200_ICTAG_W-2:0]    tag;
151
wire    [dw-1:0]         to_icram;
152
wire    [dw-1:0]         from_icram;
153
wire    [31:0]                   saved_addr;
154
wire    [3:0]                    icram_we;
155
wire                            ictag_we;
156
wire    [31:0]                   ic_addr;
157
wire                            icfsm_biu_read;
158
reg                             tagcomp_miss;
159
wire    [`OR1200_ICINDXH:`OR1200_ICLS]  ictag_addr;
160
wire                            ictag_en;
161
wire                            ictag_v;
162
wire                            ic_inv;
163
wire                            icfsm_first_hit_ack;
164
wire                            icfsm_first_miss_ack;
165
wire                            icfsm_first_miss_err;
166
wire                            icfsm_burst;
167
 
168
//
169
// Simple assignments
170
//
171
assign icbiu_adr_o = ic_addr;
172
assign ic_inv = spr_cs & spr_write;
173
assign ictag_we = (icfsm_biu_read & icbiu_ack_i) | ic_inv;
174
assign ictag_addr = ic_inv ? spr_dat_i[`OR1200_ICINDXH:`OR1200_ICLS] : ic_addr[`OR1200_ICINDXH:`OR1200_ICLS];
175
assign ictag_en = ic_inv | ic_en;
176
assign ictag_v = ~ic_inv;
177
 
178
//
179
// Data to BIU is from ICRAM when IC is enabled or from LSU when
180
// IC is disabled
181
//
182
assign icbiu_dat_o = 32'h00000000;
183
 
184
//
185
// Bypases of the IC when IC is disabled
186
//
187
assign icbiu_cyc_o = (ic_en) ? icfsm_biu_read : icimmu_cyc_i;
188
assign icbiu_stb_o = (ic_en) ? icfsm_biu_read : icimmu_stb_i;
189
assign icbiu_we_o = 1'b0;
190
assign icbiu_sel_o = (ic_en & icfsm_biu_read) ? 4'b1111 : icpu_sel_i;
191
assign icbiu_cab_o = (ic_en) ? icfsm_burst : 1'b0;
192
assign icpu_rty_o = ~icpu_ack_o;
193
assign icimmu_tag_o = icpu_tag_i;
194
 
195
//
196
// CPU normal and error termination
197
//
198
assign icpu_ack_o = ic_en ? icfsm_first_hit_ack | icfsm_first_miss_ack : icbiu_ack_i;
199
assign icimmu_err_o = ic_en ? icfsm_first_miss_err : icbiu_err_i;
200
 
201
//
202
// Select between claddr generated by IC FSM and addr[3:2] generated by LSU
203
//
204
assign ic_addr = (icfsm_biu_read) ? saved_addr : icimmu_adr_i;
205
 
206
//
207
// Select between input data generated by LSU or by BIU
208
//
209
assign to_icram = icbiu_dat_i;
210
 
211
//
212
// Select between data generated by ICRAM or passed by BIU
213
//
214
assign icpu_dat_o = icfsm_first_miss_ack | !ic_en ? icbiu_dat_i : from_icram;
215
 
216
//
217
// Tag comparison
218
//
219
always @(tag or saved_addr or tag_v) begin
220
        if ((tag != saved_addr[31:`OR1200_ICTAGL]) || !tag_v)
221
                tagcomp_miss = 1'b1;
222
        else
223
                tagcomp_miss = 1'b0;
224
end
225
 
226
//
227
// Instantiation of IC Finite State Machine
228
//
229
or1200_ic_fsm or1200_ic_fsm(
230
        .clk(clk),
231
        .rst(rst),
232
        .ic_en(ic_en),
233
        .icimmu_cyc_i(icimmu_cyc_i),
234
        .icimmu_stb_i(icimmu_stb_i),
235
//      .icimmu_ci_i(icimmu_ci_i),
236
        .icimmu_ci_i(1'b0),
237
        .icpu_sel_i(icpu_sel_i),
238
        .tagcomp_miss(tagcomp_miss),
239
        .biudata_valid(icbiu_ack_i),
240
        .biudata_error(icbiu_err_i),
241
        .start_addr(icimmu_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
);
250
 
251
//
252
// Instantiation of IC main memory
253
//
254
or1200_ic_ram or1200_ic_ram(
255
        .clk(clk),
256
        .rst(rst),
257
        .addr(ic_addr[`OR1200_ICINDXH:2]),
258
        .en(ic_en),
259
        .we(icram_we),
260
        .datain(to_icram),
261
        .dataout(from_icram)
262
);
263
 
264
//
265
// Instantiation of IC TAG memory
266
//
267
or1200_ic_tag or1200_ic_tag(
268
        .clk(clk),
269
        .rst(rst),
270
        .addr(ictag_addr),
271
        .en(ictag_en),
272
        .we(ictag_we),
273
        .datain({ic_addr[31:`OR1200_ICTAGL], ictag_v}),
274
        .tag_v(tag_v),
275
        .tag(tag)
276
);
277
 
278
endmodule

powered by: WebSVN 2.1.0

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