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

Subversion Repositories thor

[/] [thor/] [trunk/] [rtl/] [verilog/] [Thor_icachemem.v] - Blame information for rev 55

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 robfinch
// ============================================================================
2
//        __
3 18 robfinch
//   \\__/ o\    (C) 2013-2016  Robert Finch, Stratford
4 3 robfinch
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@finitron.ca
6
//       ||
7
//
8
// This source file is free software: you can redistribute it and/or modify 
9
// it under the terms of the GNU Lesser General Public License as published 
10
// by the Free Software Foundation, either version 3 of the License, or     
11
// (at your option) any later version.                                      
12
//                                                                          
13
// This source file is distributed in the hope that it will be useful,      
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
16
// GNU General Public License for more details.                             
17
//                                                                          
18
// You should have received a copy of the GNU General Public License        
19
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
20
//
21
//
22
// Thor SuperScalar
23
//
24
// ============================================================================
25
//
26
module Thor_icachemem(wclk, wce, wr, wa, wd, rclk, pc, insn);
27
parameter DBW=64;
28 18 robfinch
parameter ABW=32;
29 37 robfinch
parameter ECC=1'b0;
30 3 robfinch
input wclk;
31
input wce;
32
input wr;
33 18 robfinch
input [ABW-1:0] wa;
34 37 robfinch
input [(ECC?((DBW==64)?DBW+13:DBW+6):DBW-1):0] wd;
35 3 robfinch
input rclk;
36 18 robfinch
input [ABW-1:0] pc;
37 3 robfinch
output reg [127:0] insn;
38
 
39 18 robfinch
wire [127:0] insn0;
40
wire [127:0] insn1;
41 37 robfinch
wire [(ECC?155:127):0] insn0a;
42
wire [(ECC?155:127):0] insn1a;
43 3 robfinch
 
44
generate
45 18 robfinch
begin : cache_mem
46
if (DBW==32) begin
47 37 robfinch
if (ECC) begin
48
/*
49
blk_mem_gen_2 uicm1 (
50 18 robfinch
  .clka(wclk),    // input wire clka
51
  .ena(wce),      // input wire ena
52
  .wea(wr),      // input wire [0 : 0] wea
53
  .addra(wa[14:2]),  // input wire [14 : 0] addra
54
  .dina(wd),    // input wire [31 : 0] dina
55
  .clkb(rclk),    // input wire clkb
56
  .enb(1'b1),
57
  .addrb(pc[14:4]),  // input wire [12 : 0] addrb
58 37 robfinch
  .doutb(insn0a)  // output wire [127 : 0] doutb
59 18 robfinch
);
60 3 robfinch
 
61 37 robfinch
blk_mem_gen_2 uicm2 (
62
  .clka(wclk),    // input wire clka
63
  .ena(wce),      // input wire ena
64
  .wea(wr),      // input wire [0 : 0] wea
65
  .addra(wa[14:2]),  // input wire [14 : 0] addra
66
  .dina(wd),    // input wire [31 : 0] dina
67
  .clkb(rclk),    // input wire clkb
68
  .enb(1'b1),
69
  .addrb(pc[14:4]+11'd1),  // input wire [12 : 0] addrb
70
  .doutb(insn1a)  // output wire [127 : 0] doutb
71
);
72
*/
73
end
74
else begin
75
icache_ram uicm1 (
76
    .wclk(wclk),
77
    .wce(wce),
78
    .wr(wr),
79
    .wa(wa[14:2]),
80
    .d(wd[31:0]),
81
    .rclk(rclk),
82
    .rce(1'b1),
83
    .ra(pc[14:4]),
84
    .q(insn0a)
85
);
86
 
87
icache_ram uicm2 (
88
    .wclk(wclk),
89
    .wce(wce),
90
    .wr(wr),
91
    .wa(wa[14:2]),
92
    .d(wd[31:0]),
93
    .rclk(rclk),
94
    .rce(1'b1),
95
    .ra(pc[14:4]+11'd1),
96
    .q(insn1a)
97
);
98
/*
99
blk_mem_gen_0 uicm1 (
100
  .clka(wclk),    // input wire clka
101
  .ena(wce),      // input wire ena
102
  .wea(wr),      // input wire [0 : 0] wea
103
  .addra(wa[14:2]),  // input wire [14 : 0] addra
104
  .dina(wd[31:0]),    // input wire [31 : 0] dina
105
  .clkb(rclk),    // input wire clkb
106
  .enb(1'b1),
107
  .addrb(pc[14:4]),  // input wire [12 : 0] addrb
108
  .doutb(insn0a)  // output wire [127 : 0] doutb
109
);
110
 
111 18 robfinch
blk_mem_gen_0 uicm2 (
112
  .clka(wclk),    // input wire clka
113
  .ena(wce),      // input wire ena
114
  .wea(wr),      // input wire [0 : 0] wea
115
  .addra(wa[14:2]),  // input wire [14 : 0] addra
116 37 robfinch
  .dina(wd[31:0]),    // input wire [31 : 0] dina
117
  .clkb(rclk),    // input wire clkb
118
  .enb(1'b1),
119
  .addrb(pc[14:4]+11'd1),  // input wire [12 : 0] addrb
120
  .doutb(insn1a)  // output wire [127 : 0] doutb
121
);
122
*/
123
end
124
 
125
end
126
else begin
127
if (ECC) begin
128
/*
129
blk_mem_gen_3 uicm1 (
130
  .clka(wclk),    // input wire clka
131
  .ena(wce),      // input wire ena
132
  .wea(wr),      // input wire [0 : 0] wea
133
  .addra(wa[14:3]),  // input wire [14 : 0] addra
134 18 robfinch
  .dina(wd),    // input wire [31 : 0] dina
135
  .clkb(rclk),    // input wire clkb
136
  .enb(1'b1),
137 37 robfinch
  .addrb(pc[14:4]),  // input wire [12 : 0] addrb
138
  .doutb(insn0a)  // output wire [127 : 0] doutb
139
);
140
 
141
blk_mem_gen_3 uicm2 (
142
  .clka(wclk),    // input wire clka
143
  .ena(wce),      // input wire ena
144
  .wea(wr),      // input wire [0 : 0] wea
145
  .addra(wa[14:3]),  // input wire [14 : 0] addra
146
  .dina(wd),    // input wire [31 : 0] dina
147
  .clkb(rclk),    // input wire clkb
148
  .enb(1'b1),
149 18 robfinch
  .addrb(pc[14:4]+11'd1),  // input wire [12 : 0] addrb
150 37 robfinch
  .doutb(insn1a)  // output wire [127 : 0] doutb
151 18 robfinch
);
152 37 robfinch
*/
153 3 robfinch
end
154 18 robfinch
else begin
155 37 robfinch
/*
156 18 robfinch
blk_mem_gen_1 uicm1 (
157
  .clka(wclk),    // input wire clka
158
  .ena(wce),      // input wire ena
159
  .wea(wr),      // input wire [0 : 0] wea
160
  .addra(wa[14:3]),  // input wire [14 : 0] addra
161 37 robfinch
  .dina(wd[63:0]),    // input wire [31 : 0] dina
162 18 robfinch
  .clkb(rclk),    // input wire clkb
163
  .enb(1'b1),
164
  .addrb(pc[14:4]),  // input wire [12 : 0] addrb
165 37 robfinch
  .doutb(insn0a)  // output wire [127 : 0] doutb
166 18 robfinch
);
167
 
168
blk_mem_gen_1 uicm2 (
169
  .clka(wclk),    // input wire clka
170
  .ena(wce),      // input wire ena
171
  .wea(wr),      // input wire [0 : 0] wea
172
  .addra(wa[14:3]),  // input wire [14 : 0] addra
173 37 robfinch
  .dina(wd[63:0]),    // input wire [31 : 0] dina
174 18 robfinch
  .clkb(rclk),    // input wire clkb
175
  .enb(1'b1),
176
  .addrb(pc[14:4]+11'd1),  // input wire [12 : 0] addrb
177 37 robfinch
  .doutb(insn1a)  // output wire [127 : 0] doutb
178 18 robfinch
);
179 37 robfinch
*/
180 18 robfinch
end
181 37 robfinch
end
182 18 robfinch
 
183
end
184 3 robfinch
endgenerate
185
 
186 37 robfinch
generate
187
begin : ECCx
188
if (ECC) begin
189
/*
190
ecc_0 uecc1a (
191
  .ecc_correct_n(1'b0),    // input wire ecc_correct_n
192
  .ecc_data_in(insn0a[31:0]),        // input wire [31 : 0] ecc_data_in
193
  .ecc_data_out(insn0[31:0]),      // output wire [31 : 0] ecc_data_out
194
  .ecc_chkbits_in({insn0a[37:32],insn0a[38]}),  // input wire [6 : 0] ecc_chkbits_in
195
  .ecc_sbit_err(),      // output wire ecc_sbit_err
196
  .ecc_dbit_err()      // output wire ecc_dbit_err
197
);
198
ecc_0 uecc1b (
199
  .ecc_correct_n(1'b0),    // input wire ecc_correct_n
200
  .ecc_data_in(insn0a[70:39]),        // input wire [31 : 0] ecc_data_in
201
  .ecc_data_out(insn0[63:32]),      // output wire [31 : 0] ecc_data_out
202
  .ecc_chkbits_in({insn0a[76:71],insn0a[77]}),  // input wire [6 : 0] ecc_chkbits_in
203
  .ecc_sbit_err(),      // output wire ecc_sbit_err
204
  .ecc_dbit_err()      // output wire ecc_dbit_err
205
);
206
ecc_0 uecc1c (
207
  .ecc_correct_n(1'b0),    // input wire ecc_correct_n
208
  .ecc_data_in(insn0a[109:78]),        // input wire [31 : 0] ecc_data_in
209
  .ecc_data_out(insn0[95:64]),      // output wire [31 : 0] ecc_data_out
210
  .ecc_chkbits_in({insn0a[115:110],insn0a[116]}),  // input wire [6 : 0] ecc_chkbits_in
211
  .ecc_sbit_err(),      // output wire ecc_sbit_err
212
  .ecc_dbit_err()      // output wire ecc_dbit_err
213
);
214
ecc_0 uecc1d (
215
  .ecc_correct_n(1'b0),    // input wire ecc_correct_n
216
  .ecc_data_in(insn0a[148:117]),        // input wire [31 : 0] ecc_data_in
217
  .ecc_data_out(insn0[127:96]),      // output wire [31 : 0] ecc_data_out
218
  .ecc_chkbits_in({insn0a[154:149],insn0a[155]}),  // input wire [6 : 0] ecc_chkbits_in
219
  .ecc_sbit_err(),      // output wire ecc_sbit_err
220
  .ecc_dbit_err()      // output wire ecc_dbit_err
221
);
222
ecc_0 uecc2a (
223
  .ecc_correct_n(1'b0),    // input wire ecc_correct_n
224
  .ecc_data_in(insn1a[31:0]),        // input wire [31 : 0] ecc_data_in
225
  .ecc_data_out(insn1[31:0]),      // output wire [31 : 0] ecc_data_out
226
  .ecc_chkbits_in({insn1a[37:32],insn1a[38]}),  // input wire [6 : 0] ecc_chkbits_in
227
  .ecc_sbit_err(),      // output wire ecc_sbit_err
228
  .ecc_dbit_err()      // output wire ecc_dbit_err
229
);
230
ecc_0 uecc2b (
231
  .ecc_correct_n(1'b0),    // input wire ecc_correct_n
232
  .ecc_data_in(insn1a[70:39]),        // input wire [31 : 0] ecc_data_in
233
  .ecc_data_out(insn1[63:32]),      // output wire [31 : 0] ecc_data_out
234
  .ecc_chkbits_in({insn1a[76:71],insn1a[77]}),  // input wire [6 : 0] ecc_chkbits_in
235
  .ecc_sbit_err(),      // output wire ecc_sbit_err
236
  .ecc_dbit_err()      // output wire ecc_dbit_err
237
);
238
ecc_0 uecc2c (
239
  .ecc_correct_n(1'b0),    // input wire ecc_correct_n
240
  .ecc_data_in(insn1a[109:78]),        // input wire [31 : 0] ecc_data_in
241
  .ecc_data_out(insn1[95:64]),      // output wire [31 : 0] ecc_data_out
242
  .ecc_chkbits_in({insn1a[115:110],insn1a[116]}),  // input wire [6 : 0] ecc_chkbits_in
243
  .ecc_sbit_err(),      // output wire ecc_sbit_err
244
  .ecc_dbit_err()      // output wire ecc_dbit_err
245
);
246
ecc_0 uecc2d (
247
  .ecc_correct_n(1'b0),    // input wire ecc_correct_n
248
  .ecc_data_in(insn1a[148:117]),        // input wire [31 : 0] ecc_data_in
249
  .ecc_data_out(insn1[127:96]),      // output wire [31 : 0] ecc_data_out
250
  .ecc_chkbits_in({insn1a[154:149],insn1a[155]}),  // input wire [6 : 0] ecc_chkbits_in
251
  .ecc_sbit_err(),      // output wire ecc_sbit_err
252
  .ecc_dbit_err()      // output wire ecc_dbit_err
253
);
254
*/
255
end
256
else begin
257
assign insn0 = insn0a;//{insn0a[148:117],insn0a[109:78],insn0a[70:39],insn0a[31:0]};
258
assign insn1 = insn1a;//{insn1a[148:117],insn1a[109:78],insn1a[70:39],insn1a[31:0]};
259
end
260
end
261
endgenerate
262
 
263 3 robfinch
always @(pc or insn0 or insn1)
264
case(pc[3:0])
265
4'd0:   insn <= insn0;
266
4'd1:   insn <= {insn1[7:0],insn0[127:8]};
267
4'd2:   insn <= {insn1[15:0],insn0[127:16]};
268
4'd3:   insn <= {insn1[23:0],insn0[127:24]};
269
4'd4:   insn <= {insn1[31:0],insn0[127:32]};
270
4'd5:   insn <= {insn1[39:0],insn0[127:40]};
271
4'd6:   insn <= {insn1[47:0],insn0[127:48]};
272
4'd7:   insn <= {insn1[55:0],insn0[127:56]};
273
4'd8:   insn <= {insn1[63:0],insn0[127:64]};
274
4'd9:   insn <= {insn1[71:0],insn0[127:72]};
275
4'd10:  insn <= {insn1[79:0],insn0[127:80]};
276
4'd11:  insn <= {insn1[87:0],insn0[127:88]};
277
4'd12:  insn <= {insn1[95:0],insn0[127:96]};
278
4'd13:  insn <= {insn1[103:0],insn0[127:104]};
279
4'd14:  insn <= {insn1[111:0],insn0[127:112]};
280
4'd15:  insn <= {insn1[119:0],insn0[127:120]};
281
endcase
282
 
283
endmodule

powered by: WebSVN 2.1.0

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