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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_1/] [or1200/] [rtl/] [verilog/] [or1200_dc_top.v] - Blame information for rev 1780

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 660 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 dc.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_dc_top(
88
        // Rst, clk and clock control
89
        clk, rst,
90
 
91
        // External i/f
92
        dcbiu_dat_o, dcbiu_adr_o, dcbiu_cyc_o, dcbiu_stb_o, dcbiu_we_o, dcbiu_sel_o, dcbiu_cab_o,
93
        dcbiu_dat_i, dcbiu_ack_i, dcbiu_err_i,
94
 
95
        // Internal i/f
96
        dc_en,
97 660 lampret
        dcdmmu_adr_i, dcdmmu_cycstb_i, dcdmmu_ci_i,
98 504 lampret
        dcpu_we_i, dcpu_sel_i, dcpu_tag_i, dcpu_dat_i,
99
        dcpu_dat_o, dcpu_ack_o, dcpu_rty_o, dcdmmu_err_o, dcdmmu_tag_o,
100
 
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]         dcbiu_dat_o;
121
output  [31:0]                   dcbiu_adr_o;
122
output                          dcbiu_cyc_o;
123
output                          dcbiu_stb_o;
124
output                          dcbiu_we_o;
125
output  [3:0]                    dcbiu_sel_o;
126
output                          dcbiu_cab_o;
127
input   [dw-1:0]         dcbiu_dat_i;
128
input                           dcbiu_ack_i;
129
input                           dcbiu_err_i;
130
 
131
//
132
// Internal I/F
133
//
134
input                           dc_en;
135
input   [31:0]                   dcdmmu_adr_i;
136 660 lampret
input                           dcdmmu_cycstb_i;
137 504 lampret
input                           dcdmmu_ci_i;
138
input                           dcpu_we_i;
139
input   [3:0]                    dcpu_sel_i;
140
input   [3:0]                    dcpu_tag_i;
141
input   [dw-1:0]         dcpu_dat_i;
142
output  [dw-1:0]         dcpu_dat_o;
143
output                          dcpu_ack_o;
144
output                          dcpu_rty_o;
145
output                          dcdmmu_err_o;
146
output  [3:0]                    dcdmmu_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_DCTAG_W-2:0]    tag;
160
wire    [dw-1:0]         to_dcram;
161
wire    [dw-1:0]         from_dcram;
162
wire    [31:0]                   saved_addr;
163
wire    [3:0]                    dcram_we;
164
wire                            dctag_we;
165
wire    [31:0]                   dc_addr;
166
wire                            dcfsm_biu_read;
167
wire                            dcfsm_biu_write;
168
reg                             tagcomp_miss;
169
wire    [`OR1200_DCINDXH:`OR1200_DCLS]  dctag_addr;
170
wire                            dctag_en;
171
wire                            dctag_v;
172
wire                            dc_inv;
173
wire                            dcfsm_first_hit_ack;
174
wire                            dcfsm_first_miss_ack;
175
wire                            dcfsm_first_miss_err;
176
wire                            dcfsm_burst;
177 660 lampret
wire                            dcfsm_tag_we;
178 504 lampret
 
179
//
180
// Simple assignments
181
//
182
assign dcbiu_adr_o = dc_addr;
183
assign dc_inv = spr_cs & spr_write;
184 660 lampret
assign dctag_we = dcfsm_tag_we | dc_inv;
185 504 lampret
assign dctag_addr = dc_inv ? spr_dat_i[`OR1200_DCINDXH:`OR1200_DCLS] : dc_addr[`OR1200_DCINDXH:`OR1200_DCLS];
186
assign dctag_en = dc_inv | dc_en;
187
assign dctag_v = ~dc_inv;
188
 
189
//
190
// Data to BIU is from DCRAM when DC is enabled or from LSU when
191
// DC is disabled
192
//
193
assign dcbiu_dat_o = dcpu_dat_i;
194
 
195
//
196
// Bypases of the DC when DC is disabled
197
//
198 660 lampret
assign dcbiu_cyc_o = (dc_en) ? dcfsm_biu_read | dcfsm_biu_write : dcdmmu_cycstb_i;
199
assign dcbiu_stb_o = (dc_en) ? dcfsm_biu_read | dcfsm_biu_write : dcdmmu_cycstb_i;
200 504 lampret
assign dcbiu_we_o = (dc_en) ? dcfsm_biu_write : dcpu_we_i;
201 617 lampret
assign dcbiu_sel_o = (dc_en & dcfsm_biu_read & !dcfsm_biu_write & !dcdmmu_ci_i) ? 4'b1111 : dcpu_sel_i;
202 504 lampret
assign dcbiu_cab_o = (dc_en) ? dcfsm_burst : 1'b0;
203
assign dcpu_rty_o = ~dcpu_ack_o;
204 562 lampret
assign dcdmmu_tag_o = dcdmmu_err_o ? `OR1200_DTAG_BE : dcpu_tag_i;
205 504 lampret
 
206
//
207
// DC/LSU normal and error termination
208
//
209
assign dcpu_ack_o = dc_en ? dcfsm_first_hit_ack | dcfsm_first_miss_ack : dcbiu_ack_i;
210
assign dcdmmu_err_o = dc_en ? dcfsm_first_miss_err : dcbiu_err_i;
211
 
212
//
213
// Select between claddr generated by DC FSM and addr[3:2] generated by LSU
214
//
215 660 lampret
//assign dc_addr = (dcfsm_biu_read | dcfsm_biu_write) ? saved_addr : dcdmmu_adr_i;
216 504 lampret
 
217
//
218
// Select between input data generated by LSU or by BIU
219
//
220
assign to_dcram = (dcfsm_biu_read) ? dcbiu_dat_i : dcpu_dat_i;
221
 
222
//
223
// Select between data generated by DCRAM or passed by BIU
224
//
225
assign dcpu_dat_o = dcfsm_first_miss_ack | !dc_en ? dcbiu_dat_i : from_dcram;
226
 
227
//
228
// Tag comparison
229
//
230
always @(tag or saved_addr or tag_v) begin
231
        if ((tag != saved_addr[31:`OR1200_DCTAGL]) || !tag_v)
232
                tagcomp_miss = 1'b1;
233
        else
234
                tagcomp_miss = 1'b0;
235
end
236
 
237
//
238
// Instantiation of DC Finite State Machine
239
//
240
or1200_dc_fsm or1200_dc_fsm(
241
        .clk(clk),
242
        .rst(rst),
243
        .dc_en(dc_en),
244 660 lampret
        .dcdmmu_cycstb_i(dcdmmu_cycstb_i),
245 562 lampret
        .dcdmmu_ci_i(dcdmmu_ci_i),
246 504 lampret
        .dcpu_we_i(dcpu_we_i),
247
        .dcpu_sel_i(dcpu_sel_i),
248
        .tagcomp_miss(tagcomp_miss),
249
        .biudata_valid(dcbiu_ack_i),
250
        .biudata_error(dcbiu_err_i),
251
        .start_addr(dcdmmu_adr_i),
252
        .saved_addr(saved_addr),
253
        .dcram_we(dcram_we),
254
        .biu_read(dcfsm_biu_read),
255
        .biu_write(dcfsm_biu_write),
256
        .first_hit_ack(dcfsm_first_hit_ack),
257
        .first_miss_ack(dcfsm_first_miss_ack),
258
        .first_miss_err(dcfsm_first_miss_err),
259 660 lampret
        .burst(dcfsm_burst),
260
        .tag_we(dcfsm_tag_we),
261
        .dc_addr(dc_addr)
262 504 lampret
);
263
 
264
//
265
// Instantiation of DC main memory
266
//
267
or1200_dc_ram or1200_dc_ram(
268
        .clk(clk),
269
        .rst(rst),
270
        .addr(dc_addr[`OR1200_DCINDXH:2]),
271
        .en(dc_en),
272
        .we(dcram_we),
273
        .datain(to_dcram),
274
        .dataout(from_dcram)
275
);
276
 
277
//
278
// Instantiation of DC TAG memory
279
//
280
or1200_dc_tag or1200_dc_tag(
281
        .clk(clk),
282
        .rst(rst),
283
        .addr(dctag_addr),
284
        .en(dctag_en),
285
        .we(dctag_we),
286
        .datain({dc_addr[31:`OR1200_DCTAGL], dctag_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.