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

Subversion Repositories sparc64soc

[/] [sparc64soc/] [trunk/] [T1-common/] [srams/] [bw_r_irf_fpga1.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 dmitryr
module bw_r_irf_fpga1 (
2
   input [ 11:0]  current_cwp,
3
   input         rclk,
4
   input         reset_l,
5
 
6
   input         si,
7
   input         se,
8
   input         sehold,
9
   input         rst_tri_en,
10
 
11
   input  [ 1:0] ifu_exu_tid_s2,  // s stage thread
12
   input  [ 4:0] ifu_exu_rs1_s,  // source addresses
13
   input  [ 4:0] ifu_exu_rs2_s,
14
   input  [ 4:0] ifu_exu_rs3_s,
15
   input         ifu_exu_ren1_s,        // read enables for all 3 ports
16
   input         ifu_exu_ren2_s,
17
   input         ifu_exu_ren3_s,
18
   input         ecl_irf_wen_w,        // write enables for both write ports
19
   input         ecl_irf_wen_w2,
20
   input  [ 4:0] ecl_irf_rd_m,   // w destination
21
   input  [ 4:0] ecl_irf_rd_g,  // w2 destination
22
   input  [71:0] byp_irf_rd_data_w,// write data from w1
23
   input  [71:0] byp_irf_rd_data_w2,     // write data from w2
24
   input  [ 1:0] ecl_irf_tid_m,  // w stage thread
25
   input  [ 1:0] ecl_irf_tid_g, // w2 thread
26
 
27
   input  [ 2:0] rml_irf_old_lo_cwp_e,  // current window pointer for locals and odds
28
   input  [ 2:0] rml_irf_new_lo_cwp_e,  // target window pointer for locals and odds
29
   input  [ 2:1] rml_irf_old_e_cwp_e,  // current window pointer for evens
30
   input  [ 2:1] rml_irf_new_e_cwp_e,  // target window pointer for evens
31
   input         rml_irf_swap_even_e,
32
   input         rml_irf_swap_odd_e,
33
   input         rml_irf_swap_local_e,
34
   input         rml_irf_kill_restore_w,
35
   input  [ 1:0] rml_irf_cwpswap_tid_e,
36
 
37
   input  [ 1:0] rml_irf_old_agp, // alternate global pointer
38
   input  [ 1:0] rml_irf_new_agp, // alternate global pointer
39
   input         rml_irf_swap_global,
40
   input  [ 1:0] rml_irf_global_tid,
41
 
42
   output        so,
43
   output reg [71:0] irf_byp_rs1_data_d_l,
44
   output reg [71:0] irf_byp_rs2_data_d_l,
45
   output reg [71:0] irf_byp_rs3_data_d_l,
46
   output reg [31:0] irf_byp_rs3h_data_d_l
47
);
48
 
49
wire [71:0] dout0_0;
50
wire [71:0] dout0_1;
51
wire [71:0] dout0_2;
52
wire [71:0] dout0_3;
53
wire [71:0] dout1_0;
54
wire [71:0] dout1_1;
55
wire [71:0] dout1_2;
56
wire [71:0] dout1_3;
57
wire [71:0] dout2_0;
58
wire [71:0] dout2_1;
59
wire [71:0] dout2_2;
60
wire [71:0] dout2_3;
61
wire [71:0] dout3_0;
62
wire [71:0] dout3_1;
63
wire [71:0] dout3_2;
64
wire [71:0] dout3_3;
65
 
66
reg [1:0] ecl_irf_tid_m_d;
67
reg [1:0] ecl_irf_tid_g_d;
68
reg [4:0] ecl_irf_rd_m_d;
69
reg [4:0] ecl_irf_rd_g_d;
70
 
71
wire wen0_0=(ecl_irf_tid_m_d==2'b00) && ecl_irf_wen_w && (ecl_irf_rd_m_d!=0) & ~rst_tri_en;
72
wire wen0_1=(ecl_irf_tid_g_d==2'b00) && ecl_irf_wen_w2 && (ecl_irf_rd_g_d!=0) & ~rst_tri_en;
73
wire wen1_0=(ecl_irf_tid_m_d==2'b01) && ecl_irf_wen_w && (ecl_irf_rd_m_d!=0) & ~rst_tri_en;
74
wire wen1_1=(ecl_irf_tid_g_d==2'b01) && ecl_irf_wen_w2 && (ecl_irf_rd_g_d!=0) & ~rst_tri_en;
75
wire wen2_0=(ecl_irf_tid_m_d==2'b10) && ecl_irf_wen_w && (ecl_irf_rd_m_d!=0) & ~rst_tri_en;
76
wire wen2_1=(ecl_irf_tid_g_d==2'b10) && ecl_irf_wen_w2 && (ecl_irf_rd_g_d!=0) & ~rst_tri_en;
77
wire wen3_0=(ecl_irf_tid_m_d==2'b11) && ecl_irf_wen_w && (ecl_irf_rd_m_d!=0) & ~rst_tri_en;
78
wire wen3_1=(ecl_irf_tid_g_d==2'b11) && ecl_irf_wen_w2 && (ecl_irf_rd_g_d!=0) & ~rst_tri_en;
79
 
80
 
81
reg [2:0] wr0_window;
82
reg [2:0] wr1_window;
83
reg [2:0] rd0_window;
84
reg [2:0] rd1_window;
85
reg [2:0] rd2_window;
86
 
87
reg [2:0] current_global[3:0];
88
reg [2:0] current_window[3:0];
89
reg [2:0] current_read[3:0];
90
reg [2:0] current_write[3:0];
91
reg [2:0] current_write_d[3:0];
92
 
93
reg [1:0] cwpswap_tid_d;
94
reg [2:0] new_lo_cwp_d;
95
reg [2:0] old_lo_cwp_d;
96
reg       swap_local_d;
97
 
98
reg [1:0] cwpswap_tid_d1;
99
reg [2:0] new_lo_cwp_d1;
100
reg [2:0] old_lo_cwp_d1;
101
reg       swap_local_d1;
102
 
103
reg [1:0] cwpswap_tid_d2;
104
reg [2:0] new_lo_cwp_d2;
105
reg [2:0] old_lo_cwp_d2;
106
reg       swap_local_d2;
107
 
108
reg [1:0] ifu_exu_tid_s2_d;
109
 
110
integer i;
111
 
112
always @(posedge rclk or negedge reset_l)
113
   if(~reset_l)
114
      begin
115
         current_global[0]<=3'd3;
116
         current_global[1]<=3'd3;
117
         current_global[2]<=3'd3;
118
         current_global[3]<=3'd3;
119
         current_window[0]<=0;
120
         current_window[1]<=0;
121
         current_window[2]<=0;
122
         current_window[3]<=0;
123
         current_write[0]<=0;
124
         current_write[1]<=0;
125
         current_write[2]<=0;
126
         current_write[3]<=0;
127
         current_read[0]<=0;
128
         current_read[1]<=0;
129
         current_read[2]<=0;
130
         current_read[3]<=0;
131
         swap_local_d<=0;
132
         swap_local_d1<=0;
133
      end
134
   else
135
      begin
136
         // !!! Maybe we should flop that on negedge also
137
         if(ifu_exu_ren1_s || ifu_exu_ren2_s || ifu_exu_ren3_s)
138
            ifu_exu_tid_s2_d<=ifu_exu_tid_s2;
139
 
140
         ecl_irf_tid_m_d<=ecl_irf_tid_m;
141
         ecl_irf_tid_g_d<=ecl_irf_tid_g;
142
         ecl_irf_rd_m_d<=ecl_irf_rd_m;
143
         ecl_irf_rd_g_d<=ecl_irf_rd_g;
144
 
145
         swap_local_d<=rml_irf_swap_local_e & ~rst_tri_en;
146
         cwpswap_tid_d<=rml_irf_cwpswap_tid_e;
147
         new_lo_cwp_d<=rml_irf_new_lo_cwp_e;
148
         old_lo_cwp_d<=rml_irf_old_lo_cwp_e;
149
 
150
         swap_local_d1<=swap_local_d;
151
         cwpswap_tid_d1<=cwpswap_tid_d;
152
         new_lo_cwp_d1<=new_lo_cwp_d;
153
         old_lo_cwp_d1<=old_lo_cwp_d;
154
 
155
         swap_local_d2<=swap_local_d1;
156
         cwpswap_tid_d2<=cwpswap_tid_d1;
157
         new_lo_cwp_d2<=new_lo_cwp_d1;
158
         old_lo_cwp_d2<=old_lo_cwp_d1;
159
 
160
         if(rml_irf_swap_global & ~rst_tri_en)
161
            current_global[rml_irf_global_tid]<={1'b0,rml_irf_new_agp};
162
 
163
         /*if(swap_local_d)
164
            begin
165
               current_write[cwpswap_tid_d]<=new_lo_cwp_d;
166
               current_read[cwpswap_tid_d]<=new_lo_cwp_d;
167
            end
168
         else
169
            if(swap_local_d2 && (new_lo_cwp_d2[0]!=exu_ifu_oddwin_s[cwpswap_tid_d2]))
170
               begin
171
                  current_write[cwpswap_tid_d2]<=old_lo_cwp_d2;
172
                  current_read[cwpswap_tid_d2]<=old_lo_cwp_d2;
173
               end*/
174
 
175
 
176
         /*
177
         if(rml_irf_swap_local_e)
178
           current_write[rml_irf_cwpswap_tid_e]<=rml_irf_old_lo_cwp_e;
179
         else
180
            if(swap_local_d)
181
               current_write[cwpswap_tid_d]<=new_lo_cwp_d;
182
 
183
         for(i=0;i<4;i=i+1)
184
            current_write_d[i]<=current_write[i];
185
 
186
         if(rml_irf_swap_local_e)
187
            current_read[cwpswap_tid_d1]<=rml_irf_old_lo_cwp_e;
188
         else
189
            if(swap_local_d1)
190
               current_read[cwpswap_tid_d1]<=new_lo_cwp_d1;
191
         */
192
      end
193
 
194
/*
195
always @( * )
196
   begin
197
      wr0_window<=ecl_irf_rd_m_d[4:3]==2'b0 ? current_global[ecl_irf_tid_m_d]:(rml_irf_swap_local_e  && (ecl_irf_tid_m_d==rml_irf_cwpswap_tid_e) ? rml_irf_old_lo_cwp_e:current_write[ecl_irf_tid_m_d]);
198
      wr1_window<=ecl_irf_rd_g_d[4:3]==2'b0 ? current_global[ecl_irf_tid_g_d]:(rml_irf_swap_local_e  && (ecl_irf_tid_g_d==rml_irf_cwpswap_tid_e) ? rml_irf_old_lo_cwp_e:current_write[ecl_irf_tid_g_d]);
199
      rd0_window<=ifu_exu_rs1_s[4:3]==2'b0 ? current_global[ifu_exu_tid_s2]:(rml_irf_swap_local_e  && (ifu_exu_tid_s2==rml_irf_cwpswap_tid_e) ? rml_irf_old_lo_cwp_e:current_read[ifu_exu_tid_s2]);
200
      rd1_window<=ifu_exu_rs2_s[4:3]==2'b0 ? current_global[ifu_exu_tid_s2]:(rml_irf_swap_local_e  && (ifu_exu_tid_s2==rml_irf_cwpswap_tid_e) ? rml_irf_old_lo_cwp_e:current_read[ifu_exu_tid_s2]);
201
      rd2_window<=ifu_exu_rs3_s[4:3]==2'b0 ? current_global[ifu_exu_tid_s2]:(rml_irf_swap_local_e  && (ifu_exu_tid_s2==rml_irf_cwpswap_tid_e) ? rml_irf_old_lo_cwp_e:current_read[ifu_exu_tid_s2]);
202
   end
203
*/
204
 
205
reg [2:0] wr0_cwp;
206
reg [2:0] wr1_cwp;
207
reg [2:0] rd_cwp;
208
 
209
always @( * )
210
   case(ecl_irf_tid_m_d)
211
      2'b00:wr0_cwp<=current_cwp[2:0];
212
      2'b01:wr0_cwp<=current_cwp[5:3];
213
      2'b10:wr0_cwp<=current_cwp[8:6];
214
      2'b11:wr0_cwp<=current_cwp[11:9];
215
   endcase
216
 
217
always @( * )
218
   case(ecl_irf_tid_g_d)
219
      2'b00:wr1_cwp<=current_cwp[2:0];
220
      2'b01:wr1_cwp<=current_cwp[5:3];
221
      2'b10:wr1_cwp<=current_cwp[8:6];
222
      2'b11:wr1_cwp<=current_cwp[11:9];
223
   endcase
224
 
225
always @( * )
226
   case(ifu_exu_tid_s2)
227
      2'b00:rd_cwp<=current_cwp[2:0];
228
      2'b01:rd_cwp<=current_cwp[5:3];
229
      2'b10:rd_cwp<=current_cwp[8:6];
230
      2'b11:rd_cwp<=current_cwp[11:9];
231
   endcase
232
 
233
always @( * )
234
   begin
235
      wr0_window<=ecl_irf_rd_m_d[4:3]==2'b0 ? current_global[ecl_irf_tid_m_d]:wr0_cwp;
236
      wr1_window<=ecl_irf_rd_g_d[4:3]==2'b0 ? current_global[ecl_irf_tid_g_d]:wr1_cwp;
237
      rd0_window<=ifu_exu_rs1_s[4:3]==2'b0 ? current_global[ifu_exu_tid_s2]:rd_cwp;
238
      rd1_window<=ifu_exu_rs2_s[4:3]==2'b0 ? current_global[ifu_exu_tid_s2]:rd_cwp;
239
      rd2_window<=ifu_exu_rs3_s[4:3]==2'b0 ? current_global[ifu_exu_tid_s2]:rd_cwp;
240
   end
241
 
242
wire [4:0] wraddr0_swapoe=(!wr0_window[0] && ecl_irf_rd_m_d[3]) ? {~ecl_irf_rd_m_d[4],ecl_irf_rd_m_d[3:0]}:ecl_irf_rd_m_d;
243
wire [4:0] wraddr1_swapoe=(!wr1_window[0] && ecl_irf_rd_g_d[3]) ? {~ecl_irf_rd_g_d[4],ecl_irf_rd_g_d[3:0]}:ecl_irf_rd_g_d;
244
wire [4:0] rdaddr0_swapoe=(!rd0_window[0] && ifu_exu_rs1_s[3]) ? {~ifu_exu_rs1_s[4],ifu_exu_rs1_s[3:0]}:ifu_exu_rs1_s;
245
wire [4:0] rdaddr1_swapoe=(!rd1_window[0] && ifu_exu_rs2_s[3]) ? {~ifu_exu_rs2_s[4],ifu_exu_rs2_s[3:0]}:ifu_exu_rs2_s;
246
wire [4:0] rdaddr2_swapoe=(!rd2_window[0] && ifu_exu_rs3_s[3]) ? {~ifu_exu_rs3_s[4],ifu_exu_rs3_s[3:0]}:ifu_exu_rs3_s;
247
 
248
wire [6:0] wraddr0_wa={2'b0,wraddr0_swapoe}+{wr0_window,4'b0};
249
wire [6:0] wraddr1_wa={2'b0,wraddr1_swapoe}+{wr1_window,4'b0};
250
wire [6:0] rdaddr0_wa={2'b0,rdaddr0_swapoe}+{rd0_window,4'b0};
251
wire [6:0] rdaddr1_wa={2'b0,rdaddr1_swapoe}+{rd1_window,4'b0};
252
wire [6:0] rdaddr2_wa={2'b0,rdaddr2_swapoe}+{rd2_window,4'b0};
253
 
254
wire [7:0] wraddr0={1'b0,wraddr0_wa}+(ecl_irf_rd_m_d[4:3]!=2'b0 ? 8'd64:8'd0);
255
wire [7:0] wraddr1={1'b0,wraddr1_wa}+(ecl_irf_rd_g_d[4:3]!=2'b0 ? 8'd64:8'd0);
256
wire [7:0] rdaddr0={1'b0,rdaddr0_wa}+(ifu_exu_rs1_s[4:3]!=2'b0 ? 8'd64:8'd0);
257
wire [7:0] rdaddr1={1'b0,rdaddr1_wa}+(ifu_exu_rs2_s[4:3]!=2'b0 ? 8'd64:8'd0);
258
wire [7:0] rdaddr2={1'b0,rdaddr2_wa}+(ifu_exu_rs3_s[4:3]!=2'b0 ? 8'd64:8'd0);
259
 
260
regfile_1w_4r regfile_thr0(
261
   .clk(rclk),
262
 
263
   .din(wen0_1 ? byp_irf_rd_data_w2:byp_irf_rd_data_w),
264
   .wraddr(wen0_1 ? wraddr1:wraddr0),
265
   .wren(wen0_0 || wen0_1),
266
   .rdaddr0(rdaddr0),
267
   .rdaddr1(rdaddr1),
268
   .rdaddr2(rdaddr2),
269
   .rdaddr3({rdaddr2[7:1],1'b1}),
270
   .rd0(ifu_exu_ren1_s && (ifu_exu_tid_s2==2'b00)),
271
   .rd1(ifu_exu_ren2_s && (ifu_exu_tid_s2==2'b00)),
272
   .rd2(ifu_exu_ren3_s && (ifu_exu_tid_s2==2'b00)),
273
   .rd3(ifu_exu_ren3_s && (ifu_exu_tid_s2==2'b00)),
274
 
275
   .dout0(dout0_0),
276
   .dout1(dout0_1),
277
   .dout2(dout0_2),
278
   .dout3(dout0_3)
279
);
280
 
281
regfile_1w_4r regfile_thr1(
282
   .clk(rclk),
283
 
284
   .din(wen1_1 ? byp_irf_rd_data_w2:byp_irf_rd_data_w),
285
   .wraddr(wen1_1 ? wraddr1:wraddr0),
286
   .wren(wen1_0 || wen1_1),
287
   .rdaddr0(rdaddr0),
288
   .rdaddr1(rdaddr1),
289
   .rdaddr2(rdaddr2),
290
   .rdaddr3({rdaddr2[7:1],1'b1}),
291
   .rd0(ifu_exu_ren1_s && (ifu_exu_tid_s2==2'b01)),
292
   .rd1(ifu_exu_ren2_s && (ifu_exu_tid_s2==2'b01)),
293
   .rd2(ifu_exu_ren3_s && (ifu_exu_tid_s2==2'b01)),
294
   .rd3(ifu_exu_ren3_s && (ifu_exu_tid_s2==2'b01)),
295
 
296
   .dout0(dout1_0),
297
   .dout1(dout1_1),
298
   .dout2(dout1_2),
299
   .dout3(dout1_3)
300
);
301
 
302
regfile_1w_4r regfile_thr2(
303
   .clk(rclk),
304
 
305
   .din(wen2_1 ? byp_irf_rd_data_w2:byp_irf_rd_data_w),
306
   .wraddr(wen2_1 ? wraddr1:wraddr0),
307
   .wren(wen2_0 || wen2_1),
308
   .rdaddr0(rdaddr0),
309
   .rdaddr1(rdaddr1),
310
   .rdaddr2(rdaddr2),
311
   .rdaddr3({rdaddr2[7:1],1'b1}),
312
   .rd0(ifu_exu_ren1_s && (ifu_exu_tid_s2==2'b10)),
313
   .rd1(ifu_exu_ren2_s && (ifu_exu_tid_s2==2'b10)),
314
   .rd2(ifu_exu_ren3_s && (ifu_exu_tid_s2==2'b10)),
315
   .rd3(ifu_exu_ren3_s && (ifu_exu_tid_s2==2'b10)),
316
 
317
   .dout0(dout2_0),
318
   .dout1(dout2_1),
319
   .dout2(dout2_2),
320
   .dout3(dout2_3)
321
);
322
 
323
regfile_1w_4r regfile_thr3(
324
   .clk(rclk),
325
 
326
   .din(wen3_1 ? byp_irf_rd_data_w2:byp_irf_rd_data_w),
327
   .wraddr(wen3_1 ? wraddr1:wraddr0),
328
   .wren(wen3_0 || wen3_1),
329
   .rdaddr0(rdaddr0),
330
   .rdaddr1(rdaddr1),
331
   .rdaddr2(rdaddr2),
332
   .rdaddr3({rdaddr2[7:1],1'b1}),
333
   .rd0(ifu_exu_ren1_s && (ifu_exu_tid_s2==2'b11)),
334
   .rd1(ifu_exu_ren2_s && (ifu_exu_tid_s2==2'b11)),
335
   .rd2(ifu_exu_ren3_s && (ifu_exu_tid_s2==2'b11)),
336
   .rd3(ifu_exu_ren3_s && (ifu_exu_tid_s2==2'b11)),
337
 
338
   .dout0(dout3_0),
339
   .dout1(dout3_1),
340
   .dout2(dout3_2),
341
   .dout3(dout3_3)
342
);
343
 
344
always @( * )
345
   case(ifu_exu_tid_s2_d)
346
      2'b00:
347
         begin
348
            irf_byp_rs1_data_d_l<=~dout0_0;
349
            irf_byp_rs2_data_d_l<=~dout0_1;
350
            irf_byp_rs3_data_d_l<=~dout0_2;
351
            irf_byp_rs3h_data_d_l<=~dout0_3[31:0];
352
         end
353
      2'b01:
354
         begin
355
            irf_byp_rs1_data_d_l<=~dout1_0;
356
            irf_byp_rs2_data_d_l<=~dout1_1;
357
            irf_byp_rs3_data_d_l<=~dout1_2;
358
            irf_byp_rs3h_data_d_l<=~dout1_3[31:0];
359
         end
360
      2'b10:
361
         begin
362
            irf_byp_rs1_data_d_l<=~dout2_0;
363
            irf_byp_rs2_data_d_l<=~dout2_1;
364
            irf_byp_rs3_data_d_l<=~dout2_2;
365
            irf_byp_rs3h_data_d_l<=~dout2_3[31:0];
366
         end
367
      2'b11:
368
         begin
369
            irf_byp_rs1_data_d_l<=~dout3_0;
370
            irf_byp_rs2_data_d_l<=~dout3_1;
371
            irf_byp_rs3_data_d_l<=~dout3_2;
372
            irf_byp_rs3h_data_d_l<=~dout3_3[31:0];
373
         end
374
   endcase
375
 
376
endmodule

powered by: WebSVN 2.1.0

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