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 504

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

powered by: WebSVN 2.1.0

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