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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_dc_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 DC 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.5  2002/08/18 19:54:47  lampret
48
// Added store buffer.
49
//
50 977 lampret
// Revision 1.4  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.3  2002/01/28 01:16:00  lampret
54
// 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.
55
//
56 617 lampret
// Revision 1.2  2002/01/14 06:18:22  lampret
57
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
58
//
59 562 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
60
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
61
//
62 504 lampret
// Revision 1.10  2001/10/21 17:57:16  lampret
63
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
64
//
65
// Revision 1.9  2001/10/14 13:12:09  lampret
66
// MP3 version.
67
//
68
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
69
// no message
70
//
71
// Revision 1.4  2001/08/13 03:36:20  lampret
72
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
73
//
74
// Revision 1.3  2001/08/09 13:39:33  lampret
75
// Major clean-up.
76
//
77
// Revision 1.2  2001/07/22 03:31:53  lampret
78
// Fixed RAM's oen bug. Cache bypass under development.
79
//
80
// Revision 1.1  2001/07/20 00:46:03  lampret
81
// Development version of RTL. Libraries are missing.
82
//
83
//
84
 
85
// synopsys translate_off
86
`include "timescale.v"
87
// synopsys translate_on
88
`include "or1200_defines.v"
89
 
90
//
91
// Data cache
92
//
93
module or1200_dc_top(
94
        // Rst, clk and clock control
95
        clk, rst,
96
 
97
        // External i/f
98 977 lampret
        dcsb_dat_o, dcsb_adr_o, dcsb_cyc_o, dcsb_stb_o, dcsb_we_o, dcsb_sel_o, dcsb_cab_o,
99
        dcsb_dat_i, dcsb_ack_i, dcsb_err_i,
100 504 lampret
 
101
        // Internal i/f
102
        dc_en,
103 660 lampret
        dcdmmu_adr_i, dcdmmu_cycstb_i, dcdmmu_ci_i,
104 504 lampret
        dcpu_we_i, dcpu_sel_i, dcpu_tag_i, dcpu_dat_i,
105
        dcpu_dat_o, dcpu_ack_o, dcpu_rty_o, dcdmmu_err_o, dcdmmu_tag_o,
106
 
107 1063 lampret
`ifdef OR1200_BIST
108
        // RAM BIST
109
        scanb_rst, scanb_si, scanb_so, scanb_en, scanb_clk,
110
`endif
111
 
112 504 lampret
        // SPRs
113
        spr_cs, spr_write, spr_dat_i
114
);
115
 
116
parameter dw = `OR1200_OPERAND_WIDTH;
117
 
118
//
119
// I/O
120
//
121
 
122
//
123
// Clock and reset
124
//
125
input                           clk;
126
input                           rst;
127
 
128
//
129
// External I/F
130
//
131 977 lampret
output  [dw-1:0]         dcsb_dat_o;
132
output  [31:0]                   dcsb_adr_o;
133
output                          dcsb_cyc_o;
134
output                          dcsb_stb_o;
135
output                          dcsb_we_o;
136
output  [3:0]                    dcsb_sel_o;
137
output                          dcsb_cab_o;
138
input   [dw-1:0]         dcsb_dat_i;
139
input                           dcsb_ack_i;
140
input                           dcsb_err_i;
141 504 lampret
 
142
//
143
// Internal I/F
144
//
145
input                           dc_en;
146
input   [31:0]                   dcdmmu_adr_i;
147 660 lampret
input                           dcdmmu_cycstb_i;
148 504 lampret
input                           dcdmmu_ci_i;
149
input                           dcpu_we_i;
150
input   [3:0]                    dcpu_sel_i;
151
input   [3:0]                    dcpu_tag_i;
152
input   [dw-1:0]         dcpu_dat_i;
153
output  [dw-1:0]         dcpu_dat_o;
154
output                          dcpu_ack_o;
155
output                          dcpu_rty_o;
156
output                          dcdmmu_err_o;
157
output  [3:0]                    dcdmmu_tag_o;
158
 
159 1063 lampret
`ifdef OR1200_BIST
160 504 lampret
//
161 1063 lampret
// RAM BIST
162
//
163
input                           scanb_rst,
164
                                scanb_si,
165
                                scanb_en,
166
                                scanb_clk;
167
output                          scanb_so;
168
`endif
169
 
170
//
171 504 lampret
// SPR access
172
//
173
input                           spr_cs;
174
input                           spr_write;
175
input   [31:0]                   spr_dat_i;
176
 
177
//
178
// Internal wires and regs
179
//
180
wire                            tag_v;
181
wire    [`OR1200_DCTAG_W-2:0]    tag;
182
wire    [dw-1:0]         to_dcram;
183
wire    [dw-1:0]         from_dcram;
184
wire    [31:0]                   saved_addr;
185
wire    [3:0]                    dcram_we;
186
wire                            dctag_we;
187
wire    [31:0]                   dc_addr;
188
wire                            dcfsm_biu_read;
189
wire                            dcfsm_biu_write;
190
reg                             tagcomp_miss;
191
wire    [`OR1200_DCINDXH:`OR1200_DCLS]  dctag_addr;
192
wire                            dctag_en;
193
wire                            dctag_v;
194
wire                            dc_inv;
195
wire                            dcfsm_first_hit_ack;
196
wire                            dcfsm_first_miss_ack;
197
wire                            dcfsm_first_miss_err;
198
wire                            dcfsm_burst;
199 660 lampret
wire                            dcfsm_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 977 lampret
assign dcsb_adr_o = dc_addr;
215 504 lampret
assign dc_inv = spr_cs & spr_write;
216 660 lampret
assign dctag_we = dcfsm_tag_we | dc_inv;
217 504 lampret
assign dctag_addr = dc_inv ? spr_dat_i[`OR1200_DCINDXH:`OR1200_DCLS] : dc_addr[`OR1200_DCINDXH:`OR1200_DCLS];
218
assign dctag_en = dc_inv | dc_en;
219
assign dctag_v = ~dc_inv;
220
 
221
//
222
// Data to BIU is from DCRAM when DC is enabled or from LSU when
223
// DC is disabled
224
//
225 977 lampret
assign dcsb_dat_o = dcpu_dat_i;
226 504 lampret
 
227
//
228
// Bypases of the DC when DC is disabled
229
//
230 977 lampret
assign dcsb_cyc_o = (dc_en) ? dcfsm_biu_read | dcfsm_biu_write : dcdmmu_cycstb_i;
231
assign dcsb_stb_o = (dc_en) ? dcfsm_biu_read | dcfsm_biu_write : dcdmmu_cycstb_i;
232
assign dcsb_we_o = (dc_en) ? dcfsm_biu_write : dcpu_we_i;
233
assign dcsb_sel_o = (dc_en & dcfsm_biu_read & !dcfsm_biu_write & !dcdmmu_ci_i) ? 4'b1111 : dcpu_sel_i;
234
assign dcsb_cab_o = (dc_en) ? dcfsm_burst : 1'b0;
235 504 lampret
assign dcpu_rty_o = ~dcpu_ack_o;
236 562 lampret
assign dcdmmu_tag_o = dcdmmu_err_o ? `OR1200_DTAG_BE : dcpu_tag_i;
237 504 lampret
 
238
//
239
// DC/LSU normal and error termination
240
//
241 977 lampret
assign dcpu_ack_o = dc_en ? dcfsm_first_hit_ack | dcfsm_first_miss_ack : dcsb_ack_i;
242
assign dcdmmu_err_o = dc_en ? dcfsm_first_miss_err : dcsb_err_i;
243 504 lampret
 
244
//
245
// Select between claddr generated by DC FSM and addr[3:2] generated by LSU
246
//
247 660 lampret
//assign dc_addr = (dcfsm_biu_read | dcfsm_biu_write) ? saved_addr : dcdmmu_adr_i;
248 504 lampret
 
249
//
250
// Select between input data generated by LSU or by BIU
251
//
252 977 lampret
assign to_dcram = (dcfsm_biu_read) ? dcsb_dat_i : dcpu_dat_i;
253 504 lampret
 
254
//
255
// Select between data generated by DCRAM or passed by BIU
256
//
257 977 lampret
assign dcpu_dat_o = dcfsm_first_miss_ack | !dc_en ? dcsb_dat_i : from_dcram;
258 504 lampret
 
259
//
260
// Tag comparison
261
//
262
always @(tag or saved_addr or tag_v) begin
263
        if ((tag != saved_addr[31:`OR1200_DCTAGL]) || !tag_v)
264
                tagcomp_miss = 1'b1;
265
        else
266
                tagcomp_miss = 1'b0;
267
end
268
 
269
//
270
// Instantiation of DC Finite State Machine
271
//
272
or1200_dc_fsm or1200_dc_fsm(
273
        .clk(clk),
274
        .rst(rst),
275
        .dc_en(dc_en),
276 660 lampret
        .dcdmmu_cycstb_i(dcdmmu_cycstb_i),
277 562 lampret
        .dcdmmu_ci_i(dcdmmu_ci_i),
278 504 lampret
        .dcpu_we_i(dcpu_we_i),
279
        .dcpu_sel_i(dcpu_sel_i),
280
        .tagcomp_miss(tagcomp_miss),
281 977 lampret
        .biudata_valid(dcsb_ack_i),
282
        .biudata_error(dcsb_err_i),
283 504 lampret
        .start_addr(dcdmmu_adr_i),
284
        .saved_addr(saved_addr),
285
        .dcram_we(dcram_we),
286
        .biu_read(dcfsm_biu_read),
287
        .biu_write(dcfsm_biu_write),
288
        .first_hit_ack(dcfsm_first_hit_ack),
289
        .first_miss_ack(dcfsm_first_miss_ack),
290
        .first_miss_err(dcfsm_first_miss_err),
291 660 lampret
        .burst(dcfsm_burst),
292
        .tag_we(dcfsm_tag_we),
293
        .dc_addr(dc_addr)
294 504 lampret
);
295
 
296
//
297
// Instantiation of DC main memory
298
//
299
or1200_dc_ram or1200_dc_ram(
300
        .clk(clk),
301
        .rst(rst),
302 1063 lampret
`ifdef OR1200_BIST
303
        // RAM BIST
304
        .scanb_rst(scanb_rst),
305
        .scanb_si(scanb_ram_si),
306
        .scanb_so(scanb_ram_so),
307
        .scanb_en(scanb_en),
308
        .scanb_clk(scanb_clk),
309
`endif
310 504 lampret
        .addr(dc_addr[`OR1200_DCINDXH:2]),
311
        .en(dc_en),
312
        .we(dcram_we),
313
        .datain(to_dcram),
314
        .dataout(from_dcram)
315
);
316
 
317
//
318
// Instantiation of DC TAG memory
319
//
320
or1200_dc_tag or1200_dc_tag(
321
        .clk(clk),
322
        .rst(rst),
323 1063 lampret
`ifdef OR1200_BIST
324
        // RAM BIST
325
        .scanb_rst(scanb_rst),
326
        .scanb_si(scanb_tag_si),
327
        .scanb_so(scanb_tag_so),
328
        .scanb_en(scanb_en),
329
        .scanb_clk(scanb_clk),
330
`endif
331 504 lampret
        .addr(dctag_addr),
332
        .en(dctag_en),
333
        .we(dctag_we),
334
        .datain({dc_addr[31:`OR1200_DCTAGL], dctag_v}),
335
        .tag_v(tag_v),
336
        .tag(tag)
337
);
338
 
339
endmodule

powered by: WebSVN 2.1.0

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