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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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