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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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