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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orp/] [orp_soc/] [rtl/] [verilog/] [or1200.old/] [or1200_dc_top.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 746 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
// Revision 1.4  2002/02/11 04:33:17  lampret
48
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
49
//
50
// Revision 1.3  2002/01/28 01:16:00  lampret
51
// 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.
52
//
53
// Revision 1.2  2002/01/14 06:18:22  lampret
54
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
55
//
56
// Revision 1.1  2002/01/03 08:16:15  lampret
57
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
58
//
59
// Revision 1.10  2001/10/21 17:57:16  lampret
60
// 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.
61
//
62
// Revision 1.9  2001/10/14 13:12:09  lampret
63
// MP3 version.
64
//
65
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
66
// no message
67
//
68
// Revision 1.4  2001/08/13 03:36:20  lampret
69
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
70
//
71
// Revision 1.3  2001/08/09 13:39:33  lampret
72
// Major clean-up.
73
//
74
// Revision 1.2  2001/07/22 03:31:53  lampret
75
// Fixed RAM's oen bug. Cache bypass under development.
76
//
77
// Revision 1.1  2001/07/20 00:46:03  lampret
78
// Development version of RTL. Libraries are missing.
79
//
80
//
81
 
82
// synopsys translate_off
83
`include "timescale.v"
84
// synopsys translate_on
85
`include "or1200_defines.v"
86
 
87
//
88
// Data cache
89
//
90
module or1200_dc_top(
91
        // Rst, clk and clock control
92
        clk, rst,
93
 
94
        // External i/f
95
        dcbiu_dat_o, dcbiu_adr_o, dcbiu_cyc_o, dcbiu_stb_o, dcbiu_we_o, dcbiu_sel_o, dcbiu_cab_o,
96
        dcbiu_dat_i, dcbiu_ack_i, dcbiu_err_i,
97
 
98
        // Internal i/f
99
        dc_en,
100
        dcdmmu_adr_i, dcdmmu_cycstb_i, dcdmmu_ci_i,
101
        dcpu_we_i, dcpu_sel_i, dcpu_tag_i, dcpu_dat_i,
102
        dcpu_dat_o, dcpu_ack_o, dcpu_rty_o, dcdmmu_err_o, dcdmmu_tag_o,
103
 
104
        // SPRs
105
        spr_cs, spr_write, spr_dat_i
106
);
107
 
108
parameter dw = `OR1200_OPERAND_WIDTH;
109
 
110
//
111
// I/O
112
//
113
 
114
//
115
// Clock and reset
116
//
117
input                           clk;
118
input                           rst;
119
 
120
//
121
// External I/F
122
//
123
output  [dw-1:0]         dcbiu_dat_o;
124
output  [31:0]                   dcbiu_adr_o;
125
output                          dcbiu_cyc_o;
126
output                          dcbiu_stb_o;
127
output                          dcbiu_we_o;
128
output  [3:0]                    dcbiu_sel_o;
129
output                          dcbiu_cab_o;
130
input   [dw-1:0]         dcbiu_dat_i;
131
input                           dcbiu_ack_i;
132
input                           dcbiu_err_i;
133
 
134
//
135
// Internal I/F
136
//
137
input                           dc_en;
138
input   [31:0]                   dcdmmu_adr_i;
139
input                           dcdmmu_cycstb_i;
140
input                           dcdmmu_ci_i;
141
input                           dcpu_we_i;
142
input   [3:0]                    dcpu_sel_i;
143
input   [3:0]                    dcpu_tag_i;
144
input   [dw-1:0]         dcpu_dat_i;
145
output  [dw-1:0]         dcpu_dat_o;
146
output                          dcpu_ack_o;
147
output                          dcpu_rty_o;
148
output                          dcdmmu_err_o;
149
output  [3:0]                    dcdmmu_tag_o;
150
 
151
//
152
// SPR access
153
//
154
input                           spr_cs;
155
input                           spr_write;
156
input   [31:0]                   spr_dat_i;
157
 
158
//
159
// Internal wires and regs
160
//
161
wire                            tag_v;
162
wire    [`OR1200_DCTAG_W-2:0]    tag;
163
wire    [dw-1:0]         to_dcram;
164
wire    [dw-1:0]         from_dcram;
165
wire    [31:0]                   saved_addr;
166
wire    [3:0]                    dcram_we;
167
wire                            dctag_we;
168
wire    [31:0]                   dc_addr;
169
wire                            dcfsm_biu_read;
170
wire                            dcfsm_biu_write;
171
reg                             tagcomp_miss;
172
wire    [`OR1200_DCINDXH:`OR1200_DCLS]  dctag_addr;
173
wire                            dctag_en;
174
wire                            dctag_v;
175
wire                            dc_inv;
176
wire                            dcfsm_first_hit_ack;
177
wire                            dcfsm_first_miss_ack;
178
wire                            dcfsm_first_miss_err;
179
wire                            dcfsm_burst;
180
wire                            dcfsm_tag_we;
181
 
182
//
183
// Simple assignments
184
//
185
assign dcbiu_adr_o = dc_addr;
186
assign dc_inv = spr_cs & spr_write;
187
assign dctag_we = dcfsm_tag_we | dc_inv;
188
assign dctag_addr = dc_inv ? spr_dat_i[`OR1200_DCINDXH:`OR1200_DCLS] : dc_addr[`OR1200_DCINDXH:`OR1200_DCLS];
189
assign dctag_en = dc_inv | dc_en;
190
assign dctag_v = ~dc_inv;
191
 
192
//
193
// Data to BIU is from DCRAM when DC is enabled or from LSU when
194
// DC is disabled
195
//
196
assign dcbiu_dat_o = dcpu_dat_i;
197
 
198
//
199
// Bypases of the DC when DC is disabled
200
//
201
assign dcbiu_cyc_o = (dc_en) ? dcfsm_biu_read | dcfsm_biu_write : dcdmmu_cycstb_i;
202
assign dcbiu_stb_o = (dc_en) ? dcfsm_biu_read | dcfsm_biu_write : dcdmmu_cycstb_i;
203
assign dcbiu_we_o = (dc_en) ? dcfsm_biu_write : dcpu_we_i;
204
assign dcbiu_sel_o = (dc_en & dcfsm_biu_read & !dcfsm_biu_write & !dcdmmu_ci_i) ? 4'b1111 : dcpu_sel_i;
205
assign dcbiu_cab_o = (dc_en) ? dcfsm_burst : 1'b0;
206
assign dcpu_rty_o = ~dcpu_ack_o;
207
assign dcdmmu_tag_o = dcdmmu_err_o ? `OR1200_DTAG_BE : dcpu_tag_i;
208
 
209
//
210
// DC/LSU normal and error termination
211
//
212
assign dcpu_ack_o = dc_en ? dcfsm_first_hit_ack | dcfsm_first_miss_ack : dcbiu_ack_i;
213
assign dcdmmu_err_o = dc_en ? dcfsm_first_miss_err : dcbiu_err_i;
214
 
215
//
216
// Select between claddr generated by DC FSM and addr[3:2] generated by LSU
217
//
218
//assign dc_addr = (dcfsm_biu_read | dcfsm_biu_write) ? saved_addr : dcdmmu_adr_i;
219
 
220
//
221
// Select between input data generated by LSU or by BIU
222
//
223
assign to_dcram = (dcfsm_biu_read) ? dcbiu_dat_i : dcpu_dat_i;
224
 
225
//
226
// Select between data generated by DCRAM or passed by BIU
227
//
228
assign dcpu_dat_o = dcfsm_first_miss_ack | !dc_en ? dcbiu_dat_i : from_dcram;
229
 
230
//
231
// Tag comparison
232
//
233
always @(tag or saved_addr or tag_v) begin
234
        if ((tag != saved_addr[31:`OR1200_DCTAGL]) || !tag_v)
235
                tagcomp_miss = 1'b1;
236
        else
237
                tagcomp_miss = 1'b0;
238
end
239
 
240
//
241
// Instantiation of DC Finite State Machine
242
//
243
or1200_dc_fsm or1200_dc_fsm(
244
        .clk(clk),
245
        .rst(rst),
246
        .dc_en(dc_en),
247
        .dcdmmu_cycstb_i(dcdmmu_cycstb_i),
248
        .dcdmmu_ci_i(dcdmmu_ci_i),
249
        .dcpu_we_i(dcpu_we_i),
250
        .dcpu_sel_i(dcpu_sel_i),
251
        .tagcomp_miss(tagcomp_miss),
252
        .biudata_valid(dcbiu_ack_i),
253
        .biudata_error(dcbiu_err_i),
254
        .start_addr(dcdmmu_adr_i),
255
        .saved_addr(saved_addr),
256
        .dcram_we(dcram_we),
257
        .biu_read(dcfsm_biu_read),
258
        .biu_write(dcfsm_biu_write),
259
        .first_hit_ack(dcfsm_first_hit_ack),
260
        .first_miss_ack(dcfsm_first_miss_ack),
261
        .first_miss_err(dcfsm_first_miss_err),
262
        .burst(dcfsm_burst),
263
        .tag_we(dcfsm_tag_we),
264
        .dc_addr(dc_addr)
265
);
266
 
267
//
268
// Instantiation of DC main memory
269
//
270
or1200_dc_ram or1200_dc_ram(
271
        .clk(clk),
272
        .rst(rst),
273
        .addr(dc_addr[`OR1200_DCINDXH:2]),
274
        .en(dc_en),
275
        .we(dcram_we),
276
        .datain(to_dcram),
277
        .dataout(from_dcram)
278
);
279
 
280
//
281
// Instantiation of DC TAG memory
282
//
283
or1200_dc_tag or1200_dc_tag(
284
        .clk(clk),
285
        .rst(rst),
286
        .addr(dctag_addr),
287
        .en(dctag_en),
288
        .we(dctag_we),
289
        .datain({dc_addr[31:`OR1200_DCTAGL], dctag_v}),
290
        .tag_v(tag_v),
291
        .tag(tag)
292
);
293
 
294
endmodule

powered by: WebSVN 2.1.0

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