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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [bw_r_irf.v] - Blame information for rev 113

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 95 fafa1971
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: bw_r_irf.v
4
// Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6
// 
7
// The above named program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public
9
// License version 2 as published by the Free Software Foundation.
10
// 
11
// The above named program is distributed in the hope that it will be 
12
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
// General Public License for more details.
15
// 
16
// You should have received a copy of the GNU General Public
17
// License along with this work; if not, write to the Free Software
18
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
// 
20
// ========== Copyright Header End ============================================
21 113 albert.wat
`ifdef SIMPLY_RISC_TWEAKS
22
`define SIMPLY_RISC_SCANIN .si(0)
23
`else
24
`define SIMPLY_RISC_SCANIN .si()
25
`endif
26 95 fafa1971
////////////////////////////////////////////////////////////////////////
27
/*
28
//  Module Name: bw_r_irf
29
//      Description: Register file with 3 read ports and 2 write ports.  Has
30
//                              32 registers per thread with 4 threads.  Reading and writing
31
//                              the same register concurrently produces x.
32
*/
33
 
34
//FPGA_SYN enables all FPGA related modifications
35 113 albert.wat
`ifdef FPGA_SYN
36
`define FPGA_SYN_IRF
37
`endif
38 95 fafa1971
 
39
 
40 113 albert.wat
`ifdef FPGA_SYN_IRF
41
`ifdef FPGA_SYN_1THREAD
42
module bw_r_irf (/*AUTOARG*/
43
   // Outputs
44
   so, irf_byp_rs1_data_d_l, irf_byp_rs2_data_d_l,
45
   irf_byp_rs3_data_d_l, irf_byp_rs3h_data_d_l,
46
   // Inputs
47
   rclk, reset_l, si, se, sehold, rst_tri_en, ifu_exu_tid_s2,
48
   ifu_exu_rs1_s, ifu_exu_rs2_s, ifu_exu_rs3_s, ifu_exu_ren1_s,
49
   ifu_exu_ren2_s, ifu_exu_ren3_s, ecl_irf_wen_w, ecl_irf_wen_w2,
50
   ecl_irf_rd_m, ecl_irf_rd_g, byp_irf_rd_data_w, byp_irf_rd_data_w2,
51
   ecl_irf_tid_m, ecl_irf_tid_g, rml_irf_old_lo_cwp_e,
52
   rml_irf_new_lo_cwp_e, rml_irf_old_e_cwp_e, rml_irf_new_e_cwp_e,
53
   rml_irf_swap_even_e, rml_irf_swap_odd_e, rml_irf_swap_local_e,
54
   rml_irf_kill_restore_w, rml_irf_cwpswap_tid_e, rml_irf_old_agp,
55
   rml_irf_new_agp, rml_irf_swap_global, rml_irf_global_tid
56
   ) ;
57
   input rclk;
58
   input reset_l;
59
   input si;
60
   input se;
61
   input sehold;
62
   input rst_tri_en;
63
   input [1:0]  ifu_exu_tid_s2;  // s stage thread
64
   input [4:0]  ifu_exu_rs1_s;  // source addresses
65
   input [4:0]  ifu_exu_rs2_s;
66
   input [4:0]  ifu_exu_rs3_s;
67
   input ifu_exu_ren1_s;        // read enables for all 3 ports
68
   input ifu_exu_ren2_s;
69
   input ifu_exu_ren3_s;
70
   input ecl_irf_wen_w;        // write enables for both write ports
71
   input ecl_irf_wen_w2;
72
   input [4:0]  ecl_irf_rd_m;   // w destination
73
   input [4:0]  ecl_irf_rd_g;  // w2 destination
74
   input [71:0] byp_irf_rd_data_w;// write data from w1
75
   input [71:0] byp_irf_rd_data_w2;     // write data from w2
76
   input [1:0]  ecl_irf_tid_m;  // w stage thread
77
   input [1:0]  ecl_irf_tid_g; // w2 thread
78 95 fafa1971
 
79 113 albert.wat
   input [2:0]  rml_irf_old_lo_cwp_e;  // current window pointer for locals and odds
80
   input [2:0]  rml_irf_new_lo_cwp_e;  // target window pointer for locals and odds
81
   input [2:1]  rml_irf_old_e_cwp_e;  // current window pointer for evens
82
   input [2:1]  rml_irf_new_e_cwp_e;  // target window pointer for evens
83
   input        rml_irf_swap_even_e;
84
   input        rml_irf_swap_odd_e;
85
   input        rml_irf_swap_local_e;
86
   input        rml_irf_kill_restore_w;
87
   input [1:0]  rml_irf_cwpswap_tid_e;
88 95 fafa1971
 
89 113 albert.wat
   input [1:0]  rml_irf_old_agp; // alternate global pointer
90
   input [1:0]  rml_irf_new_agp; // alternate global pointer
91
   input        rml_irf_swap_global;
92
   input [1:0]  rml_irf_global_tid;
93
 
94
   output       so;
95
   output [71:0] irf_byp_rs1_data_d_l;
96
   output [71:0] irf_byp_rs2_data_d_l;
97
   output [71:0] irf_byp_rs3_data_d_l;
98
   output [31:0] irf_byp_rs3h_data_d_l;
99 95 fafa1971
 
100 113 albert.wat
   wire [71:0] irf_byp_rs1_data_d;
101
   wire [71:0] irf_byp_rs2_data_d;
102
   wire [71:0] irf_byp_rs3_data_d;
103
   wire [71:0] irf_byp_rs3h_data_d;
104 95 fafa1971
 
105 113 albert.wat
   wire [1:0]  ecl_irf_tid_w;  // w stage thread
106
   wire [1:0]  ecl_irf_tid_w2; // w2 thread
107
   wire [4:0]  ecl_irf_rd_w;   // w destination
108
   wire [4:0]  ecl_irf_rd_w2;  // w2 destination
109
   wire [1:0]  ifu_exu_thr_d;  // d stage thread
110
   wire ifu_exu_ren1_d;        // read enables for all 3 ports
111
   wire ifu_exu_ren2_d;
112
   wire ifu_exu_ren3_d;
113
   wire [4:0]  ifu_exu_rs1_d;  // source addresses
114
   wire [4:0]  ifu_exu_rs2_d;
115
   wire [4:0]  ifu_exu_rs3_d;
116
   wire [6:0]    thr_rs1;       // these 5 are a combination of the thr and reg
117
   wire [6:0]    thr_rs2;       // so that comparison can be done more easily
118
   wire [6:0]    thr_rs3;
119
   wire [6:0]    thr_rs3h;
120
   wire [6:0]    thr_rd_w;
121
   wire [6:0]    thr_rd_w2;
122 95 fafa1971
 
123 113 albert.wat
   reg [1:0] cwpswap_tid_m;
124
   reg [1:0] cwpswap_tid_w;
125
   reg [2:0] old_lo_cwp_m;
126
   reg [2:0] new_lo_cwp_m;
127
   reg [2:0] new_lo_cwp_w;
128
   reg [1:0] old_e_cwp_m;
129
   reg [1:0] new_e_cwp_m;
130
   reg [1:0] new_e_cwp_w;
131
   reg       swap_local_m;
132
   reg       swap_local_w;
133
   reg       swap_even_m;
134
   reg       swap_even_w;
135
   reg       swap_odd_m;
136
   reg       swap_odd_w;
137
   reg       kill_restore_d1;
138
   reg        swap_global_d1;
139
   reg        swap_global_d2;
140
   reg [1:0]  global_tid_d1;
141
   reg [1:0]  global_tid_d2;
142
   reg [1:0] old_agp_d1,
143
             new_agp_d1,
144
             new_agp_d2;
145 95 fafa1971
 
146 113 albert.wat
`ifdef FPGA_SYN_SAVE_BRAM
147
   wire [71:0] active_win_thr_rd_w_neg;
148
   wire [71:0] active_win_thr_rd_w2_neg;
149
   wire [6:0]  thr_rd_w_neg;
150
   wire [6:0]  thr_rd_w2_neg;
151
   wire        active_win_thr_rd_w_neg_wr_en;
152
   wire        active_win_thr_rd_w2_neg_wr_en;
153
   wire        rst_tri_en_neg;
154
`else
155
   reg [71:0] active_win_thr_rd_w_neg;
156
   reg [71:0] active_win_thr_rd_w2_neg;
157
   reg [6:0]  thr_rd_w_neg;
158
   reg [6:0]  thr_rd_w2_neg;
159
   reg        active_win_thr_rd_w_neg_wr_en;
160
   reg        active_win_thr_rd_w2_neg_wr_en;
161
   reg        rst_tri_en_neg;
162
`endif
163
 
164
   wire          se;
165
   wire          clk;
166
//   assign        clk = rclk & reset_l;
167
   assign        clk = rclk;
168
 
169
   wire          ren1_s;
170
   wire          ren2_s;
171
   wire          ren3_s;
172
   wire [4:0]    rs1_s;
173
   wire [4:0]    rs2_s;
174
   wire [4:0]    rs3_s;
175
   wire [1:0]    tid_s;
176
   wire [1:0]    tid_g;
177
   wire [1:0]    tid_m;
178
   wire [4:0]    rd_m;
179
   wire [4:0]    rd_g;
180
   wire          kill_restore_w;
181
   wire          swap_global_d1_vld;
182
   wire          swap_local_m_vld;
183
   wire          swap_even_m_vld;
184
   wire          swap_odd_m_vld;
185 95 fafa1971
 
186 113 albert.wat
   assign {ren1_s,ren2_s,ren3_s,rs1_s[4:0],rs2_s[4:0],rs3_s[4:0],tid_s[1:0],tid_g[1:0],tid_m[1:0],
187
           rd_m[4:0], rd_g[4:0]} = (sehold)?
188
          {ifu_exu_ren1_d,ifu_exu_ren2_d,ifu_exu_ren3_d,ifu_exu_rs1_d[4:0],ifu_exu_rs2_d[4:0],
189
           ifu_exu_rs3_d[4:0],ifu_exu_thr_d[1:0],ecl_irf_tid_w2[1:0],ecl_irf_tid_w[1:0],
190
           ecl_irf_rd_w[4:0],ecl_irf_rd_w2[4:0]}:
191
          {ifu_exu_ren1_s,ifu_exu_ren2_s,ifu_exu_ren3_s,ifu_exu_rs1_s[4:0],ifu_exu_rs2_s[4:0],
192
           ifu_exu_rs3_s[4:0],ifu_exu_tid_s2[1:0],ecl_irf_tid_g[1:0],ecl_irf_tid_m[1:0],
193
           ecl_irf_rd_m[4:0],ecl_irf_rd_g[4:0]};
194
   // Pipeline flops for irf control signals
195
   dff_s dff_ren1_s2d(.din(ren1_s), .clk(clk), .q(ifu_exu_ren1_d), .se(se),
196
                    `SIMPLY_RISC_SCANIN, .so());
197
   dff_s dff_ren2_s2d(.din(ren2_s), .clk(clk), .q(ifu_exu_ren2_d), .se(se),
198
                    `SIMPLY_RISC_SCANIN, .so());
199
   dff_s dff_ren3_s2d(.din(ren3_s), .clk(clk), .q(ifu_exu_ren3_d), .se(se),
200
                    `SIMPLY_RISC_SCANIN, .so());
201
   dff_s #5 dff_rs1_s2d(.din(rs1_s[4:0]), .clk(clk), .q(ifu_exu_rs1_d[4:0]), .se(se),
202
                      `SIMPLY_RISC_SCANIN,.so());
203
   dff_s #5 dff_rs2_s2d(.din(rs2_s[4:0]), .clk(clk), .q(ifu_exu_rs2_d[4:0]), .se(se),
204
                      `SIMPLY_RISC_SCANIN,.so());
205
   dff_s #5 dff_rs3_s2d(.din(rs3_s[4:0]), .clk(clk), .q(ifu_exu_rs3_d[4:0]), .se(se),
206
                      `SIMPLY_RISC_SCANIN,.so());
207
   dff_s #2 dff_thr_s2d(.din(tid_s[1:0]), .clk(clk), .q(ifu_exu_thr_d[1:0]), .se(se),
208
                      `SIMPLY_RISC_SCANIN,.so());
209
   dff_s #2 dff_thr_g2w2(.din(tid_g[1:0]), .clk(clk), .q(ecl_irf_tid_w2[1:0]), .se(se),
210
                      `SIMPLY_RISC_SCANIN,.so());
211
   dff_s #2 dff_thr_m2w(.din(tid_m[1:0]), .clk(clk), .q(ecl_irf_tid_w[1:0]), .se(se),
212
                      `SIMPLY_RISC_SCANIN,.so());
213
   dff_s #5 dff_rd_m2w(.din(rd_m[4:0]), .clk(clk), .q(ecl_irf_rd_w[4:0]), .se(se),
214
                      `SIMPLY_RISC_SCANIN,.so());
215
   dff_s #5 dff_rd_g2w2(.din(rd_g[4:0]), .clk(clk), .q(ecl_irf_rd_w2[4:0]), .se(se),
216
                      `SIMPLY_RISC_SCANIN,.so());
217
 
218
   // Concatenate the thread and rs1/rd bits together
219
   assign        thr_rs1[6:0] = {ifu_exu_thr_d, ifu_exu_rs1_d};
220
   assign        thr_rs2[6:0] = {ifu_exu_thr_d, ifu_exu_rs2_d};
221
   assign        thr_rs3[6:0] = {ifu_exu_thr_d, ifu_exu_rs3_d[4:0]};
222
   assign        thr_rs3h[6:0] = {ifu_exu_thr_d[1:0], ifu_exu_rs3_d[4:1], 1'b1};
223
   assign        thr_rd_w[6:0] = {ecl_irf_tid_w, ecl_irf_rd_w};
224
   assign        thr_rd_w2[6:0] = {ecl_irf_tid_w2, ecl_irf_rd_w2};
225 95 fafa1971
 
226 113 albert.wat
   // Active low outputs
227
   assign        irf_byp_rs1_data_d_l[71:0] = ~irf_byp_rs1_data_d[71:0];
228
   assign        irf_byp_rs2_data_d_l[71:0] = ~irf_byp_rs2_data_d[71:0];
229
   assign        irf_byp_rs3_data_d_l[71:0] = ~irf_byp_rs3_data_d[71:0];
230
   assign        irf_byp_rs3h_data_d_l[31:0] = ~irf_byp_rs3h_data_d[31:0];
231
 
232
/////////////////////////////////////////////////////////////////
233
///  Write ports
234
////////////////////////////////////////////////////////////////
235
   // This is a latch that works if both wen is high and clk is low
236 95 fafa1971
 
237 113 albert.wat
`ifdef FPGA_SYN_SAVE_BRAM
238
  assign rst_tri_en_neg = rst_tri_en;
239
  assign active_win_thr_rd_w_neg = byp_irf_rd_data_w;
240
  assign active_win_thr_rd_w2_neg = byp_irf_rd_data_w2;
241
  assign thr_rd_w_neg = thr_rd_w;
242
  assign thr_rd_w2_neg = thr_rd_w2;
243
  assign active_win_thr_rd_w_neg_wr_en = ecl_irf_wen_w & (thr_rd_w[4:0] != 5'b0);
244
  assign active_win_thr_rd_w2_neg_wr_en = ecl_irf_wen_w2 & (thr_rd_w2[4:0] != 5'b0);
245
`else
246 95 fafa1971
 
247 113 albert.wat
   always @(negedge clk) begin
248
      rst_tri_en_neg <= rst_tri_en;
249
      // write conflict results in X written to destination
250
      if (ecl_irf_wen_w & ecl_irf_wen_w2 & (thr_rd_w[6:0] == thr_rd_w2[6:0])) begin
251
         active_win_thr_rd_w_neg <= {72{1'bx}};
252
         thr_rd_w_neg <= thr_rd_w;
253
         active_win_thr_rd_w_neg_wr_en <= 1'b1;
254
         active_win_thr_rd_w2_neg_wr_en <= 1'b0;
255
      end
256
      else begin
257
         // W1 write port
258
         if (ecl_irf_wen_w & (thr_rd_w[4:0] != 5'b0)) begin
259
            active_win_thr_rd_w_neg <= byp_irf_rd_data_w;
260
            thr_rd_w_neg <= thr_rd_w;
261
            active_win_thr_rd_w_neg_wr_en <= 1'b1;
262
         end
263
         else
264
           active_win_thr_rd_w_neg_wr_en <= 1'b0;
265
 
266
         // W2 write port
267
         if (ecl_irf_wen_w2 & (thr_rd_w2[4:0] != 5'b0)) begin
268
            active_win_thr_rd_w2_neg <= byp_irf_rd_data_w2;
269
            thr_rd_w2_neg <= thr_rd_w2;
270
            active_win_thr_rd_w2_neg_wr_en <= 1'b1;
271
         end
272
         else
273
           active_win_thr_rd_w2_neg_wr_en <= 1'b0;
274
      end
275
   end
276 95 fafa1971
 
277 113 albert.wat
`endif
278
 
279 95 fafa1971
 
280
 
281 113 albert.wat
/* MOVED TO CMP ENVIRONMENT
282
   initial begin
283
      // Hardcode R0 to zero
284
      active_window[{2'b00, 5'b00000}] = 72'b0;
285
      active_window[{2'b01, 5'b00000}] = 72'b0;
286
      active_window[{2'b10, 5'b00000}] = 72'b0;
287
      active_window[{2'b11, 5'b00000}] = 72'b0;
288
   end
289
*/
290
   //////////////////////////////////////////////////
291
   // Window management logic
292
   //////////////////////////////////////////////////
293
   // Pipeline flops for control signals
294 95 fafa1971
 
295 113 albert.wat
   // cwp swap signals
296
   assign kill_restore_w = (sehold)? kill_restore_d1: rml_irf_kill_restore_w;
297
   assign swap_local_m_vld = swap_local_m & ~rst_tri_en;
298
   assign swap_odd_m_vld = swap_odd_m & ~rst_tri_en;
299
   assign swap_even_m_vld = swap_even_m & ~rst_tri_en;
300
   assign swap_global_d1_vld = swap_global_d1 & ~rst_tri_en;
301
 
302
   always @ (posedge clk) begin
303
      cwpswap_tid_m[1:0] <= (sehold)? cwpswap_tid_m[1:0]: rml_irf_cwpswap_tid_e[1:0];
304
      cwpswap_tid_w[1:0] <= cwpswap_tid_m[1:0];
305
      old_lo_cwp_m[2:0] <= (sehold)? old_lo_cwp_m[2:0]: rml_irf_old_lo_cwp_e[2:0];
306
      new_lo_cwp_m[2:0] <= (sehold)? new_lo_cwp_m[2:0]: rml_irf_new_lo_cwp_e[2:0];
307
      new_lo_cwp_w[2:0] <= new_lo_cwp_m[2:0];
308
      old_e_cwp_m[1:0] <= (sehold)? old_e_cwp_m[1:0]: rml_irf_old_e_cwp_e[2:1];
309
      new_e_cwp_m[1:0] <= (sehold)? new_e_cwp_m[1:0]: rml_irf_new_e_cwp_e[2:1];
310
      new_e_cwp_w[1:0] <= new_e_cwp_m[1:0];
311
      swap_local_m <= (sehold)? swap_local_m & rst_tri_en: rml_irf_swap_local_e;
312
      swap_local_w <= swap_local_m_vld;
313
      swap_odd_m <= (sehold)? swap_odd_m & rst_tri_en: rml_irf_swap_odd_e;
314
      swap_odd_w <= swap_odd_m_vld;
315
      swap_even_m <= (sehold)? swap_even_m & rst_tri_en: rml_irf_swap_even_e;
316
      swap_even_w <= swap_even_m_vld;
317
      kill_restore_d1 <= kill_restore_w;
318
   end
319
   // global swap signals    
320
   always @ (posedge clk) begin
321
      swap_global_d1 <= (sehold)? swap_global_d1 & rst_tri_en: rml_irf_swap_global;
322
      swap_global_d2 <= swap_global_d1_vld;
323
      global_tid_d1[1:0] <= (sehold)? global_tid_d1[1:0]: rml_irf_global_tid[1:0];
324
      global_tid_d2[1:0] <= global_tid_d1[1:0];
325
      old_agp_d1[1:0] <= (sehold)? old_agp_d1[1:0]: rml_irf_old_agp[1:0];
326
      new_agp_d1[1:0] <= (sehold)? new_agp_d1[1:0]: rml_irf_new_agp[1:0];
327
      new_agp_d2[1:0] <= new_agp_d1[1:0];
328
   end
329 95 fafa1971
 
330 113 albert.wat
  wire wr_en  = active_win_thr_rd_w_neg_wr_en & (~rst_tri_en | ~rst_tri_en_neg);
331
  wire wr_en2 = active_win_thr_rd_w2_neg_wr_en & (~rst_tri_en | ~rst_tri_en_neg);
332 95 fafa1971
 
333 113 albert.wat
// synthesis translate_off
334
  always @(posedge clk) begin
335
    if(wr_en)
336
      $display("Write Port 1: %h %h", active_win_thr_rd_w_neg, thr_rd_w_neg );
337
    if(wr_en2)
338
      $display("Write Port 2: %h %h", active_win_thr_rd_w2_neg, thr_rd_w2_neg );
339
    if(ifu_exu_ren1_d) begin
340
      @(posedge clk);
341
      $display("Read Port 1: %h %h", irf_byp_rs1_data_d, thr_rs1);
342
    end
343
    if(ifu_exu_ren2_d) begin
344
      @(posedge clk);
345
      $display("Read Port 2: %h %h", irf_byp_rs2_data_d, thr_rs2);
346
    end
347
    if(ifu_exu_ren3_d) begin
348
      @(posedge clk);
349
      $display("Read Port 3: %h %h", irf_byp_rs3_data_d, thr_rs3);
350
    end
351
  end
352
//synthesis translate_on
353
 
354
bw_r_irf_core bw_r_irf_core (
355
        .clk                    (clk),
356
        .ifu_exu_ren1_d         (ifu_exu_ren1_d),
357
        .ifu_exu_ren2_d         (ifu_exu_ren2_d),
358
        .ifu_exu_ren3_d         (ifu_exu_ren3_d),
359
        .thr_rs1                (thr_rs1),
360
        .thr_rs2                (thr_rs2),
361
        .thr_rs3                (thr_rs3),
362
        .thr_rs3h               (thr_rs3h),
363
        .irf_byp_rs1_data_d     (irf_byp_rs1_data_d),
364
        .irf_byp_rs2_data_d     (irf_byp_rs2_data_d),
365
        .irf_byp_rs3_data_d     (irf_byp_rs3_data_d),
366
        .irf_byp_rs3h_data_d    (irf_byp_rs3h_data_d),
367
        .wr_en                  (wr_en),
368
        .wr_en2                 (wr_en2),
369
        .active_win_thr_rd_w_neg(active_win_thr_rd_w_neg),
370
        .active_win_thr_rd_w2_neg(active_win_thr_rd_w2_neg),
371
        .thr_rd_w_neg           (thr_rd_w_neg),
372
        .thr_rd_w2_neg          (thr_rd_w2_neg),
373
        .swap_global_d1_vld     (swap_global_d1_vld),
374
        .swap_global_d2         (swap_global_d2),
375
        .global_tid_d1          (global_tid_d1),
376
        .global_tid_d2          (global_tid_d2),
377
        .old_agp_d1             (old_agp_d1),
378
        .new_agp_d2             (new_agp_d2),
379
        .swap_local_m_vld       (swap_local_m_vld),
380
        .swap_local_w           (swap_local_w),
381
        .old_lo_cwp_m           (old_lo_cwp_m),
382
        .new_lo_cwp_w           (new_lo_cwp_w),
383
        .swap_even_m_vld        (swap_even_m_vld),
384
        .swap_even_w            (swap_even_w),
385
        .old_e_cwp_m            (old_e_cwp_m),
386
        .new_e_cwp_w            (new_e_cwp_w),
387
        .swap_odd_m_vld         (swap_odd_m_vld),
388
        .swap_odd_w             (swap_odd_w),
389
        .cwpswap_tid_m          (cwpswap_tid_m),
390
        .cwpswap_tid_w          (cwpswap_tid_w),
391
        .kill_restore_w         (kill_restore_w)
392
        );
393 95 fafa1971
 
394 113 albert.wat
endmodule // bw_r_irf
395 95 fafa1971
 
396 113 albert.wat
module bw_r_irf_core(
397
        clk,
398
        ifu_exu_ren1_d,
399
        ifu_exu_ren2_d,
400
        ifu_exu_ren3_d,
401
        thr_rs1,
402
        thr_rs2,
403
        thr_rs3,
404
        thr_rs3h,
405
        irf_byp_rs1_data_d,
406
        irf_byp_rs2_data_d,
407
        irf_byp_rs3_data_d,
408
        irf_byp_rs3h_data_d,
409
        wr_en,
410
        wr_en2,
411
        active_win_thr_rd_w_neg,
412
        active_win_thr_rd_w2_neg,
413
        thr_rd_w_neg,
414
        thr_rd_w2_neg,
415
        swap_global_d1_vld,
416
        swap_global_d2,
417
        global_tid_d1,
418
        global_tid_d2,
419
        old_agp_d1,
420
        new_agp_d2,
421
        swap_local_m_vld,
422
        swap_local_w,
423
        old_lo_cwp_m,
424
        new_lo_cwp_w,
425
        swap_even_m_vld,
426
        swap_even_w,
427
        old_e_cwp_m,
428
        new_e_cwp_w,
429
        swap_odd_m_vld,
430
        swap_odd_w,
431
        cwpswap_tid_m,
432
        cwpswap_tid_w,
433
        kill_restore_w);
434 95 fafa1971
 
435
 
436 113 albert.wat
        input           clk;
437
        input           ifu_exu_ren1_d;
438
        input           ifu_exu_ren2_d;
439
        input           ifu_exu_ren3_d;
440 95 fafa1971
 
441 113 albert.wat
        input   [6:0]    thr_rs1;
442
        input   [6:0]    thr_rs2;
443
        input   [6:0]    thr_rs3;
444
        input   [6:0]    thr_rs3h;
445 95 fafa1971
 
446 113 albert.wat
        output  [71:0]   irf_byp_rs1_data_d;
447
        output  [71:0]   irf_byp_rs2_data_d;
448
        output  [71:0]   irf_byp_rs3_data_d;
449
        output  [71:0]   irf_byp_rs3h_data_d;
450 95 fafa1971
 
451 113 albert.wat
 
452
        reg     [71:0]   irf_byp_rs1_data_d;
453
        reg     [71:0]   irf_byp_rs2_data_d;
454
        reg     [71:0]   irf_byp_rs3_data_d;
455
        reg     [71:0]   irf_byp_rs3h_data_d;
456 95 fafa1971
 
457 113 albert.wat
        input           wr_en;
458
        input           wr_en2;
459
        input   [71:0]   active_win_thr_rd_w_neg;
460
        input   [71:0]   active_win_thr_rd_w2_neg;
461
        input   [6:0]    thr_rd_w_neg;
462
        input   [6:0]    thr_rd_w2_neg;
463 95 fafa1971
 
464 113 albert.wat
        input           swap_global_d1_vld;
465
        input           swap_global_d2;
466
        input   [1:0]    global_tid_d1;
467
        input   [1:0]    global_tid_d2;
468
        input   [1:0]    old_agp_d1;
469
        input   [1:0]    new_agp_d2;
470 95 fafa1971
 
471 113 albert.wat
        input           swap_local_m_vld;
472
        input           swap_local_w;
473
        input   [2:0]    old_lo_cwp_m;
474
        input   [2:0]    new_lo_cwp_w;
475 95 fafa1971
 
476 113 albert.wat
        input           swap_even_m_vld;
477
        input           swap_even_w;
478
        input   [1:0]    old_e_cwp_m;
479
        input   [1:0]    new_e_cwp_w;
480 95 fafa1971
 
481 113 albert.wat
        input           swap_odd_m_vld;
482
        input           swap_odd_w;
483 95 fafa1971
 
484 113 albert.wat
        input   [1:0]    cwpswap_tid_m;
485
        input   [1:0]    cwpswap_tid_w;
486 95 fafa1971
 
487 113 albert.wat
        input           kill_restore_w;
488 95 fafa1971
 
489
 
490 113 albert.wat
        wire    [71:0]   rd_data00;
491
        wire    [71:0]   rd_data01;
492
        wire    [71:0]   rd_data02;
493
        wire    [71:0]   rd_data03;
494
        wire    [71:0]   rd_data04;
495
        wire    [71:0]   rd_data05;
496
        wire    [71:0]   rd_data06;
497
        wire    [71:0]   rd_data07;
498
        wire    [71:0]   rd_data08;
499
        wire    [71:0]   rd_data09;
500
        wire    [71:0]   rd_data10;
501
        wire    [71:0]   rd_data11;
502
        wire    [71:0]   rd_data12;
503
        wire    [71:0]   rd_data13;
504
        wire    [71:0]   rd_data14;
505
        wire    [71:0]   rd_data15;
506
        wire    [71:0]   rd_data16;
507
        wire    [71:0]   rd_data17;
508
        wire    [71:0]   rd_data18;
509
        wire    [71:0]   rd_data19;
510
        wire    [71:0]   rd_data20;
511
        wire    [71:0]   rd_data21;
512
        wire    [71:0]   rd_data22;
513
        wire    [71:0]   rd_data23;
514
        wire    [71:0]   rd_data24;
515
        wire    [71:0]   rd_data25;
516
        wire    [71:0]   rd_data26;
517
        wire    [71:0]   rd_data27;
518
        wire    [71:0]   rd_data28;
519
        wire    [71:0]   rd_data29;
520
        wire    [71:0]   rd_data30;
521
        wire    [71:0]   rd_data31;
522 95 fafa1971
 
523 113 albert.wat
// synthesis translate_off
524
always @(posedge clk) begin
525
        if(ifu_exu_ren1_d | ifu_exu_ren2_d | ifu_exu_ren3_d) begin
526
                if(thr_rs1[6:5] != 2'b00) begin
527
                        $display("Accessing thread # other than 0");
528
                        $finish;
529
                end
530
        end
531
end
532
// synthesis translate_on
533
 
534
   //reg [71:0]    active_window [127:0];// 32x4 72 bit registers
535 95 fafa1971
 
536 113 albert.wat
        always @(negedge clk)
537
          if(ifu_exu_ren1_d) //comes from a posedge clk
538
          case(thr_rs1[4:0])
539
            5'b00000: irf_byp_rs1_data_d <= rd_data00;
540
            5'b00001: irf_byp_rs1_data_d <= rd_data01;
541
            5'b00010: irf_byp_rs1_data_d <= rd_data02;
542
            5'b00011: irf_byp_rs1_data_d <= rd_data03;
543
            5'b00100: irf_byp_rs1_data_d <= rd_data04;
544
            5'b00101: irf_byp_rs1_data_d <= rd_data05;
545
            5'b00110: irf_byp_rs1_data_d <= rd_data06;
546
            5'b00111: irf_byp_rs1_data_d <= rd_data07;
547
            5'b01000: irf_byp_rs1_data_d <= rd_data08;
548
            5'b01001: irf_byp_rs1_data_d <= rd_data09;
549
            5'b01010: irf_byp_rs1_data_d <= rd_data10;
550
            5'b01011: irf_byp_rs1_data_d <= rd_data11;
551
            5'b01100: irf_byp_rs1_data_d <= rd_data12;
552
            5'b01101: irf_byp_rs1_data_d <= rd_data13;
553
            5'b01110: irf_byp_rs1_data_d <= rd_data14;
554
            5'b01111: irf_byp_rs1_data_d <= rd_data15;
555
            5'b10000: irf_byp_rs1_data_d <= rd_data16;
556
            5'b10001: irf_byp_rs1_data_d <= rd_data17;
557
            5'b10010: irf_byp_rs1_data_d <= rd_data18;
558
            5'b10011: irf_byp_rs1_data_d <= rd_data19;
559
            5'b10100: irf_byp_rs1_data_d <= rd_data20;
560
            5'b10101: irf_byp_rs1_data_d <= rd_data21;
561
            5'b10110: irf_byp_rs1_data_d <= rd_data22;
562
            5'b10111: irf_byp_rs1_data_d <= rd_data23;
563
            5'b11000: irf_byp_rs1_data_d <= rd_data24;
564
            5'b11001: irf_byp_rs1_data_d <= rd_data25;
565
            5'b11010: irf_byp_rs1_data_d <= rd_data26;
566
            5'b11011: irf_byp_rs1_data_d <= rd_data27;
567
            5'b11100: irf_byp_rs1_data_d <= rd_data28;
568
            5'b11101: irf_byp_rs1_data_d <= rd_data29;
569
            5'b11110: irf_byp_rs1_data_d <= rd_data30;
570
            5'b11111: irf_byp_rs1_data_d <= rd_data31;
571
          endcase
572 95 fafa1971
 
573 113 albert.wat
        always @(negedge clk)
574
          if(ifu_exu_ren2_d)
575
          case(thr_rs2[4:0])
576
            5'b00000: irf_byp_rs2_data_d <= rd_data00;
577
            5'b00001: irf_byp_rs2_data_d <= rd_data01;
578
            5'b00010: irf_byp_rs2_data_d <= rd_data02;
579
            5'b00011: irf_byp_rs2_data_d <= rd_data03;
580
            5'b00100: irf_byp_rs2_data_d <= rd_data04;
581
            5'b00101: irf_byp_rs2_data_d <= rd_data05;
582
            5'b00110: irf_byp_rs2_data_d <= rd_data06;
583
            5'b00111: irf_byp_rs2_data_d <= rd_data07;
584
            5'b01000: irf_byp_rs2_data_d <= rd_data08;
585
            5'b01001: irf_byp_rs2_data_d <= rd_data09;
586
            5'b01010: irf_byp_rs2_data_d <= rd_data10;
587
            5'b01011: irf_byp_rs2_data_d <= rd_data11;
588
            5'b01100: irf_byp_rs2_data_d <= rd_data12;
589
            5'b01101: irf_byp_rs2_data_d <= rd_data13;
590
            5'b01110: irf_byp_rs2_data_d <= rd_data14;
591
            5'b01111: irf_byp_rs2_data_d <= rd_data15;
592
            5'b10000: irf_byp_rs2_data_d <= rd_data16;
593
            5'b10001: irf_byp_rs2_data_d <= rd_data17;
594
            5'b10010: irf_byp_rs2_data_d <= rd_data18;
595
            5'b10011: irf_byp_rs2_data_d <= rd_data19;
596
            5'b10100: irf_byp_rs2_data_d <= rd_data20;
597
            5'b10101: irf_byp_rs2_data_d <= rd_data21;
598
            5'b10110: irf_byp_rs2_data_d <= rd_data22;
599
            5'b10111: irf_byp_rs2_data_d <= rd_data23;
600
            5'b11000: irf_byp_rs2_data_d <= rd_data24;
601
            5'b11001: irf_byp_rs2_data_d <= rd_data25;
602
            5'b11010: irf_byp_rs2_data_d <= rd_data26;
603
            5'b11011: irf_byp_rs2_data_d <= rd_data27;
604
            5'b11100: irf_byp_rs2_data_d <= rd_data28;
605
            5'b11101: irf_byp_rs2_data_d <= rd_data29;
606
            5'b11110: irf_byp_rs2_data_d <= rd_data30;
607
            5'b11111: irf_byp_rs2_data_d <= rd_data31;
608
          endcase
609 95 fafa1971
 
610 113 albert.wat
        always @(negedge clk)
611
          if(ifu_exu_ren3_d)
612
          case(thr_rs3[4:0])
613
            5'b00000: irf_byp_rs3_data_d <= rd_data00;
614
            5'b00001: irf_byp_rs3_data_d <= rd_data01;
615
            5'b00010: irf_byp_rs3_data_d <= rd_data02;
616
            5'b00011: irf_byp_rs3_data_d <= rd_data03;
617
            5'b00100: irf_byp_rs3_data_d <= rd_data04;
618
            5'b00101: irf_byp_rs3_data_d <= rd_data05;
619
            5'b00110: irf_byp_rs3_data_d <= rd_data06;
620
            5'b00111: irf_byp_rs3_data_d <= rd_data07;
621
            5'b01000: irf_byp_rs3_data_d <= rd_data08;
622
            5'b01001: irf_byp_rs3_data_d <= rd_data09;
623
            5'b01010: irf_byp_rs3_data_d <= rd_data10;
624
            5'b01011: irf_byp_rs3_data_d <= rd_data11;
625
            5'b01100: irf_byp_rs3_data_d <= rd_data12;
626
            5'b01101: irf_byp_rs3_data_d <= rd_data13;
627
            5'b01110: irf_byp_rs3_data_d <= rd_data14;
628
            5'b01111: irf_byp_rs3_data_d <= rd_data15;
629
            5'b10000: irf_byp_rs3_data_d <= rd_data16;
630
            5'b10001: irf_byp_rs3_data_d <= rd_data17;
631
            5'b10010: irf_byp_rs3_data_d <= rd_data18;
632
            5'b10011: irf_byp_rs3_data_d <= rd_data19;
633
            5'b10100: irf_byp_rs3_data_d <= rd_data20;
634
            5'b10101: irf_byp_rs3_data_d <= rd_data21;
635
            5'b10110: irf_byp_rs3_data_d <= rd_data22;
636
            5'b10111: irf_byp_rs3_data_d <= rd_data23;
637
            5'b11000: irf_byp_rs3_data_d <= rd_data24;
638
            5'b11001: irf_byp_rs3_data_d <= rd_data25;
639
            5'b11010: irf_byp_rs3_data_d <= rd_data26;
640
            5'b11011: irf_byp_rs3_data_d <= rd_data27;
641
            5'b11100: irf_byp_rs3_data_d <= rd_data28;
642
            5'b11101: irf_byp_rs3_data_d <= rd_data29;
643
            5'b11110: irf_byp_rs3_data_d <= rd_data30;
644
            5'b11111: irf_byp_rs3_data_d <= rd_data31;
645
          endcase
646 95 fafa1971
 
647 113 albert.wat
        always @(negedge clk)
648
          if(ifu_exu_ren3_d)
649
          case(thr_rs3h[4:1])
650
            4'b0000: irf_byp_rs3h_data_d <= rd_data01;
651
            4'b0001: irf_byp_rs3h_data_d <= rd_data03;
652
            4'b0010: irf_byp_rs3h_data_d <= rd_data05;
653
            4'b0011: irf_byp_rs3h_data_d <= rd_data07;
654
            4'b0100: irf_byp_rs3h_data_d <= rd_data09;
655
            4'b0101: irf_byp_rs3h_data_d <= rd_data11;
656
            4'b0110: irf_byp_rs3h_data_d <= rd_data13;
657
            4'b0111: irf_byp_rs3h_data_d <= rd_data15;
658
            4'b1000: irf_byp_rs3h_data_d <= rd_data17;
659
            4'b1001: irf_byp_rs3h_data_d <= rd_data19;
660
            4'b1010: irf_byp_rs3h_data_d <= rd_data21;
661
            4'b1011: irf_byp_rs3h_data_d <= rd_data23;
662
            4'b1100: irf_byp_rs3h_data_d <= rd_data25;
663
            4'b1101: irf_byp_rs3h_data_d <= rd_data27;
664
            4'b1110: irf_byp_rs3h_data_d <= rd_data29;
665
            4'b1111: irf_byp_rs3h_data_d <= rd_data31;
666
          endcase
667 95 fafa1971
 
668 113 albert.wat
wire wren = wr_en | wr_en2;
669
wire [4:0] wr_addr = wr_en ? thr_rd_w_neg[4:0] : thr_rd_w2_neg[4:0];
670
wire [71:0] wr_data = wr_en ? active_win_thr_rd_w_neg : active_win_thr_rd_w2_neg;
671 95 fafa1971
 
672 113 albert.wat
//GLOBALs
673
bw_r_irf_register register00(
674
                .clk(clk),
675
                .wren(wren & (wr_addr == 5'b00000)),
676
                .save(swap_global_d1_vld),
677
                .save_addr({1'b0,old_agp_d1[1:0]}),
678
                .restore(swap_global_d2),
679
                .restore_addr({1'b0,new_agp_d2[1:0]}),
680
                .wr_data(72'b0),
681
                .rd_data(rd_data00)
682
);
683 95 fafa1971
 
684 113 albert.wat
bw_r_irf_register register01(
685
                .clk(clk),
686
                .wren(wren & (wr_addr == 5'b00001)),
687
                .save(swap_global_d1_vld),
688
                .save_addr({1'b0,old_agp_d1[1:0]}),
689
                .restore(swap_global_d2),
690
                .restore_addr({1'b0,new_agp_d2[1:0]}),
691
                .wr_data(wr_data),
692
                .rd_data(rd_data01)
693
);
694 95 fafa1971
 
695 113 albert.wat
bw_r_irf_register register02(
696
                .clk(clk),
697
                .wren(wren & (wr_addr == 5'b00010)),
698
                .save(swap_global_d1_vld),
699
                .save_addr({1'b0,old_agp_d1[1:0]}),
700
                .restore(swap_global_d2),
701
                .restore_addr({1'b0,new_agp_d2[1:0]}),
702
                .wr_data(wr_data),
703
                .rd_data(rd_data02)
704
);
705 95 fafa1971
 
706 113 albert.wat
bw_r_irf_register register03(
707
                .clk(clk),
708
                .wren(wren & (wr_addr == 5'b00011)),
709
                .save(swap_global_d1_vld),
710
                .save_addr({1'b0,old_agp_d1[1:0]}),
711
                .restore(swap_global_d2),
712
                .restore_addr({1'b0,new_agp_d2[1:0]}),
713
                .wr_data(wr_data),
714
                .rd_data(rd_data03)
715
);
716 95 fafa1971
 
717 113 albert.wat
bw_r_irf_register register04(
718
                .clk(clk),
719
                .wren(wren & (wr_addr == 5'b00100)),
720
                .save(swap_global_d1_vld),
721
                .save_addr({1'b0,old_agp_d1[1:0]}),
722
                .restore(swap_global_d2),
723
                .restore_addr({1'b0,new_agp_d2[1:0]}),
724
                .wr_data(wr_data),
725
                .rd_data(rd_data04)
726
);
727 95 fafa1971
 
728 113 albert.wat
bw_r_irf_register register05(
729
                .clk(clk),
730
                .wren(wren & (wr_addr == 5'b00101)),
731
                .save(swap_global_d1_vld),
732
                .save_addr({1'b0,old_agp_d1[1:0]}),
733
                .restore(swap_global_d2),
734
                .restore_addr({1'b0,new_agp_d2[1:0]}),
735
                .wr_data(wr_data),
736
                .rd_data(rd_data05)
737
);
738 95 fafa1971
 
739 113 albert.wat
bw_r_irf_register register06(
740
                .clk(clk),
741
                .wren(wren & (wr_addr == 5'b00110)),
742
                .save(swap_global_d1_vld),
743
                .save_addr({1'b0,old_agp_d1[1:0]}),
744
                .restore(swap_global_d2),
745
                .restore_addr({1'b0,new_agp_d2[1:0]}),
746
                .wr_data(wr_data),
747
                .rd_data(rd_data06)
748
);
749 95 fafa1971
 
750 113 albert.wat
bw_r_irf_register register07(
751
                .clk(clk),
752
                .wren(wren & (wr_addr == 5'b00111)),
753
                .save(swap_global_d1_vld),
754
                .save_addr({1'b0,old_agp_d1[1:0]}),
755
                .restore(swap_global_d2),
756
                .restore_addr({1'b0,new_agp_d2[1:0]}),
757
                .wr_data(wr_data),
758
                .rd_data(rd_data07)
759
);
760 95 fafa1971
 
761 113 albert.wat
//ODDs
762
bw_r_irf_register register08(
763
                .clk(clk),
764
                .wren(wren & (wr_addr == 5'b01000)),
765
                .save(swap_odd_m_vld),
766
                .save_addr({1'b0,old_lo_cwp_m[2:1]}),
767
                .restore(swap_odd_w & ~kill_restore_w),
768
                .restore_addr({1'b0,new_lo_cwp_w[2:1]}),
769
                .wr_data(wr_data),
770
                .rd_data(rd_data08)
771
);
772 95 fafa1971
 
773 113 albert.wat
bw_r_irf_register register09(
774
                .clk(clk),
775
                .wren(wren & (wr_addr == 5'b01001)),
776
                .save(swap_odd_m_vld),
777
                .save_addr({1'b0,old_lo_cwp_m[2:1]}),
778
                .restore(swap_odd_w & ~kill_restore_w),
779
                .restore_addr({1'b0,new_lo_cwp_w[2:1]}),
780
                .wr_data(wr_data),
781
                .rd_data(rd_data09)
782
);
783 95 fafa1971
 
784 113 albert.wat
bw_r_irf_register register10(
785
                .clk(clk),
786
                .wren(wren & (wr_addr == 5'b01010)),
787
                .save(swap_odd_m_vld),
788
                .save_addr({1'b0,old_lo_cwp_m[2:1]}),
789
                .restore(swap_odd_w & ~kill_restore_w),
790
                .restore_addr({1'b0,new_lo_cwp_w[2:1]}),
791
                .wr_data(wr_data),
792
                .rd_data(rd_data10)
793
);
794 95 fafa1971
 
795 113 albert.wat
bw_r_irf_register register11(
796
                .clk(clk),
797
                .wren(wren & (wr_addr == 5'b01011)),
798
                .save(swap_odd_m_vld),
799
                .save_addr({1'b0,old_lo_cwp_m[2:1]}),
800
                .restore(swap_odd_w & ~kill_restore_w),
801
                .restore_addr({1'b0,new_lo_cwp_w[2:1]}),
802
                .wr_data(wr_data),
803
                .rd_data(rd_data11)
804
);
805 95 fafa1971
 
806 113 albert.wat
bw_r_irf_register register12(
807
                .clk(clk),
808
                .wren(wren & (wr_addr == 5'b01100)),
809
                .save(swap_odd_m_vld),
810
                .save_addr({1'b0,old_lo_cwp_m[2:1]}),
811
                .restore(swap_odd_w & ~kill_restore_w),
812
                .restore_addr({1'b0,new_lo_cwp_w[2:1]}),
813
                .wr_data(wr_data),
814
                .rd_data(rd_data12)
815
);
816 95 fafa1971
 
817 113 albert.wat
bw_r_irf_register register13(
818
                .clk(clk),
819
                .wren(wren & (wr_addr == 5'b01101)),
820
                .save(swap_odd_m_vld),
821
                .save_addr({1'b0,old_lo_cwp_m[2:1]}),
822
                .restore(swap_odd_w & ~kill_restore_w),
823
                .restore_addr({1'b0,new_lo_cwp_w[2:1]}),
824
                .wr_data(wr_data),
825
                .rd_data(rd_data13)
826
);
827 95 fafa1971
 
828 113 albert.wat
bw_r_irf_register register14(
829
                .clk(clk),
830
                .wren(wren & (wr_addr == 5'b01110)),
831
                .save(swap_odd_m_vld),
832
                .save_addr({1'b0,old_lo_cwp_m[2:1]}),
833
                .restore(swap_odd_w & ~kill_restore_w),
834
                .restore_addr({1'b0,new_lo_cwp_w[2:1]}),
835
                .wr_data(wr_data),
836
                .rd_data(rd_data14)
837
);
838 95 fafa1971
 
839 113 albert.wat
bw_r_irf_register register15(
840
                .clk(clk),
841
                .wren(wren & (wr_addr == 5'b01111)),
842
                .save(swap_odd_m_vld),
843
                .save_addr({1'b0,old_lo_cwp_m[2:1]}),
844
                .restore(swap_odd_w & ~kill_restore_w),
845
                .restore_addr({1'b0,new_lo_cwp_w[2:1]}),
846
                .wr_data(wr_data),
847
                .rd_data(rd_data15)
848
);
849 95 fafa1971
 
850 113 albert.wat
//LOCALs
851
bw_r_irf_register register16(
852
                .clk(clk),
853
                .wren(wren & (wr_addr == 5'b10000)),
854
                .save(swap_local_m_vld),
855
                .save_addr({old_lo_cwp_m[2:0]}),
856
                .restore(swap_local_w & ~kill_restore_w),
857
                .restore_addr({new_lo_cwp_w[2:0]}),
858
                .wr_data(wr_data),
859
                .rd_data(rd_data16)
860
);
861 95 fafa1971
 
862 113 albert.wat
bw_r_irf_register register17(
863
                .clk(clk),
864
                .wren(wren & (wr_addr == 5'b10001)),
865
                .save(swap_local_m_vld),
866
                .save_addr({old_lo_cwp_m[2:0]}),
867
                .restore(swap_local_w & ~kill_restore_w),
868
                .restore_addr({new_lo_cwp_w[2:0]}),
869
                .wr_data(wr_data),
870
                .rd_data(rd_data17)
871
);
872 95 fafa1971
 
873 113 albert.wat
bw_r_irf_register register18(
874
                .clk(clk),
875
                .wren(wren & (wr_addr == 5'b10010)),
876
                .save(swap_local_m_vld),
877
                .save_addr({old_lo_cwp_m[2:0]}),
878
                .restore(swap_local_w & ~kill_restore_w),
879
                .restore_addr({new_lo_cwp_w[2:0]}),
880
                .wr_data(wr_data),
881
                .rd_data(rd_data18)
882
);
883 95 fafa1971
 
884 113 albert.wat
bw_r_irf_register register19(
885
                .clk(clk),
886
                .wren(wren & (wr_addr == 5'b10011)),
887
                .save(swap_local_m_vld),
888
                .save_addr({old_lo_cwp_m[2:0]}),
889
                .restore(swap_local_w & ~kill_restore_w),
890
                .restore_addr({new_lo_cwp_w[2:0]}),
891
                .wr_data(wr_data),
892
                .rd_data(rd_data19)
893
);
894 95 fafa1971
 
895 113 albert.wat
bw_r_irf_register register20(
896
                .clk(clk),
897
                .wren(wren & (wr_addr == 5'b10100)),
898
                .save(swap_local_m_vld),
899
                .save_addr({old_lo_cwp_m[2:0]}),
900
                .restore(swap_local_w & ~kill_restore_w),
901
                .restore_addr({new_lo_cwp_w[2:0]}),
902
                .wr_data(wr_data),
903
                .rd_data(rd_data20)
904
);
905 95 fafa1971
 
906 113 albert.wat
bw_r_irf_register register21(
907
                .clk(clk),
908
                .wren(wren & (wr_addr == 5'b10101)),
909
                .save(swap_local_m_vld),
910
                .save_addr({old_lo_cwp_m[2:0]}),
911
                .restore(swap_local_w & ~kill_restore_w),
912
                .restore_addr({new_lo_cwp_w[2:0]}),
913
                .wr_data(wr_data),
914
                .rd_data(rd_data21)
915
);
916 95 fafa1971
 
917 113 albert.wat
bw_r_irf_register register22(
918
                .clk(clk),
919
                .wren(wren & (wr_addr == 5'b10110)),
920
                .save(swap_local_m_vld),
921
                .save_addr({old_lo_cwp_m[2:0]}),
922
                .restore(swap_local_w & ~kill_restore_w),
923
                .restore_addr({new_lo_cwp_w[2:0]}),
924
                .wr_data(wr_data),
925
                .rd_data(rd_data22)
926
);
927 95 fafa1971
 
928 113 albert.wat
bw_r_irf_register register23(
929
                .clk(clk),
930
                .wren(wren & (wr_addr == 5'b10111)),
931
                .save(swap_local_m_vld),
932
                .save_addr({old_lo_cwp_m[2:0]}),
933
                .restore(swap_local_w & ~kill_restore_w),
934
                .restore_addr({new_lo_cwp_w[2:0]}),
935
                .wr_data(wr_data),
936
                .rd_data(rd_data23)
937
);
938 95 fafa1971
 
939 113 albert.wat
//EVENs
940
bw_r_irf_register register24(
941
                .clk(clk),
942
                .wren(wren & (wr_addr == 5'b11000)),
943
                .save(swap_even_m_vld),
944
                .save_addr({1'b0,old_e_cwp_m[1:0]}),
945
                .restore(swap_even_w & ~kill_restore_w),
946
                .restore_addr({1'b0,new_e_cwp_w[1:0]}),
947
                .wr_data(wr_data),
948
                .rd_data(rd_data24)
949
);
950 95 fafa1971
 
951 113 albert.wat
bw_r_irf_register register25(
952
                .clk(clk),
953
                .wren(wren & (wr_addr == 5'b11001)),
954
                .save(swap_even_m_vld),
955
                .save_addr({1'b0,old_e_cwp_m[1:0]}),
956
                .restore(swap_even_w & ~kill_restore_w),
957
                .restore_addr({1'b0,new_e_cwp_w[1:0]}),
958
                .wr_data(wr_data),
959
                .rd_data(rd_data25)
960
);
961 95 fafa1971
 
962 113 albert.wat
bw_r_irf_register register26(
963
                .clk(clk),
964
                .wren(wren & (wr_addr == 5'b11010)),
965
                .save(swap_even_m_vld),
966
                .save_addr({1'b0,old_e_cwp_m[1:0]}),
967
                .restore(swap_even_w & ~kill_restore_w),
968
                .restore_addr({1'b0,new_e_cwp_w[1:0]}),
969
                .wr_data(wr_data),
970
                .rd_data(rd_data26)
971
);
972 95 fafa1971
 
973 113 albert.wat
bw_r_irf_register register27(
974
                .clk(clk),
975
                .wren(wren & (wr_addr == 5'b11011)),
976
                .save(swap_even_m_vld),
977
                .save_addr({1'b0,old_e_cwp_m[1:0]}),
978
                .restore(swap_even_w & ~kill_restore_w),
979
                .restore_addr({1'b0,new_e_cwp_w[1:0]}),
980
                .wr_data(wr_data),
981
                .rd_data(rd_data27)
982
);
983 95 fafa1971
 
984 113 albert.wat
bw_r_irf_register register28(
985
                .clk(clk),
986
                .wren(wren & (wr_addr == 5'b11100)),
987
                .save(swap_even_m_vld),
988
                .save_addr({1'b0,old_e_cwp_m[1:0]}),
989
                .restore(swap_even_w & ~kill_restore_w),
990
                .restore_addr({1'b0,new_e_cwp_w[1:0]}),
991
                .wr_data(wr_data),
992
                .rd_data(rd_data28)
993
);
994 95 fafa1971
 
995 113 albert.wat
bw_r_irf_register register29(
996
                .clk(clk),
997
                .wren(wren & (wr_addr == 5'b11101)),
998
                .save(swap_even_m_vld),
999
                .save_addr({1'b0,old_e_cwp_m[1:0]}),
1000
                .restore(swap_even_w & ~kill_restore_w),
1001
                .restore_addr({1'b0,new_e_cwp_w[1:0]}),
1002
                .wr_data(wr_data),
1003
                .rd_data(rd_data29)
1004
);
1005 95 fafa1971
 
1006 113 albert.wat
bw_r_irf_register register30(
1007
                .clk(clk),
1008
                .wren(wren & (wr_addr == 5'b11110)),
1009
                .save(swap_even_m_vld),
1010
                .save_addr({1'b0,old_e_cwp_m[1:0]}),
1011
                .restore(swap_even_w & ~kill_restore_w),
1012
                .restore_addr({1'b0,new_e_cwp_w[1:0]}),
1013
                .wr_data(wr_data),
1014
                .rd_data(rd_data30)
1015
);
1016 95 fafa1971
 
1017 113 albert.wat
bw_r_irf_register register31(
1018
                .clk(clk),
1019
                .wren(wren & (wr_addr == 5'b11111)),
1020
                .save(swap_even_m_vld),
1021
                .save_addr({1'b0,old_e_cwp_m[1:0]}),
1022
                .restore(swap_even_w & ~kill_restore_w),
1023
                .restore_addr({1'b0,new_e_cwp_w[1:0]}),
1024
                .wr_data(wr_data),
1025
                .rd_data(rd_data31)
1026
);
1027 95 fafa1971
 
1028 113 albert.wat
endmodule
1029 95 fafa1971
 
1030
 
1031 113 albert.wat
`else
1032 95 fafa1971
 
1033
 
1034
module bw_r_irf(so, irf_byp_rs1_data_d_l, irf_byp_rs2_data_d_l,
1035
        irf_byp_rs3_data_d_l, irf_byp_rs3h_data_d_l, rclk, reset_l, si, se,
1036
        sehold, rst_tri_en, ifu_exu_tid_s2, ifu_exu_rs1_s, ifu_exu_rs2_s,
1037
        ifu_exu_rs3_s, ifu_exu_ren1_s, ifu_exu_ren2_s, ifu_exu_ren3_s,
1038
        ecl_irf_wen_w, ecl_irf_wen_w2, ecl_irf_rd_m, ecl_irf_rd_g,
1039
        byp_irf_rd_data_w, byp_irf_rd_data_w2, ecl_irf_tid_m, ecl_irf_tid_g,
1040
        rml_irf_old_lo_cwp_e, rml_irf_new_lo_cwp_e, rml_irf_old_e_cwp_e,
1041
        rml_irf_new_e_cwp_e, rml_irf_swap_even_e, rml_irf_swap_odd_e,
1042
        rml_irf_swap_local_e, rml_irf_kill_restore_w, rml_irf_cwpswap_tid_e,
1043
        rml_irf_old_agp, rml_irf_new_agp, rml_irf_swap_global,
1044
        rml_irf_global_tid);
1045
 
1046
        input                   rclk;
1047
        input                   reset_l;
1048
        input                   si;
1049
        input                   se;
1050
        input                   sehold;
1051
        input                   rst_tri_en;
1052
        input   [1:0]            ifu_exu_tid_s2;
1053
        input   [4:0]            ifu_exu_rs1_s;
1054
        input   [4:0]            ifu_exu_rs2_s;
1055
        input   [4:0]            ifu_exu_rs3_s;
1056
        input                   ifu_exu_ren1_s;
1057
        input                   ifu_exu_ren2_s;
1058
        input                   ifu_exu_ren3_s;
1059
        input                   ecl_irf_wen_w;
1060
        input                   ecl_irf_wen_w2;
1061
        input   [4:0]            ecl_irf_rd_m;
1062
        input   [4:0]            ecl_irf_rd_g;
1063
        input   [71:0]           byp_irf_rd_data_w;
1064
        input   [71:0]           byp_irf_rd_data_w2;
1065
        input   [1:0]            ecl_irf_tid_m;
1066
        input   [1:0]            ecl_irf_tid_g;
1067
        input   [2:0]            rml_irf_old_lo_cwp_e;
1068
        input   [2:0]            rml_irf_new_lo_cwp_e;
1069
        input   [2:1]           rml_irf_old_e_cwp_e;
1070
        input   [2:1]           rml_irf_new_e_cwp_e;
1071
        input                   rml_irf_swap_even_e;
1072
        input                   rml_irf_swap_odd_e;
1073
        input                   rml_irf_swap_local_e;
1074
        input                   rml_irf_kill_restore_w;
1075
        input   [1:0]            rml_irf_cwpswap_tid_e;
1076
        input   [1:0]            rml_irf_old_agp;
1077
        input   [1:0]            rml_irf_new_agp;
1078
        input                   rml_irf_swap_global;
1079
        input   [1:0]            rml_irf_global_tid;
1080
        output                  so;
1081
        output  [71:0]           irf_byp_rs1_data_d_l;
1082
        output  [71:0]           irf_byp_rs2_data_d_l;
1083
        output  [71:0]           irf_byp_rs3_data_d_l;
1084
        output  [31:0]           irf_byp_rs3h_data_d_l;
1085
 
1086
        wire    [71:0]           irf_byp_rs1_data_d;
1087
        wire    [71:0]           irf_byp_rs2_data_d;
1088
        wire    [71:0]           irf_byp_rs3_data_d;
1089
        wire    [71:0]           irf_byp_rs3h_data_d;
1090
        wire    [1:0]            ecl_irf_tid_w;
1091
        wire    [1:0]            ecl_irf_tid_w2;
1092
        wire    [4:0]            ecl_irf_rd_w;
1093
        wire    [4:0]            ecl_irf_rd_w2;
1094
        wire    [1:0]            ifu_exu_thr_d;
1095
        wire                    ifu_exu_ren1_d;
1096
        wire                    ifu_exu_ren2_d;
1097
        wire                    ifu_exu_ren3_d;
1098
        wire    [4:0]            ifu_exu_rs1_d;
1099
        wire    [4:0]            ifu_exu_rs2_d;
1100
        wire    [4:0]            ifu_exu_rs3_d;
1101
        wire    [6:0]            thr_rs1;
1102
        wire    [6:0]            thr_rs2;
1103
        wire    [6:0]            thr_rs3;
1104
        wire    [6:0]            thr_rs3h;
1105
        wire    [6:0]            thr_rd_w;
1106
        wire    [6:0]            thr_rd_w2;
1107
        reg     [1:0]            cwpswap_tid_m;
1108
        reg     [1:0]            cwpswap_tid_w;
1109
        reg     [2:0]            old_lo_cwp_m;
1110
        reg     [2:0]            new_lo_cwp_m;
1111
        reg     [2:0]            new_lo_cwp_w;
1112
        reg     [1:0]            old_e_cwp_m;
1113
        reg     [1:0]            new_e_cwp_m;
1114
        reg     [1:0]            new_e_cwp_w;
1115
        reg                     swap_local_m;
1116
        reg                     swap_local_w;
1117
        reg                     swap_even_m;
1118
        reg                     swap_even_w;
1119
        reg                     swap_odd_m;
1120
        reg                     swap_odd_w;
1121
        reg                     kill_restore_d1;
1122
        reg                     swap_global_d1;
1123
        reg                     swap_global_d2;
1124
        reg     [1:0]            global_tid_d1;
1125
        reg     [1:0]            global_tid_d2;
1126
        reg     [1:0]            old_agp_d1;
1127
        reg     [1:0]            new_agp_d1;
1128
        reg     [1:0]            new_agp_d2;
1129
        reg     [71:0]           active_win_thr_rd_w_neg;
1130
        reg     [71:0]           active_win_thr_rd_w2_neg;
1131
        reg     [6:0]            thr_rd_w_neg;
1132
        reg     [6:0]            thr_rd_w2_neg;
1133
        reg                     active_win_thr_rd_w_neg_wr_en;
1134
        reg                     active_win_thr_rd_w2_neg_wr_en;
1135
        reg                     rst_tri_en_neg;
1136
        wire                    clk;
1137
        wire                    ren1_s;
1138
        wire                    ren2_s;
1139
        wire                    ren3_s;
1140
        wire    [4:0]            rs1_s;
1141
        wire    [4:0]            rs2_s;
1142
        wire    [4:0]            rs3_s;
1143
        wire    [1:0]            tid_s;
1144
        wire    [1:0]            tid_g;
1145
        wire    [1:0]            tid_m;
1146
        wire    [4:0]            rd_m;
1147
        wire    [4:0]            rd_g;
1148
        wire                    kill_restore_w;
1149
        wire                    swap_global_d1_vld;
1150
        wire                    swap_local_m_vld;
1151
        wire                    swap_even_m_vld;
1152
        wire                    swap_odd_m_vld;
1153
        wire                    wr_en;
1154
        wire                    wr_en2;
1155
 
1156
        assign clk = rclk;
1157
        assign {ren1_s, ren2_s, ren3_s, rs1_s[4:0], rs2_s[4:0], rs3_s[4:0],
1158
                tid_s[1:0], tid_g[1:0], tid_m[1:0], rd_m[4:0], rd_g[4:0]} = (
1159
                sehold ? {ifu_exu_ren1_d, ifu_exu_ren2_d, ifu_exu_ren3_d,
1160
                ifu_exu_rs1_d[4:0], ifu_exu_rs2_d[4:0], ifu_exu_rs3_d[4:0],
1161
                ifu_exu_thr_d[1:0], ecl_irf_tid_w2[1:0], ecl_irf_tid_w[1:0],
1162
                ecl_irf_rd_w[4:0], ecl_irf_rd_w2[4:0]} : {ifu_exu_ren1_s,
1163
                ifu_exu_ren2_s, ifu_exu_ren3_s, ifu_exu_rs1_s[4:0],
1164
                ifu_exu_rs2_s[4:0], ifu_exu_rs3_s[4:0], ifu_exu_tid_s2[1:0],
1165
                ecl_irf_tid_g[1:0], ecl_irf_tid_m[1:0], ecl_irf_rd_m[4:0],
1166
                ecl_irf_rd_g[4:0]});
1167
        assign thr_rs1[6:0] = {ifu_exu_thr_d, ifu_exu_rs1_d};
1168
        assign thr_rs2[6:0] = {ifu_exu_thr_d, ifu_exu_rs2_d};
1169
        assign thr_rs3[6:0] = {ifu_exu_thr_d, ifu_exu_rs3_d[4:0]};
1170
        assign thr_rs3h[6:0] = {ifu_exu_thr_d[1:0], ifu_exu_rs3_d[4:1], 1'b1};
1171
        assign thr_rd_w[6:0] = {ecl_irf_tid_w, ecl_irf_rd_w};
1172
        assign thr_rd_w2[6:0] = {ecl_irf_tid_w2, ecl_irf_rd_w2};
1173
        assign irf_byp_rs1_data_d_l[71:0] = (~irf_byp_rs1_data_d[71:0]);
1174
        assign irf_byp_rs2_data_d_l[71:0] = (~irf_byp_rs2_data_d[71:0]);
1175
        assign irf_byp_rs3_data_d_l[71:0] = (~irf_byp_rs3_data_d[71:0]);
1176
        assign irf_byp_rs3h_data_d_l[31:0] = (~irf_byp_rs3h_data_d[31:0]);
1177
        assign kill_restore_w = (sehold ? kill_restore_d1 :
1178
                rml_irf_kill_restore_w);
1179
        assign swap_local_m_vld = (swap_local_m & (~rst_tri_en));
1180
        assign swap_odd_m_vld = (swap_odd_m & (~rst_tri_en));
1181
        assign swap_even_m_vld = (swap_even_m & (~rst_tri_en));
1182
        assign swap_global_d1_vld = (swap_global_d1 & (~rst_tri_en));
1183
        assign wr_en = (active_win_thr_rd_w_neg_wr_en & ((~rst_tri_en) | (~
1184
                rst_tri_en_neg)));
1185
        assign wr_en2 = (active_win_thr_rd_w2_neg_wr_en & ((~rst_tri_en) | (~
1186
                rst_tri_en_neg)));
1187
 
1188 113 albert.wat
        dff_s dff_ren1_s2d(
1189 95 fafa1971
                .din                            (ren1_s),
1190
                .clk                            (clk),
1191
                .q                              (ifu_exu_ren1_d),
1192
                .se                             (se));
1193 113 albert.wat
        dff_s dff_ren2_s2d(
1194 95 fafa1971
                .din                            (ren2_s),
1195
                .clk                            (clk),
1196
                .q                              (ifu_exu_ren2_d),
1197
                .se                             (se));
1198 113 albert.wat
        dff_s dff_ren3_s2d(
1199 95 fafa1971
                .din                            (ren3_s),
1200
                .clk                            (clk),
1201
                .q                              (ifu_exu_ren3_d),
1202
                .se                             (se));
1203 113 albert.wat
        dff_s #(5) dff_rs1_s2d(
1204 95 fafa1971
                .din                            (rs1_s[4:0]),
1205
                .clk                            (clk),
1206
                .q                              (ifu_exu_rs1_d[4:0]),
1207
                .se                             (se));
1208 113 albert.wat
        dff_s #(5) dff_rs2_s2d(
1209 95 fafa1971
                .din                            (rs2_s[4:0]),
1210
                .clk                            (clk),
1211
                .q                              (ifu_exu_rs2_d[4:0]),
1212
                .se                             (se));
1213 113 albert.wat
        dff_s #(5) dff_rs3_s2d(
1214 95 fafa1971
                .din                            (rs3_s[4:0]),
1215
                .clk                            (clk),
1216
                .q                              (ifu_exu_rs3_d[4:0]),
1217
                .se                             (se));
1218 113 albert.wat
        dff_s #(2) dff_thr_s2d(
1219 95 fafa1971
                .din                            (tid_s[1:0]),
1220
                .clk                            (clk),
1221
                .q                              (ifu_exu_thr_d[1:0]),
1222
                .se                             (se));
1223 113 albert.wat
        dff_s #(2) dff_thr_g2w2(
1224 95 fafa1971
                .din                            (tid_g[1:0]),
1225
                .clk                            (clk),
1226
                .q                              (ecl_irf_tid_w2[1:0]),
1227
                .se                             (se));
1228 113 albert.wat
        dff_s #(2) dff_thr_m2w(
1229 95 fafa1971
                .din                            (tid_m[1:0]),
1230
                .clk                            (clk),
1231
                .q                              (ecl_irf_tid_w[1:0]),
1232
                .se                             (se));
1233 113 albert.wat
        dff_s #(5) dff_rd_m2w(
1234 95 fafa1971
                .din                            (rd_m[4:0]),
1235
                .clk                            (clk),
1236
                .q                              (ecl_irf_rd_w[4:0]),
1237
                .se                             (se));
1238 113 albert.wat
        dff_s #(5) dff_rd_g2w2(
1239 95 fafa1971
                .din                            (rd_g[4:0]),
1240
                .clk                            (clk),
1241
                .q                              (ecl_irf_rd_w2[4:0]),
1242
                .se                             (se));
1243
        bw_r_irf_core bw_r_irf_core(
1244
                .clk                            (clk),
1245
                .ifu_exu_ren1_d                 (ifu_exu_ren1_d),
1246
                .ifu_exu_ren2_d                 (ifu_exu_ren2_d),
1247
                .ifu_exu_ren3_d                 (ifu_exu_ren3_d),
1248
                .thr_rs1                        (thr_rs1),
1249
                .thr_rs2                        (thr_rs2),
1250
                .thr_rs3                        (thr_rs3),
1251
                .thr_rs3h                       (thr_rs3h),
1252
                .irf_byp_rs1_data_d             (irf_byp_rs1_data_d),
1253
                .irf_byp_rs2_data_d             (irf_byp_rs2_data_d),
1254
                .irf_byp_rs3_data_d             (irf_byp_rs3_data_d),
1255
                .irf_byp_rs3h_data_d            (irf_byp_rs3h_data_d),
1256
                .wr_en                          (wr_en),
1257
                .wr_en2                         (wr_en2),
1258
                .active_win_thr_rd_w_neg        (active_win_thr_rd_w_neg),
1259
                .active_win_thr_rd_w2_neg       (active_win_thr_rd_w2_neg),
1260
                .thr_rd_w_neg                   (thr_rd_w_neg),
1261
                .thr_rd_w2_neg                  (thr_rd_w2_neg),
1262
                .swap_global_d1_vld             (swap_global_d1_vld),
1263
                .swap_global_d2                 (swap_global_d2),
1264
                .global_tid_d1                  (global_tid_d1),
1265
                .global_tid_d2                  (global_tid_d2),
1266
                .old_agp_d1                     (old_agp_d1),
1267
                .new_agp_d2                     (new_agp_d2),
1268
                .swap_local_m_vld               (swap_local_m_vld),
1269
                .swap_local_w                   (swap_local_w),
1270
                .old_lo_cwp_m                   (old_lo_cwp_m),
1271
                .new_lo_cwp_w                   (new_lo_cwp_w),
1272
                .swap_even_m_vld                (swap_even_m_vld),
1273
                .swap_even_w                    (swap_even_w),
1274
                .old_e_cwp_m                    (old_e_cwp_m),
1275
                .new_e_cwp_w                    (new_e_cwp_w),
1276
                .swap_odd_m_vld                 (swap_odd_m_vld),
1277
                .swap_odd_w                     (swap_odd_w),
1278
                .cwpswap_tid_m                  (cwpswap_tid_m),
1279
                .cwpswap_tid_w                  (cwpswap_tid_w),
1280
                .kill_restore_w                 (kill_restore_w));
1281
 
1282
        always @(negedge clk) begin
1283
          rst_tri_en_neg <= rst_tri_en;
1284
          if ((ecl_irf_wen_w & ecl_irf_wen_w2) & (thr_rd_w[6:0] ==
1285
                  thr_rd_w2[6:0])) begin
1286
            active_win_thr_rd_w_neg <= {72 {1'bx}};
1287
            thr_rd_w_neg <= thr_rd_w;
1288
            active_win_thr_rd_w_neg_wr_en <= 1'b1;
1289
            active_win_thr_rd_w2_neg_wr_en <= 1'b0;
1290
          end
1291
          else
1292
            begin
1293
              if (ecl_irf_wen_w & (thr_rd_w[4:0] != 5'b0)) begin
1294
                active_win_thr_rd_w_neg <= byp_irf_rd_data_w;
1295
                thr_rd_w_neg <= thr_rd_w;
1296
                active_win_thr_rd_w_neg_wr_en <= 1'b1;
1297
              end
1298
              else begin
1299
                active_win_thr_rd_w_neg_wr_en <= 1'b0;
1300
              end
1301
              if (ecl_irf_wen_w2 & (thr_rd_w2[4:0] != 5'b0)) begin
1302
                active_win_thr_rd_w2_neg <= byp_irf_rd_data_w2;
1303
                thr_rd_w2_neg <= thr_rd_w2;
1304
                active_win_thr_rd_w2_neg_wr_en <= 1'b1;
1305
              end
1306
              else begin
1307
                active_win_thr_rd_w2_neg_wr_en <= 1'b0;
1308
              end
1309
            end
1310
        end
1311
        always @(posedge clk) begin
1312
          cwpswap_tid_m[1:0] <= (sehold ? cwpswap_tid_m[1:0] :
1313
                  rml_irf_cwpswap_tid_e[1:0]);
1314
          cwpswap_tid_w[1:0] <= cwpswap_tid_m[1:0];
1315
          old_lo_cwp_m[2:0] <= (sehold ? old_lo_cwp_m[2:0] :
1316
                  rml_irf_old_lo_cwp_e[2:0]);
1317
          new_lo_cwp_m[2:0] <= (sehold ? new_lo_cwp_m[2:0] :
1318
                  rml_irf_new_lo_cwp_e[2:0]);
1319
          new_lo_cwp_w[2:0] <= new_lo_cwp_m[2:0];
1320
          old_e_cwp_m[1:0] <= (sehold ? old_e_cwp_m[1:0] :
1321
                  rml_irf_old_e_cwp_e[2:1]);
1322
          new_e_cwp_m[1:0] <= (sehold ? new_e_cwp_m[1:0] :
1323
                  rml_irf_new_e_cwp_e[2:1]);
1324
          new_e_cwp_w[1:0] <= new_e_cwp_m[1:0];
1325
          swap_local_m <= (sehold ? (swap_local_m & rst_tri_en) :
1326
                  rml_irf_swap_local_e);
1327
          swap_local_w <= swap_local_m_vld;
1328
          swap_odd_m <= (sehold ? (swap_odd_m & rst_tri_en) : rml_irf_swap_odd_e
1329
                  );
1330
          swap_odd_w <= swap_odd_m_vld;
1331
          swap_even_m <= (sehold ? (swap_even_m & rst_tri_en) :
1332
                  rml_irf_swap_even_e);
1333
          swap_even_w <= swap_even_m_vld;
1334
          kill_restore_d1 <= kill_restore_w;
1335
        end
1336
        always @(posedge clk) begin
1337
          swap_global_d1 <= (sehold ? (swap_global_d1 & rst_tri_en) :
1338
                  rml_irf_swap_global);
1339
          swap_global_d2 <= swap_global_d1_vld;
1340
          global_tid_d1[1:0] <= (sehold ? global_tid_d1[1:0] :
1341
                  rml_irf_global_tid[1:0]);
1342
          global_tid_d2[1:0] <= global_tid_d1[1:0];
1343
          old_agp_d1[1:0] <= (sehold ? old_agp_d1[1:0] : rml_irf_old_agp[1:0]);
1344
          new_agp_d1[1:0] <= (sehold ? new_agp_d1[1:0] : rml_irf_new_agp[1:0]);
1345
          new_agp_d2[1:0] <= new_agp_d1[1:0];
1346
        end
1347
/*
1348
        always @(posedge clk) begin
1349
          if (wr_en) begin
1350
            $display("Write Port 1: %h %h", active_win_thr_rd_w_neg,
1351
                    thr_rd_w_neg);
1352
          end
1353
          if (wr_en2) begin
1354
            $display("Write Port 2: %h %h", active_win_thr_rd_w2_neg,
1355
                    thr_rd_w2_neg);
1356
          end
1357
          if (ifu_exu_ren1_d) begin
1358
            @(posedge clk) ;
1359
            $display("Read Port 1: %h %h", irf_byp_rs1_data_d, thr_rs1);
1360
          end
1361
          if (ifu_exu_ren2_d) begin
1362
            @(posedge clk) ;
1363
            $display("Read Port 2: %h %h", irf_byp_rs2_data_d, thr_rs2);
1364
          end
1365
          if (ifu_exu_ren3_d) begin
1366
            @(posedge clk) ;
1367
            $display("Read Port 3: %h %h", irf_byp_rs3_data_d, thr_rs3);
1368
          end
1369
        end
1370
*/
1371
endmodule
1372
 
1373
module bw_r_irf_core(clk, ifu_exu_ren1_d, ifu_exu_ren2_d, ifu_exu_ren3_d,
1374
        thr_rs1, thr_rs2, thr_rs3, thr_rs3h, irf_byp_rs1_data_d,
1375
        irf_byp_rs2_data_d, irf_byp_rs3_data_d, irf_byp_rs3h_data_d, wr_en,
1376
        wr_en2, active_win_thr_rd_w_neg, active_win_thr_rd_w2_neg, thr_rd_w_neg,
1377
        thr_rd_w2_neg, swap_global_d1_vld, swap_global_d2, global_tid_d1,
1378
        global_tid_d2, old_agp_d1, new_agp_d2, swap_local_m_vld, swap_local_w,
1379
        old_lo_cwp_m, new_lo_cwp_w, swap_even_m_vld, swap_even_w, old_e_cwp_m,
1380
        new_e_cwp_w, swap_odd_m_vld, swap_odd_w, cwpswap_tid_m, cwpswap_tid_w,
1381
        kill_restore_w);
1382
 
1383
        input                   clk;
1384
        input                   ifu_exu_ren1_d;
1385
        input                   ifu_exu_ren2_d;
1386
        input                   ifu_exu_ren3_d;
1387
        input   [6:0]            thr_rs1;
1388
        input   [6:0]            thr_rs2;
1389
        input   [6:0]            thr_rs3;
1390
        input   [6:0]            thr_rs3h;
1391
        output  [71:0]           irf_byp_rs1_data_d;
1392
        output  [71:0]           irf_byp_rs2_data_d;
1393
        output  [71:0]           irf_byp_rs3_data_d;
1394
        output  [71:0]           irf_byp_rs3h_data_d;
1395
        input                   wr_en;
1396
        input                   wr_en2;
1397
        input   [71:0]           active_win_thr_rd_w_neg;
1398
        input   [71:0]           active_win_thr_rd_w2_neg;
1399
        input   [6:0]            thr_rd_w_neg;
1400
        input   [6:0]            thr_rd_w2_neg;
1401
        input                   swap_global_d1_vld;
1402
        input                   swap_global_d2;
1403
        input   [1:0]            global_tid_d1;
1404
        input   [1:0]            global_tid_d2;
1405
        input   [1:0]            old_agp_d1;
1406
        input   [1:0]            new_agp_d2;
1407
        input                   swap_local_m_vld;
1408
        input                   swap_local_w;
1409
        input   [2:0]            old_lo_cwp_m;
1410
        input   [2:0]            new_lo_cwp_w;
1411
        input                   swap_even_m_vld;
1412
        input                   swap_even_w;
1413
        input   [1:0]            old_e_cwp_m;
1414
        input   [1:0]            new_e_cwp_w;
1415
        input                   swap_odd_m_vld;
1416
        input                   swap_odd_w;
1417
        input   [1:0]            cwpswap_tid_m;
1418
        input   [1:0]            cwpswap_tid_w;
1419
        input                   kill_restore_w;
1420
 
1421
        reg     [71:0]           irf_byp_rs1_data_d;
1422
        reg     [71:0]           irf_byp_rs2_data_d;
1423
        reg     [71:0]           irf_byp_rs3_data_d;
1424
        reg     [71:0]           irf_byp_rs3h_data_d;
1425
        wire    [71:0]           rd_data00;
1426
        wire    [71:0]           rd_data01;
1427
        wire    [71:0]           rd_data02;
1428
        wire    [71:0]           rd_data03;
1429
        wire    [71:0]           rd_data04;
1430
        wire    [71:0]           rd_data05;
1431
        wire    [71:0]           rd_data06;
1432
        wire    [71:0]           rd_data07;
1433
        wire    [71:0]           rd_data08;
1434
        wire    [71:0]           rd_data09;
1435
        wire    [71:0]           rd_data10;
1436
        wire    [71:0]           rd_data11;
1437
        wire    [71:0]           rd_data12;
1438
        wire    [71:0]           rd_data13;
1439
        wire    [71:0]           rd_data14;
1440
        wire    [71:0]           rd_data15;
1441
        wire    [71:0]           rd_data16;
1442
        wire    [71:0]           rd_data17;
1443
        wire    [71:0]           rd_data18;
1444
        wire    [71:0]           rd_data19;
1445
        wire    [71:0]           rd_data20;
1446
        wire    [71:0]           rd_data21;
1447
        wire    [71:0]           rd_data22;
1448
        wire    [71:0]           rd_data23;
1449
        wire    [71:0]           rd_data24;
1450
        wire    [71:0]           rd_data25;
1451
        wire    [71:0]           rd_data26;
1452
        wire    [71:0]           rd_data27;
1453
        wire    [71:0]           rd_data28;
1454
        wire    [71:0]           rd_data29;
1455
        wire    [71:0]           rd_data30;
1456
        wire    [71:0]           rd_data31;
1457
        wire                    wren;
1458
        wire    [4:0]            wr_addr;
1459
        wire    [71:0]           wr_data;
1460
 
1461
 
1462
        wire    [127:0]  wr_en1s = (wr_en << {thr_rd_w_neg[4:0],thr_rd_w_neg[6:5]});
1463
        wire    [127:0] wr_en2s = (wr_en2 << {thr_rd_w2_neg[4:0],thr_rd_w2_neg[6:5]});
1464
        wire    [127:0]  wrens = wr_en1s | wr_en2s;
1465
 
1466
        wire    [3:0]    wr_th1 = wr_en << thr_rd_w_neg[6:5];
1467
 
1468
        wire    [71:0]   wr_data0 = wr_th1[0] ? active_win_thr_rd_w_neg : active_win_thr_rd_w2_neg;
1469
        wire    [71:0]   wr_data1 = wr_th1[1] ? active_win_thr_rd_w_neg : active_win_thr_rd_w2_neg;
1470
        wire    [71:0]   wr_data2 = wr_th1[2] ? active_win_thr_rd_w_neg : active_win_thr_rd_w2_neg;
1471
        wire    [71:0]   wr_data3 = wr_th1[3] ? active_win_thr_rd_w_neg : active_win_thr_rd_w2_neg;
1472
 
1473
 
1474
        bw_r_irf_register register00(
1475
                .clk                            (clk),
1476
                .wrens                          (wrens[3:0]),
1477
                .save                           (swap_global_d1_vld),
1478
                .save_addr                      ({global_tid_d1, 1'b0, old_agp_d1[1:0]}),
1479
                .restore                        (swap_global_d2),
1480
                .restore_addr                   ({global_tid_d2, 1'b0, new_agp_d2[1:0]}),
1481
                .wr_data0                       (72'b0),
1482
                .wr_data1                       (72'b0),
1483
                .wr_data2                       (72'b0),
1484
                .wr_data3                       (72'b0),
1485
                .rd_thread                      (thr_rs1[6:5]),
1486
                .rd_data                        (rd_data00));
1487
        bw_r_irf_register register01(
1488
                .clk                            (clk),
1489
                .wrens                          (wrens[7:4]),
1490
                .save                           (swap_global_d1_vld),
1491
                .save_addr                      ({global_tid_d1, 1'b0, old_agp_d1[1:0]}),
1492
                .restore                        (swap_global_d2),
1493
                .restore_addr                   ({global_tid_d2, 1'b0, new_agp_d2[1:0]}),
1494
                .wr_data0                       (wr_data0),
1495
                .wr_data1                       (wr_data1),
1496
                .wr_data2                       (wr_data2),
1497
                .wr_data3                       (wr_data3),
1498
                .rd_thread                      (thr_rs1[6:5]),
1499
                .rd_data                        (rd_data01));
1500
        bw_r_irf_register register02(
1501
                .clk                            (clk),
1502
                .wrens                          (wrens[11:8]),
1503
                .save                           (swap_global_d1_vld),
1504
                .save_addr                      ({global_tid_d1, 1'b0, old_agp_d1[1:0]}),
1505
                .restore                        (swap_global_d2),
1506
                .restore_addr                   ({global_tid_d2, 1'b0, new_agp_d2[1:0]}),
1507
                .wr_data0                       (wr_data0),
1508
                .wr_data1                       (wr_data1),
1509
                .wr_data2                       (wr_data2),
1510
                .wr_data3                       (wr_data3),
1511
                .rd_thread                      (thr_rs1[6:5]),
1512
                .rd_data                        (rd_data02));
1513
        bw_r_irf_register register03(
1514
                .clk                            (clk),
1515
                .wrens                          (wrens[15:12]),
1516
                .save                           (swap_global_d1_vld),
1517
                .save_addr                      ({global_tid_d1, 1'b0, old_agp_d1[1:0]}),
1518
                .restore                        (swap_global_d2),
1519
                .restore_addr                   ({global_tid_d2, 1'b0, new_agp_d2[1:0]}),
1520
                .wr_data0                       (wr_data0),
1521
                .wr_data1                       (wr_data1),
1522
                .wr_data2                       (wr_data2),
1523
                .wr_data3                       (wr_data3),
1524
                .rd_thread                      (thr_rs1[6:5]),
1525
                .rd_data                        (rd_data03));
1526
        bw_r_irf_register register04(
1527
                .clk                            (clk),
1528
                .wrens                          (wrens[19:16]),
1529
                .save                           (swap_global_d1_vld),
1530
                .save_addr                      ({global_tid_d1, 1'b0, old_agp_d1[1:0]}),
1531
                .restore                        (swap_global_d2),
1532
                .restore_addr                   ({global_tid_d2, 1'b0, new_agp_d2[1:0]}),
1533
                .wr_data0                       (wr_data0),
1534
                .wr_data1                       (wr_data1),
1535
                .wr_data2                       (wr_data2),
1536
                .wr_data3                       (wr_data3),
1537
                .rd_thread                      (thr_rs1[6:5]),
1538
                .rd_data                        (rd_data04));
1539
        bw_r_irf_register register05(
1540
                .clk                            (clk),
1541
                .wrens                          (wrens[23:20]),
1542
                .save                           (swap_global_d1_vld),
1543
                .save_addr                      ({global_tid_d1, 1'b0, old_agp_d1[1:0]}),
1544
                .restore                        (swap_global_d2),
1545
                .restore_addr                   ({global_tid_d2, 1'b0, new_agp_d2[1:0]}),
1546
                .wr_data0                       (wr_data0),
1547
                .wr_data1                       (wr_data1),
1548
                .wr_data2                       (wr_data2),
1549
                .wr_data3                       (wr_data3),
1550
                .rd_thread                      (thr_rs1[6:5]),
1551
                .rd_data                        (rd_data05));
1552
        bw_r_irf_register register06(
1553
                .clk                            (clk),
1554
                .wrens                          (wrens[27:24]),
1555
                .save                           (swap_global_d1_vld),
1556
                .save_addr                      ({global_tid_d1, 1'b0, old_agp_d1[1:0]}),
1557
                .restore                        (swap_global_d2),
1558
                .restore_addr                   ({global_tid_d2, 1'b0, new_agp_d2[1:0]}),
1559
                .wr_data0                       (wr_data0),
1560
                .wr_data1                       (wr_data1),
1561
                .wr_data2                       (wr_data2),
1562
                .wr_data3                       (wr_data3),
1563
                .rd_thread                      (thr_rs1[6:5]),
1564
                .rd_data                        (rd_data06));
1565
        bw_r_irf_register register07(
1566
                .clk                            (clk),
1567
                .wrens                          (wrens[31:28]),
1568
                .save                           (swap_global_d1_vld),
1569
                .save_addr                      ({global_tid_d1, 1'b0, old_agp_d1[1:0]}),
1570
                .restore                        (swap_global_d2),
1571
                .restore_addr                   ({global_tid_d2, 1'b0, new_agp_d2[1:0]}),
1572
                .wr_data0                       (wr_data0),
1573
                .wr_data1                       (wr_data1),
1574
                .wr_data2                       (wr_data2),
1575
                .wr_data3                       (wr_data3),
1576
                .rd_thread                      (thr_rs1[6:5]),
1577
                .rd_data                        (rd_data07));
1578
 
1579
        bw_r_irf_register register08(
1580
                .clk                            (clk),
1581
                .wrens                          (wrens[35:32]),
1582
                .save                           (swap_odd_m_vld),
1583
                .save_addr                      ({cwpswap_tid_m, 1'b0, old_lo_cwp_m[2:1]}),
1584
                .restore                        ((swap_odd_w & (~kill_restore_w))),
1585
                .restore_addr                   ({cwpswap_tid_w,1'b0, new_lo_cwp_w[2:1]}),
1586
                .wr_data0                       (wr_data0),
1587
                .wr_data1                       (wr_data1),
1588
                .wr_data2                       (wr_data2),
1589
                .wr_data3                       (wr_data3),
1590
                .rd_thread                      (thr_rs1[6:5]),
1591
                .rd_data                        (rd_data08));
1592
        bw_r_irf_register register09(
1593
                .clk                            (clk),
1594
                .wrens                          (wrens[39:36]),
1595
                .save                           (swap_odd_m_vld),
1596
                .save_addr                      ({cwpswap_tid_m, 1'b0, old_lo_cwp_m[2:1]}),
1597
                .restore                        ((swap_odd_w & (~kill_restore_w))),
1598
                .restore_addr                   ({cwpswap_tid_w,1'b0, new_lo_cwp_w[2:1]}),
1599
                .wr_data0                       (wr_data0),
1600
                .wr_data1                       (wr_data1),
1601
                .wr_data2                       (wr_data2),
1602
                .wr_data3                       (wr_data3),
1603
                .rd_thread                      (thr_rs1[6:5]),
1604
                .rd_data                        (rd_data09));
1605
        bw_r_irf_register register10(
1606
                .clk                            (clk),
1607
                .wrens                          (wrens[43:40]),
1608
                .save                           (swap_odd_m_vld),
1609
                .save_addr                      ({cwpswap_tid_m, 1'b0, old_lo_cwp_m[2:1]}),
1610
                .restore                        ((swap_odd_w & (~kill_restore_w))),
1611
                .restore_addr                   ({cwpswap_tid_w,1'b0, new_lo_cwp_w[2:1]}),
1612
                .wr_data0                       (wr_data0),
1613
                .wr_data1                       (wr_data1),
1614
                .wr_data2                       (wr_data2),
1615
                .wr_data3                       (wr_data3),
1616
                .rd_thread                      (thr_rs1[6:5]),
1617
                .rd_data                        (rd_data10));
1618
        bw_r_irf_register register11(
1619
                .clk                            (clk),
1620
                .wrens                          (wrens[47:44]),
1621
                .save                           (swap_odd_m_vld),
1622
                .save_addr                      ({cwpswap_tid_m, 1'b0, old_lo_cwp_m[2:1]}),
1623
                .restore                        ((swap_odd_w & (~kill_restore_w))),
1624
                .restore_addr                   ({cwpswap_tid_w,1'b0, new_lo_cwp_w[2:1]}),
1625
                .wr_data0                       (wr_data0),
1626
                .wr_data1                       (wr_data1),
1627
                .wr_data2                       (wr_data2),
1628
                .wr_data3                       (wr_data3),
1629
                .rd_thread                      (thr_rs1[6:5]),
1630
                .rd_data                        (rd_data11));
1631
        bw_r_irf_register register12(
1632
                .clk                            (clk),
1633
                .wrens                          (wrens[51:48]),
1634
                .save                           (swap_odd_m_vld),
1635
                .save_addr                      ({cwpswap_tid_m, 1'b0, old_lo_cwp_m[2:1]}),
1636
                .restore                        ((swap_odd_w & (~kill_restore_w))),
1637
                .restore_addr                   ({cwpswap_tid_w,1'b0, new_lo_cwp_w[2:1]}),
1638
                .wr_data0                       (wr_data0),
1639
                .wr_data1                       (wr_data1),
1640
                .wr_data2                       (wr_data2),
1641
                .wr_data3                       (wr_data3),
1642
                .rd_thread                      (thr_rs1[6:5]),
1643
                .rd_data                        (rd_data12));
1644
        bw_r_irf_register register13(
1645
                .clk                            (clk),
1646
                .wrens                          (wrens[55:52]),
1647
                .save                           (swap_odd_m_vld),
1648
                .save_addr                      ({cwpswap_tid_m, 1'b0, old_lo_cwp_m[2:1]}),
1649
                .restore                        ((swap_odd_w & (~kill_restore_w))),
1650
                .restore_addr                   ({cwpswap_tid_w,1'b0, new_lo_cwp_w[2:1]}),
1651
                .wr_data0                       (wr_data0),
1652
                .wr_data1                       (wr_data1),
1653
                .wr_data2                       (wr_data2),
1654
                .wr_data3                       (wr_data3),
1655
                .rd_thread                      (thr_rs1[6:5]),
1656
                .rd_data                        (rd_data13));
1657
        bw_r_irf_register register14(
1658
                .clk                            (clk),
1659
                .wrens                          (wrens[59:56]),
1660
                .save                           (swap_odd_m_vld),
1661
                .save_addr                      ({cwpswap_tid_m, 1'b0, old_lo_cwp_m[2:1]}),
1662
                .restore                        ((swap_odd_w & (~kill_restore_w))),
1663
                .restore_addr                   ({cwpswap_tid_w,1'b0, new_lo_cwp_w[2:1]}),
1664
                .wr_data0                       (wr_data0),
1665
                .wr_data1                       (wr_data1),
1666
                .wr_data2                       (wr_data2),
1667
                .wr_data3                       (wr_data3),
1668
                .rd_thread                      (thr_rs1[6:5]),
1669
                .rd_data                        (rd_data14));
1670
        bw_r_irf_register register15(
1671
                .clk                            (clk),
1672
                .wrens                          (wrens[63:60]),
1673
                .save                           (swap_odd_m_vld),
1674
                .save_addr                      ({cwpswap_tid_m, 1'b0, old_lo_cwp_m[2:1]}),
1675
                .restore                        ((swap_odd_w & (~kill_restore_w))),
1676
                .restore_addr                   ({cwpswap_tid_w,1'b0, new_lo_cwp_w[2:1]}),
1677
                .wr_data0                       (wr_data0),
1678
                .wr_data1                       (wr_data1),
1679
                .wr_data2                       (wr_data2),
1680
                .wr_data3                       (wr_data3),
1681
                .rd_thread                      (thr_rs1[6:5]),
1682
                .rd_data                        (rd_data15));
1683
 
1684
        bw_r_irf_register register16(
1685
                .clk                            (clk),
1686
                .wrens                          (wrens[67:64]),
1687
                .save                           (swap_local_m_vld),
1688
                .save_addr                      ({cwpswap_tid_m, old_lo_cwp_m[2:0]}),
1689
                .restore                        ((swap_local_w & (~kill_restore_w))),
1690
                .restore_addr                   ({cwpswap_tid_w, new_lo_cwp_w[2:0]}),
1691
                .wr_data0                       (wr_data0),
1692
                .wr_data1                       (wr_data1),
1693
                .wr_data2                       (wr_data2),
1694
                .wr_data3                       (wr_data3),
1695
                .rd_thread                      (thr_rs1[6:5]),
1696
                .rd_data                        (rd_data16));
1697
        bw_r_irf_register register17(
1698
                .clk                            (clk),
1699
                .wrens                          (wrens[71:68]),
1700
                .save                           (swap_local_m_vld),
1701
                .save_addr                      ({cwpswap_tid_m, old_lo_cwp_m[2:0]}),
1702
                .restore                        ((swap_local_w & (~kill_restore_w))),
1703
                .restore_addr                   ({cwpswap_tid_w, new_lo_cwp_w[2:0]}),
1704
                .wr_data0                       (wr_data0),
1705
                .wr_data1                       (wr_data1),
1706
                .wr_data2                       (wr_data2),
1707
                .wr_data3                       (wr_data3),
1708
                .rd_thread                      (thr_rs1[6:5]),
1709
                .rd_data                        (rd_data17));
1710
        bw_r_irf_register register18(
1711
                .clk                            (clk),
1712
                .wrens                          (wrens[75:72]),
1713
                .save                           (swap_local_m_vld),
1714
                .save_addr                      ({cwpswap_tid_m, old_lo_cwp_m[2:0]}),
1715
                .restore                        ((swap_local_w & (~kill_restore_w))),
1716
                .restore_addr                   ({cwpswap_tid_w, new_lo_cwp_w[2:0]}),
1717
                .wr_data0                       (wr_data0),
1718
                .wr_data1                       (wr_data1),
1719
                .wr_data2                       (wr_data2),
1720
                .wr_data3                       (wr_data3),
1721
                .rd_thread                      (thr_rs1[6:5]),
1722
                .rd_data                        (rd_data18));
1723
        bw_r_irf_register register19(
1724
                .clk                            (clk),
1725
                .wrens                          (wrens[79:76]),
1726
                .save                           (swap_local_m_vld),
1727
                .save_addr                      ({cwpswap_tid_m, old_lo_cwp_m[2:0]}),
1728
                .restore                        ((swap_local_w & (~kill_restore_w))),
1729
                .restore_addr                   ({cwpswap_tid_w, new_lo_cwp_w[2:0]}),
1730
                .wr_data0                       (wr_data0),
1731
                .wr_data1                       (wr_data1),
1732
                .wr_data2                       (wr_data2),
1733
                .wr_data3                       (wr_data3),
1734
                .rd_thread                      (thr_rs1[6:5]),
1735
                .rd_data                        (rd_data19));
1736
        bw_r_irf_register register20(
1737
                .clk                            (clk),
1738
                .wrens                          (wrens[83:80]),
1739
                .save                           (swap_local_m_vld),
1740
                .save_addr                      ({cwpswap_tid_m, old_lo_cwp_m[2:0]}),
1741
                .restore                        ((swap_local_w & (~kill_restore_w))),
1742
                .restore_addr                   ({cwpswap_tid_w, new_lo_cwp_w[2:0]}),
1743
                .wr_data0                       (wr_data0),
1744
                .wr_data1                       (wr_data1),
1745
                .wr_data2                       (wr_data2),
1746
                .wr_data3                       (wr_data3),
1747
                .rd_thread                      (thr_rs1[6:5]),
1748
                .rd_data                        (rd_data20));
1749
        bw_r_irf_register register21(
1750
                .clk                            (clk),
1751
                .wrens                          (wrens[87:84]),
1752
                .save                           (swap_local_m_vld),
1753
                .save_addr                      ({cwpswap_tid_m, old_lo_cwp_m[2:0]}),
1754
                .restore                        ((swap_local_w & (~kill_restore_w))),
1755
                .restore_addr                   ({cwpswap_tid_w, new_lo_cwp_w[2:0]}),
1756
                .wr_data0                       (wr_data0),
1757
                .wr_data1                       (wr_data1),
1758
                .wr_data2                       (wr_data2),
1759
                .wr_data3                       (wr_data3),
1760
                .rd_thread                      (thr_rs1[6:5]),
1761
                .rd_data                        (rd_data21));
1762
        bw_r_irf_register register22(
1763
                .clk                            (clk),
1764
                .wrens                          (wrens[91:88]),
1765
                .save                           (swap_local_m_vld),
1766
                .save_addr                      ({cwpswap_tid_m, old_lo_cwp_m[2:0]}),
1767
                .restore                        ((swap_local_w & (~kill_restore_w))),
1768
                .restore_addr                   ({cwpswap_tid_w, new_lo_cwp_w[2:0]}),
1769
                .wr_data0                       (wr_data0),
1770
                .wr_data1                       (wr_data1),
1771
                .wr_data2                       (wr_data2),
1772
                .wr_data3                       (wr_data3),
1773
                .rd_thread                      (thr_rs1[6:5]),
1774
                .rd_data                        (rd_data22));
1775
        bw_r_irf_register register23(
1776
                .clk                            (clk),
1777
                .wrens                          (wrens[95:92]),
1778
                .save                           (swap_local_m_vld),
1779
                .save_addr                      ({cwpswap_tid_m, old_lo_cwp_m[2:0]}),
1780
                .restore                        ((swap_local_w & (~kill_restore_w))),
1781
                .restore_addr                   ({cwpswap_tid_w, new_lo_cwp_w[2:0]}),
1782
                .wr_data0                       (wr_data0),
1783
                .wr_data1                       (wr_data1),
1784
                .wr_data2                       (wr_data2),
1785
                .wr_data3                       (wr_data3),
1786
                .rd_thread                      (thr_rs1[6:5]),
1787
                .rd_data                        (rd_data23));
1788
 
1789
        bw_r_irf_register register24(
1790
                .clk                            (clk),
1791
                .wrens                          (wrens[99:96]),
1792
                .save                           (swap_even_m_vld),
1793
                .save_addr                      ({cwpswap_tid_m[1:0], 1'b0, old_e_cwp_m[1:0]}),
1794
                .restore                        ((swap_even_w & (~kill_restore_w))),
1795
                .restore_addr                   ({cwpswap_tid_w[1:0], 1'b0, new_e_cwp_w[1:0]}),
1796
                .wr_data0                       (wr_data0),
1797
                .wr_data1                       (wr_data1),
1798
                .wr_data2                       (wr_data2),
1799
                .wr_data3                       (wr_data3),
1800
                .rd_thread                      (thr_rs1[6:5]),
1801
                .rd_data                        (rd_data24));
1802
        bw_r_irf_register register25(
1803
                .clk                            (clk),
1804
                .wrens                          (wrens[103:100]),
1805
                .save                           (swap_even_m_vld),
1806
                .save_addr                      ({cwpswap_tid_m[1:0], 1'b0, old_e_cwp_m[1:0]}),
1807
                .restore                        ((swap_even_w & (~kill_restore_w))),
1808
                .restore_addr                   ({cwpswap_tid_w[1:0], 1'b0, new_e_cwp_w[1:0]}),
1809
                .wr_data0                       (wr_data0),
1810
                .wr_data1                       (wr_data1),
1811
                .wr_data2                       (wr_data2),
1812
                .wr_data3                       (wr_data3),
1813
                .rd_thread                      (thr_rs1[6:5]),
1814
                .rd_data                        (rd_data25));
1815
        bw_r_irf_register register26(
1816
                .clk                            (clk),
1817
                .wrens                          (wrens[107:104]),
1818
                .save                           (swap_even_m_vld),
1819
                .save_addr                      ({cwpswap_tid_m[1:0], 1'b0, old_e_cwp_m[1:0]}),
1820
                .restore                        ((swap_even_w & (~kill_restore_w))),
1821
                .restore_addr                   ({cwpswap_tid_w[1:0], 1'b0, new_e_cwp_w[1:0]}),
1822
                .wr_data0                       (wr_data0),
1823
                .wr_data1                       (wr_data1),
1824
                .wr_data2                       (wr_data2),
1825
                .wr_data3                       (wr_data3),
1826
                .rd_thread                      (thr_rs1[6:5]),
1827
                .rd_data                        (rd_data26));
1828
        bw_r_irf_register register27(
1829
                .clk                            (clk),
1830
                .wrens                          (wrens[111:108]),
1831
                .save                           (swap_even_m_vld),
1832
                .save_addr                      ({cwpswap_tid_m[1:0], 1'b0, old_e_cwp_m[1:0]}),
1833
                .restore                        ((swap_even_w & (~kill_restore_w))),
1834
                .restore_addr                   ({cwpswap_tid_w[1:0], 1'b0, new_e_cwp_w[1:0]}),
1835
                .wr_data0                       (wr_data0),
1836
                .wr_data1                       (wr_data1),
1837
                .wr_data2                       (wr_data2),
1838
                .wr_data3                       (wr_data3),
1839
                .rd_thread                      (thr_rs1[6:5]),
1840
                .rd_data                        (rd_data27));
1841
        bw_r_irf_register register28(
1842
                .clk                            (clk),
1843
                .wrens                          (wrens[115:112]),
1844
                .save                           (swap_even_m_vld),
1845
                .save_addr                      ({cwpswap_tid_m[1:0], 1'b0, old_e_cwp_m[1:0]}),
1846
                .restore                        ((swap_even_w & (~kill_restore_w))),
1847
                .restore_addr                   ({cwpswap_tid_w[1:0], 1'b0, new_e_cwp_w[1:0]}),
1848
                .wr_data0                       (wr_data0),
1849
                .wr_data1                       (wr_data1),
1850
                .wr_data2                       (wr_data2),
1851
                .wr_data3                       (wr_data3),
1852
                .rd_thread                      (thr_rs1[6:5]),
1853
                .rd_data                        (rd_data28));
1854
        bw_r_irf_register register29(
1855
                .clk                            (clk),
1856
                .wrens                          (wrens[119:116]),
1857
                .save                           (swap_even_m_vld),
1858
                .save_addr                      ({cwpswap_tid_m[1:0], 1'b0, old_e_cwp_m[1:0]}),
1859
                .restore                        ((swap_even_w & (~kill_restore_w))),
1860
                .restore_addr                   ({cwpswap_tid_w[1:0], 1'b0, new_e_cwp_w[1:0]}),
1861
                .wr_data0                       (wr_data0),
1862
                .wr_data1                       (wr_data1),
1863
                .wr_data2                       (wr_data2),
1864
                .wr_data3                       (wr_data3),
1865
                .rd_thread                      (thr_rs1[6:5]),
1866
                .rd_data                        (rd_data29));
1867
        bw_r_irf_register register30(
1868
                .clk                            (clk),
1869
                .wrens                          (wrens[123:120]),
1870
                .save                           (swap_even_m_vld),
1871
                .save_addr                      ({cwpswap_tid_m[1:0], 1'b0, old_e_cwp_m[1:0]}),
1872
                .restore                        ((swap_even_w & (~kill_restore_w))),
1873
                .restore_addr                   ({cwpswap_tid_w[1:0], 1'b0, new_e_cwp_w[1:0]}),
1874
                .wr_data0                       (wr_data0),
1875
                .wr_data1                       (wr_data1),
1876
                .wr_data2                       (wr_data2),
1877
                .wr_data3                       (wr_data3),
1878
                .rd_thread                      (thr_rs1[6:5]),
1879
                .rd_data                        (rd_data30));
1880
        bw_r_irf_register register31(
1881
                .clk                            (clk),
1882
                .wrens                          (wrens[127:124]),
1883
                .save                           (swap_even_m_vld),
1884
                .save_addr                      ({cwpswap_tid_m[1:0], 1'b0, old_e_cwp_m[1:0]}),
1885
                .restore                        ((swap_even_w & (~kill_restore_w))),
1886
                .restore_addr                   ({cwpswap_tid_w[1:0], 1'b0, new_e_cwp_w[1:0]}),
1887
                .wr_data0                       (wr_data0),
1888
                .wr_data1                       (wr_data1),
1889
                .wr_data2                       (wr_data2),
1890
                .wr_data3                       (wr_data3),
1891
                .rd_thread                      (thr_rs1[6:5]),
1892
                .rd_data                        (rd_data31));
1893
 
1894
 
1895
        always @(negedge clk) if (ifu_exu_ren1_d) begin
1896
          case (thr_rs1[4:0])
1897
            5'b0:
1898
              irf_byp_rs1_data_d <= rd_data00;
1899
            5'b1:
1900
              irf_byp_rs1_data_d <= rd_data01;
1901
            5'b00010:
1902
              irf_byp_rs1_data_d <= rd_data02;
1903
            5'b00011:
1904
              irf_byp_rs1_data_d <= rd_data03;
1905
            5'b00100:
1906
              irf_byp_rs1_data_d <= rd_data04;
1907
            5'b00101:
1908
              irf_byp_rs1_data_d <= rd_data05;
1909
            5'b00110:
1910
              irf_byp_rs1_data_d <= rd_data06;
1911
            5'b00111:
1912
              irf_byp_rs1_data_d <= rd_data07;
1913
            5'b01000:
1914
              irf_byp_rs1_data_d <= rd_data08;
1915
            5'b01001:
1916
              irf_byp_rs1_data_d <= rd_data09;
1917
            5'b01010:
1918
              irf_byp_rs1_data_d <= rd_data10;
1919
            5'b01011:
1920
              irf_byp_rs1_data_d <= rd_data11;
1921
            5'b01100:
1922
              irf_byp_rs1_data_d <= rd_data12;
1923
            5'b01101:
1924
              irf_byp_rs1_data_d <= rd_data13;
1925
            5'b01110:
1926
              irf_byp_rs1_data_d <= rd_data14;
1927
            5'b01111:
1928
              irf_byp_rs1_data_d <= rd_data15;
1929
            5'b10000:
1930
              irf_byp_rs1_data_d <= rd_data16;
1931
            5'b10001:
1932
              irf_byp_rs1_data_d <= rd_data17;
1933
            5'b10010:
1934
              irf_byp_rs1_data_d <= rd_data18;
1935
            5'b10011:
1936
              irf_byp_rs1_data_d <= rd_data19;
1937
            5'b10100:
1938
              irf_byp_rs1_data_d <= rd_data20;
1939
            5'b10101:
1940
              irf_byp_rs1_data_d <= rd_data21;
1941
            5'b10110:
1942
              irf_byp_rs1_data_d <= rd_data22;
1943
            5'b10111:
1944
              irf_byp_rs1_data_d <= rd_data23;
1945
            5'b11000:
1946
              irf_byp_rs1_data_d <= rd_data24;
1947
            5'b11001:
1948
              irf_byp_rs1_data_d <= rd_data25;
1949
            5'b11010:
1950
              irf_byp_rs1_data_d <= rd_data26;
1951
            5'b11011:
1952
              irf_byp_rs1_data_d <= rd_data27;
1953
            5'b11100:
1954
              irf_byp_rs1_data_d <= rd_data28;
1955
            5'b11101:
1956
              irf_byp_rs1_data_d <= rd_data29;
1957
            5'b11110:
1958
              irf_byp_rs1_data_d <= rd_data30;
1959
            5'b11111:
1960
              irf_byp_rs1_data_d <= rd_data31;
1961
          endcase
1962
        end
1963
        always @(negedge clk) if (ifu_exu_ren2_d) begin
1964
          case (thr_rs2[4:0])
1965
            5'b0:
1966
              irf_byp_rs2_data_d <= rd_data00;
1967
            5'b1:
1968
              irf_byp_rs2_data_d <= rd_data01;
1969
            5'b00010:
1970
              irf_byp_rs2_data_d <= rd_data02;
1971
            5'b00011:
1972
              irf_byp_rs2_data_d <= rd_data03;
1973
            5'b00100:
1974
              irf_byp_rs2_data_d <= rd_data04;
1975
            5'b00101:
1976
              irf_byp_rs2_data_d <= rd_data05;
1977
            5'b00110:
1978
              irf_byp_rs2_data_d <= rd_data06;
1979
            5'b00111:
1980
              irf_byp_rs2_data_d <= rd_data07;
1981
            5'b01000:
1982
              irf_byp_rs2_data_d <= rd_data08;
1983
            5'b01001:
1984
              irf_byp_rs2_data_d <= rd_data09;
1985
            5'b01010:
1986
              irf_byp_rs2_data_d <= rd_data10;
1987
            5'b01011:
1988
              irf_byp_rs2_data_d <= rd_data11;
1989
            5'b01100:
1990
              irf_byp_rs2_data_d <= rd_data12;
1991
            5'b01101:
1992
              irf_byp_rs2_data_d <= rd_data13;
1993
            5'b01110:
1994
              irf_byp_rs2_data_d <= rd_data14;
1995
            5'b01111:
1996
              irf_byp_rs2_data_d <= rd_data15;
1997
            5'b10000:
1998
              irf_byp_rs2_data_d <= rd_data16;
1999
            5'b10001:
2000
              irf_byp_rs2_data_d <= rd_data17;
2001
            5'b10010:
2002
              irf_byp_rs2_data_d <= rd_data18;
2003
            5'b10011:
2004
              irf_byp_rs2_data_d <= rd_data19;
2005
            5'b10100:
2006
              irf_byp_rs2_data_d <= rd_data20;
2007
            5'b10101:
2008
              irf_byp_rs2_data_d <= rd_data21;
2009
            5'b10110:
2010
              irf_byp_rs2_data_d <= rd_data22;
2011
            5'b10111:
2012
              irf_byp_rs2_data_d <= rd_data23;
2013
            5'b11000:
2014
              irf_byp_rs2_data_d <= rd_data24;
2015
            5'b11001:
2016
              irf_byp_rs2_data_d <= rd_data25;
2017
            5'b11010:
2018
              irf_byp_rs2_data_d <= rd_data26;
2019
            5'b11011:
2020
              irf_byp_rs2_data_d <= rd_data27;
2021
            5'b11100:
2022
              irf_byp_rs2_data_d <= rd_data28;
2023
            5'b11101:
2024
              irf_byp_rs2_data_d <= rd_data29;
2025
            5'b11110:
2026
              irf_byp_rs2_data_d <= rd_data30;
2027
            5'b11111:
2028
              irf_byp_rs2_data_d <= rd_data31;
2029
          endcase
2030
        end
2031
        always @(negedge clk) if (ifu_exu_ren3_d) begin
2032
          case (thr_rs3[4:0])
2033
            5'b0:
2034
              irf_byp_rs3_data_d <= rd_data00;
2035
            5'b1:
2036
              irf_byp_rs3_data_d <= rd_data01;
2037
            5'b00010:
2038
              irf_byp_rs3_data_d <= rd_data02;
2039
            5'b00011:
2040
              irf_byp_rs3_data_d <= rd_data03;
2041
            5'b00100:
2042
              irf_byp_rs3_data_d <= rd_data04;
2043
            5'b00101:
2044
              irf_byp_rs3_data_d <= rd_data05;
2045
            5'b00110:
2046
              irf_byp_rs3_data_d <= rd_data06;
2047
            5'b00111:
2048
              irf_byp_rs3_data_d <= rd_data07;
2049
            5'b01000:
2050
              irf_byp_rs3_data_d <= rd_data08;
2051
            5'b01001:
2052
              irf_byp_rs3_data_d <= rd_data09;
2053
            5'b01010:
2054
              irf_byp_rs3_data_d <= rd_data10;
2055
            5'b01011:
2056
              irf_byp_rs3_data_d <= rd_data11;
2057
            5'b01100:
2058
              irf_byp_rs3_data_d <= rd_data12;
2059
            5'b01101:
2060
              irf_byp_rs3_data_d <= rd_data13;
2061
            5'b01110:
2062
              irf_byp_rs3_data_d <= rd_data14;
2063
            5'b01111:
2064
              irf_byp_rs3_data_d <= rd_data15;
2065
            5'b10000:
2066
              irf_byp_rs3_data_d <= rd_data16;
2067
            5'b10001:
2068
              irf_byp_rs3_data_d <= rd_data17;
2069
            5'b10010:
2070
              irf_byp_rs3_data_d <= rd_data18;
2071
            5'b10011:
2072
              irf_byp_rs3_data_d <= rd_data19;
2073
            5'b10100:
2074
              irf_byp_rs3_data_d <= rd_data20;
2075
            5'b10101:
2076
              irf_byp_rs3_data_d <= rd_data21;
2077
            5'b10110:
2078
              irf_byp_rs3_data_d <= rd_data22;
2079
            5'b10111:
2080
              irf_byp_rs3_data_d <= rd_data23;
2081
            5'b11000:
2082
              irf_byp_rs3_data_d <= rd_data24;
2083
            5'b11001:
2084
              irf_byp_rs3_data_d <= rd_data25;
2085
            5'b11010:
2086
              irf_byp_rs3_data_d <= rd_data26;
2087
            5'b11011:
2088
              irf_byp_rs3_data_d <= rd_data27;
2089
            5'b11100:
2090
              irf_byp_rs3_data_d <= rd_data28;
2091
            5'b11101:
2092
              irf_byp_rs3_data_d <= rd_data29;
2093
            5'b11110:
2094
              irf_byp_rs3_data_d <= rd_data30;
2095
            5'b11111:
2096
              irf_byp_rs3_data_d <= rd_data31;
2097
          endcase
2098
        end
2099
        always @(negedge clk) if (ifu_exu_ren3_d) begin
2100
          case (thr_rs3h[4:1])
2101
            4'b0:
2102
              irf_byp_rs3h_data_d <= rd_data01;
2103
            4'b1:
2104
              irf_byp_rs3h_data_d <= rd_data03;
2105
            4'b0010:
2106
              irf_byp_rs3h_data_d <= rd_data05;
2107
            4'b0011:
2108
              irf_byp_rs3h_data_d <= rd_data07;
2109
            4'b0100:
2110
              irf_byp_rs3h_data_d <= rd_data09;
2111
            4'b0101:
2112
              irf_byp_rs3h_data_d <= rd_data11;
2113
            4'b0110:
2114
              irf_byp_rs3h_data_d <= rd_data13;
2115
            4'b0111:
2116
              irf_byp_rs3h_data_d <= rd_data15;
2117
            4'b1000:
2118
              irf_byp_rs3h_data_d <= rd_data17;
2119
            4'b1001:
2120
              irf_byp_rs3h_data_d <= rd_data19;
2121
            4'b1010:
2122
              irf_byp_rs3h_data_d <= rd_data21;
2123
            4'b1011:
2124
              irf_byp_rs3h_data_d <= rd_data23;
2125
            4'b1100:
2126
              irf_byp_rs3h_data_d <= rd_data25;
2127
            4'b1101:
2128
              irf_byp_rs3h_data_d <= rd_data27;
2129
            4'b1110:
2130
              irf_byp_rs3h_data_d <= rd_data29;
2131
            4'b1111:
2132
              irf_byp_rs3h_data_d <= rd_data31;
2133
          endcase
2134
        end
2135
endmodule
2136
 
2137 113 albert.wat
`endif
2138
`else
2139 95 fafa1971
 
2140 113 albert.wat
module bw_r_irf (/*AUTOARG*/
2141
   // Outputs
2142
   so, irf_byp_rs1_data_d_l, irf_byp_rs2_data_d_l,
2143
   irf_byp_rs3_data_d_l, irf_byp_rs3h_data_d_l,
2144
   // Inputs
2145
   rclk, reset_l, si, se, sehold, rst_tri_en, ifu_exu_tid_s2,
2146
   ifu_exu_rs1_s, ifu_exu_rs2_s, ifu_exu_rs3_s, ifu_exu_ren1_s,
2147
   ifu_exu_ren2_s, ifu_exu_ren3_s, ecl_irf_wen_w, ecl_irf_wen_w2,
2148
   ecl_irf_rd_m, ecl_irf_rd_g, byp_irf_rd_data_w, byp_irf_rd_data_w2,
2149
   ecl_irf_tid_m, ecl_irf_tid_g, rml_irf_old_lo_cwp_e,
2150
   rml_irf_new_lo_cwp_e, rml_irf_old_e_cwp_e, rml_irf_new_e_cwp_e,
2151
   rml_irf_swap_even_e, rml_irf_swap_odd_e, rml_irf_swap_local_e,
2152
   rml_irf_kill_restore_w, rml_irf_cwpswap_tid_e, rml_irf_old_agp,
2153
   rml_irf_new_agp, rml_irf_swap_global, rml_irf_global_tid
2154
   ) ;
2155
   input rclk;
2156
   input reset_l;
2157
   input si;
2158
   input se;
2159
   input sehold;
2160
   input rst_tri_en;
2161
   input [1:0]  ifu_exu_tid_s2;  // s stage thread
2162
   input [4:0]  ifu_exu_rs1_s;  // source addresses
2163
   input [4:0]  ifu_exu_rs2_s;
2164
   input [4:0]  ifu_exu_rs3_s;
2165
   input ifu_exu_ren1_s;        // read enables for all 3 ports
2166
   input ifu_exu_ren2_s;
2167
   input ifu_exu_ren3_s;
2168
   input ecl_irf_wen_w;        // write enables for both write ports
2169
   input ecl_irf_wen_w2;
2170
   input [4:0]  ecl_irf_rd_m;   // w destination
2171
   input [4:0]  ecl_irf_rd_g;  // w2 destination
2172
   input [71:0] byp_irf_rd_data_w;// write data from w1
2173
   input [71:0] byp_irf_rd_data_w2;     // write data from w2
2174
   input [1:0]  ecl_irf_tid_m;  // w stage thread
2175
   input [1:0]  ecl_irf_tid_g; // w2 thread
2176 95 fafa1971
 
2177 113 albert.wat
   input [2:0]  rml_irf_old_lo_cwp_e;  // current window pointer for locals and odds
2178
   input [2:0]  rml_irf_new_lo_cwp_e;  // target window pointer for locals and odds
2179
   input [2:1]  rml_irf_old_e_cwp_e;  // current window pointer for evens
2180
   input [2:1]  rml_irf_new_e_cwp_e;  // target window pointer for evens
2181
   input        rml_irf_swap_even_e;
2182
   input        rml_irf_swap_odd_e;
2183
   input        rml_irf_swap_local_e;
2184
   input        rml_irf_kill_restore_w;
2185
   input [1:0]  rml_irf_cwpswap_tid_e;
2186 95 fafa1971
 
2187 113 albert.wat
   input [1:0]  rml_irf_old_agp; // alternate global pointer
2188
   input [1:0]  rml_irf_new_agp; // alternate global pointer
2189
   input        rml_irf_swap_global;
2190
   input [1:0]  rml_irf_global_tid;
2191
 
2192
   output       so;
2193
   output [71:0] irf_byp_rs1_data_d_l;
2194
   output [71:0] irf_byp_rs2_data_d_l;
2195
   output [71:0] irf_byp_rs3_data_d_l;
2196
   output [31:0] irf_byp_rs3h_data_d_l;
2197
   reg [71:0] irf_byp_rs1_data_d;
2198
   reg [71:0] irf_byp_rs2_data_d;
2199
   reg [71:0] irf_byp_rs3_data_d;
2200
   reg [71:0] irf_byp_rs3h_data_d;
2201 95 fafa1971
 
2202 113 albert.wat
   reg [71:0]    active_window [127:0];// 32x4 72 bit registers
2203
   reg [71:0]    locals[255:0];      // 4x8x8 registers
2204
   reg [71:0]    evens[127:0];      // 4x4x8 registers
2205
   reg [71:0]    odds[127:0];      // 4x4x8 registers
2206
   reg [71:0]    globals[127:0];      // 4x4x8 registers
2207
   // registers for manipulating windows
2208
   reg [6:0] active_pointer;
2209
   reg [7:0] regfile_pointer;
2210
   reg [5:0] i;
2211 95 fafa1971
 
2212 113 albert.wat
   wire [1:0]  ecl_irf_tid_w;  // w stage thread
2213
   wire [1:0]  ecl_irf_tid_w2; // w2 thread
2214
   wire [4:0]  ecl_irf_rd_w;   // w destination
2215
   wire [4:0]  ecl_irf_rd_w2;  // w2 destination
2216
   wire [1:0]  ifu_exu_thr_d;  // d stage thread
2217
   wire ifu_exu_ren1_d;        // read enables for all 3 ports
2218
   wire ifu_exu_ren2_d;
2219
   wire ifu_exu_ren3_d;
2220
   wire [4:0]  ifu_exu_rs1_d;  // source addresses
2221
   wire [4:0]  ifu_exu_rs2_d;
2222
   wire [4:0]  ifu_exu_rs3_d;
2223
   wire [6:0]    thr_rs1;       // these 5 are a combination of the thr and reg
2224
   wire [6:0]    thr_rs2;       // so that comparison can be done more easily
2225
   wire [6:0]    thr_rs3;
2226
   wire [6:0]    thr_rs3h;
2227
   wire [6:0]    thr_rd_w;
2228
   wire [6:0]    thr_rd_w2;
2229 95 fafa1971
 
2230 113 albert.wat
   reg [1:0] cwpswap_tid_m;
2231
   reg [1:0] cwpswap_tid_w;
2232
   reg [2:0] old_lo_cwp_m;
2233
   reg [2:0] new_lo_cwp_m;
2234
   reg [2:0] new_lo_cwp_w;
2235
   reg [1:0] old_e_cwp_m;
2236
   reg [1:0] new_e_cwp_m;
2237
   reg [1:0] new_e_cwp_w;
2238
   reg       swap_local_m;
2239
   reg       swap_local_w;
2240
   reg       swap_even_m;
2241
   reg       swap_even_w;
2242
   reg       swap_odd_m;
2243
   reg       swap_odd_w;
2244
   reg       kill_restore_d1;
2245
   reg        swap_global_d1;
2246
   reg        swap_global_d2;
2247
   reg [1:0]  global_tid_d1;
2248
   reg [1:0]  global_tid_d2;
2249
   reg [1:0] old_agp_d1,
2250
             new_agp_d1,
2251
             new_agp_d2;
2252 95 fafa1971
 
2253 113 albert.wat
   reg [71:0] active_win_thr_rd_w_neg;
2254
   reg        active_win_thr_rd_w_neg_wr_en;
2255
   reg [6:0]  thr_rd_w_neg;
2256
   reg [71:0] active_win_thr_rd_w2_neg;
2257
   reg        active_win_thr_rd_w2_neg_wr_en;
2258
   reg [6:0]  thr_rd_w2_neg;
2259
   reg        rst_tri_en_neg;
2260
 
2261
   wire          se;
2262
   wire          clk;
2263
   assign        clk = rclk & reset_l;
2264
   wire          ren1_s;
2265
   wire          ren2_s;
2266
   wire          ren3_s;
2267
   wire [4:0]    rs1_s;
2268
   wire [4:0]    rs2_s;
2269
   wire [4:0]    rs3_s;
2270
   wire [1:0]    tid_s;
2271
   wire [1:0]    tid_g;
2272
   wire [1:0]    tid_m;
2273
   wire [4:0]    rd_m;
2274
   wire [4:0]    rd_g;
2275
   wire          kill_restore_w;
2276
   wire          swap_global_d1_vld;
2277
   wire          swap_local_m_vld;
2278
   wire          swap_even_m_vld;
2279
   wire          swap_odd_m_vld;
2280 95 fafa1971
 
2281 113 albert.wat
   assign {ren1_s,ren2_s,ren3_s,rs1_s[4:0],rs2_s[4:0],rs3_s[4:0],tid_s[1:0],tid_g[1:0],tid_m[1:0],
2282
           rd_m[4:0], rd_g[4:0]} = (sehold)?
2283
          {ifu_exu_ren1_d,ifu_exu_ren2_d,ifu_exu_ren3_d,ifu_exu_rs1_d[4:0],ifu_exu_rs2_d[4:0],
2284
           ifu_exu_rs3_d[4:0],ifu_exu_thr_d[1:0],ecl_irf_tid_w2[1:0],ecl_irf_tid_w[1:0],
2285
           ecl_irf_rd_w[4:0],ecl_irf_rd_w2[4:0]}:
2286
          {ifu_exu_ren1_s,ifu_exu_ren2_s,ifu_exu_ren3_s,ifu_exu_rs1_s[4:0],ifu_exu_rs2_s[4:0],
2287
           ifu_exu_rs3_s[4:0],ifu_exu_tid_s2[1:0],ecl_irf_tid_g[1:0],ecl_irf_tid_m[1:0],
2288
           ecl_irf_rd_m[4:0],ecl_irf_rd_g[4:0]};
2289
   // Pipeline flops for irf control signals
2290
   dff_s dff_ren1_s2d(.din(ren1_s), .clk(clk), .q(ifu_exu_ren1_d), .se(se),
2291
                    `SIMPLY_RISC_SCANIN, .so());
2292
   dff_s dff_ren2_s2d(.din(ren2_s), .clk(clk), .q(ifu_exu_ren2_d), .se(se),
2293
                    `SIMPLY_RISC_SCANIN, .so());
2294
   dff_s dff_ren3_s2d(.din(ren3_s), .clk(clk), .q(ifu_exu_ren3_d), .se(se),
2295
                    `SIMPLY_RISC_SCANIN, .so());
2296
   dff_s #5 dff_rs1_s2d(.din(rs1_s[4:0]), .clk(clk), .q(ifu_exu_rs1_d[4:0]), .se(se),
2297
                      `SIMPLY_RISC_SCANIN,.so());
2298
   dff_s #5 dff_rs2_s2d(.din(rs2_s[4:0]), .clk(clk), .q(ifu_exu_rs2_d[4:0]), .se(se),
2299
                      `SIMPLY_RISC_SCANIN,.so());
2300
   dff_s #5 dff_rs3_s2d(.din(rs3_s[4:0]), .clk(clk), .q(ifu_exu_rs3_d[4:0]), .se(se),
2301
                      `SIMPLY_RISC_SCANIN,.so());
2302
   dff_s #2 dff_thr_s2d(.din(tid_s[1:0]), .clk(clk), .q(ifu_exu_thr_d[1:0]), .se(se),
2303
                      `SIMPLY_RISC_SCANIN,.so());
2304
   dff_s #2 dff_thr_g2w2(.din(tid_g[1:0]), .clk(clk), .q(ecl_irf_tid_w2[1:0]), .se(se),
2305
                      `SIMPLY_RISC_SCANIN,.so());
2306
   dff_s #2 dff_thr_m2w(.din(tid_m[1:0]), .clk(clk), .q(ecl_irf_tid_w[1:0]), .se(se),
2307
                      `SIMPLY_RISC_SCANIN,.so());
2308
   dff_s #5 dff_rd_m2w(.din(rd_m[4:0]), .clk(clk), .q(ecl_irf_rd_w[4:0]), .se(se),
2309
                      `SIMPLY_RISC_SCANIN,.so());
2310
   dff_s #5 dff_rd_g2w2(.din(rd_g[4:0]), .clk(clk), .q(ecl_irf_rd_w2[4:0]), .se(se),
2311
                      `SIMPLY_RISC_SCANIN,.so());
2312
 
2313
   // Concatenate the thread and rs1/rd bits together
2314
   assign        thr_rs1[6:0] = {ifu_exu_thr_d, ifu_exu_rs1_d};
2315
   assign        thr_rs2[6:0] = {ifu_exu_thr_d, ifu_exu_rs2_d};
2316
   assign        thr_rs3[6:0] = {ifu_exu_thr_d, ifu_exu_rs3_d[4:0]};
2317
   assign        thr_rs3h[6:0] = {ifu_exu_thr_d[1:0], ifu_exu_rs3_d[4:1], 1'b1};
2318
   assign        thr_rd_w[6:0] = {ecl_irf_tid_w, ecl_irf_rd_w};
2319
   assign        thr_rd_w2[6:0] = {ecl_irf_tid_w2, ecl_irf_rd_w2};
2320 95 fafa1971
 
2321 113 albert.wat
   // Active low outputs
2322
   assign        irf_byp_rs1_data_d_l[71:0] = ~irf_byp_rs1_data_d[71:0];
2323
   assign        irf_byp_rs2_data_d_l[71:0] = ~irf_byp_rs2_data_d[71:0];
2324
   assign        irf_byp_rs3_data_d_l[71:0] = ~irf_byp_rs3_data_d[71:0];
2325
   assign        irf_byp_rs3h_data_d_l[31:0] = ~irf_byp_rs3h_data_d[31:0];
2326
 
2327
   // Read port 1
2328
   always @ ( clk ) begin
2329
      if (clk) irf_byp_rs1_data_d <= {72{1'bx}};
2330
      else begin
2331
         if (ifu_exu_ren1_d) begin // read enable must be high
2332
            if (thr_rs1[4:0] == 5'b0) irf_byp_rs1_data_d <= {72{1'b0}};
2333
            else begin
2334
               if ((ecl_irf_wen_w && (thr_rs1 == thr_rd_w)) || // check r/w conflict
2335
                   (ecl_irf_wen_w2 && (thr_rs1 == thr_rd_w2))) begin
2336
                  irf_byp_rs1_data_d <= {72{1'bx}};  // rw conflict gives x
2337
               end
2338
               else begin
2339
                  irf_byp_rs1_data_d <= active_window[thr_rs1[6:0]];
2340
               end
2341
            end
2342
         end
2343
         // output disabled
2344
         else begin
2345
            irf_byp_rs1_data_d <= {72{1'bx}};
2346
         end
2347
      end
2348
   end
2349
 
2350
   // Read port 2
2351
   always @ ( clk ) begin
2352
      if (clk) irf_byp_rs2_data_d <= {72{1'bx}};
2353
      else begin
2354
         if (ifu_exu_ren2_d) begin
2355
            if (thr_rs2[4:0] == 5'b0) irf_byp_rs2_data_d <= {72{1'b0}};
2356
            else if ((ecl_irf_wen_w && (thr_rs2 == thr_rd_w)) ||
2357
                     (ecl_irf_wen_w2 && (thr_rs2 == thr_rd_w2)))
2358
              irf_byp_rs2_data_d <= {72{1'bx}};
2359
            else begin
2360
               irf_byp_rs2_data_d <= active_window[thr_rs2];
2361
            end
2362
         end
2363
         // output disabled
2364
         else irf_byp_rs2_data_d <= {72{1'bx}};
2365
      end
2366
   end
2367
 
2368
   // Read port 3
2369
   always @ ( clk ) begin
2370
      if (clk) irf_byp_rs3_data_d <= {72{1'bx}};
2371
      else begin
2372
         if (ifu_exu_ren3_d) begin
2373
            if (thr_rs3[4:0] == 5'b0) irf_byp_rs3_data_d[71:0] <= {72{1'b0}};
2374
            else if ((ecl_irf_wen_w && (thr_rs3 == thr_rd_w)) ||
2375
                     (ecl_irf_wen_w2 && (thr_rs3 == thr_rd_w2)))
2376
              begin
2377
                 irf_byp_rs3_data_d[71:0] <= {72{1'bx}};
2378
              end
2379
            else begin
2380
               irf_byp_rs3_data_d[71:0] <= active_window[thr_rs3];
2381
            end
2382
         end
2383
         // output disabled
2384
         else begin
2385
            irf_byp_rs3_data_d[71:0] <= {72{1'bx}};
2386
         end
2387
      end
2388
   end
2389
 
2390
   // Read port 3h
2391
   always @ ( clk ) begin
2392
      if (clk) irf_byp_rs3h_data_d[71:0] <= {72{1'bx}};
2393
      else begin
2394
         if (ifu_exu_ren3_d) begin
2395
            if (thr_rs3h[4:0] == 5'b0) irf_byp_rs3h_data_d[71:0] <= 72'b0;
2396
            else if ((ecl_irf_wen_w && (thr_rs3h == thr_rd_w)) ||
2397
                     (ecl_irf_wen_w2 && (thr_rs3h == thr_rd_w2)))
2398
              begin
2399
                 irf_byp_rs3h_data_d[71:0] <= {72{1'bx}};
2400
              end
2401
            else begin
2402
               irf_byp_rs3h_data_d[71:0] <= active_window[thr_rs3h];
2403
            end
2404
         end
2405
         // output disabled
2406
         else begin
2407
            irf_byp_rs3h_data_d[71:0] <= {72{1'bx}};
2408
         end
2409
      end
2410
   end
2411
 
2412
/////////////////////////////////////////////////////////////////
2413
///  Write ports
2414
////////////////////////////////////////////////////////////////
2415
   // This is a latch that works if both wen is high and clk is low
2416 95 fafa1971
 
2417 113 albert.wat
   always @(negedge clk) begin
2418
      rst_tri_en_neg <= rst_tri_en;
2419
      // write conflict results in X written to destination
2420
      if (ecl_irf_wen_w & ecl_irf_wen_w2 & (thr_rd_w[6:0] == thr_rd_w2[6:0])) begin
2421
         active_win_thr_rd_w_neg <= {72{1'bx}};
2422
         thr_rd_w_neg <= thr_rd_w;
2423
         active_win_thr_rd_w_neg_wr_en <= 1'b1;
2424
         active_win_thr_rd_w2_neg_wr_en <= 1'b0;
2425
      end
2426
      else begin
2427
         // W1 write port
2428
         if (ecl_irf_wen_w & (thr_rd_w[4:0] != 5'b0)) begin
2429
            active_win_thr_rd_w_neg <= byp_irf_rd_data_w;
2430
            thr_rd_w_neg <= thr_rd_w;
2431
            active_win_thr_rd_w_neg_wr_en <= 1'b1;
2432
         end
2433
         else
2434
           active_win_thr_rd_w_neg_wr_en <= 1'b0;
2435
 
2436
         // W2 write port
2437
         if (ecl_irf_wen_w2 & (thr_rd_w2[4:0] != 5'b0)) begin
2438
            active_win_thr_rd_w2_neg <= byp_irf_rd_data_w2;
2439
            thr_rd_w2_neg <= thr_rd_w2;
2440
            active_win_thr_rd_w2_neg_wr_en <= 1'b1;
2441
         end
2442
         else
2443
           active_win_thr_rd_w2_neg_wr_en <= 1'b0;
2444
      end
2445
   end
2446
 
2447 95 fafa1971
 
2448
 
2449 113 albert.wat
/* MOVED TO CMP ENVIRONMENT
2450
   initial begin
2451
      // Hardcode R0 to zero
2452
      active_window[{2'b00, 5'b00000}] = 72'b0;
2453
      active_window[{2'b01, 5'b00000}] = 72'b0;
2454
      active_window[{2'b10, 5'b00000}] = 72'b0;
2455
      active_window[{2'b11, 5'b00000}] = 72'b0;
2456
   end
2457
*/
2458
   //////////////////////////////////////////////////
2459
   // Window management logic
2460
   //////////////////////////////////////////////////
2461
   // Pipeline flops for control signals
2462 95 fafa1971
 
2463 113 albert.wat
   // cwp swap signals
2464
   assign kill_restore_w = (sehold)? kill_restore_d1: rml_irf_kill_restore_w;
2465
   assign swap_local_m_vld = swap_local_m & ~rst_tri_en;
2466
   assign swap_odd_m_vld = swap_odd_m & ~rst_tri_en;
2467
   assign swap_even_m_vld = swap_even_m & ~rst_tri_en;
2468
   assign swap_global_d1_vld = swap_global_d1 & ~rst_tri_en;
2469
 
2470
   always @ (posedge clk) begin
2471
      cwpswap_tid_m[1:0] <= (sehold)? cwpswap_tid_m[1:0]: rml_irf_cwpswap_tid_e[1:0];
2472
      cwpswap_tid_w[1:0] <= cwpswap_tid_m[1:0];
2473
      old_lo_cwp_m[2:0] <= (sehold)? old_lo_cwp_m[2:0]: rml_irf_old_lo_cwp_e[2:0];
2474
      new_lo_cwp_m[2:0] <= (sehold)? new_lo_cwp_m[2:0]: rml_irf_new_lo_cwp_e[2:0];
2475
      new_lo_cwp_w[2:0] <= new_lo_cwp_m[2:0];
2476
      old_e_cwp_m[1:0] <= (sehold)? old_e_cwp_m[1:0]: rml_irf_old_e_cwp_e[2:1];
2477
      new_e_cwp_m[1:0] <= (sehold)? new_e_cwp_m[1:0]: rml_irf_new_e_cwp_e[2:1];
2478
      new_e_cwp_w[1:0] <= new_e_cwp_m[1:0];
2479
      swap_local_m <= (sehold)? swap_local_m & rst_tri_en: rml_irf_swap_local_e;
2480
      swap_local_w <= swap_local_m_vld;
2481
      swap_odd_m <= (sehold)? swap_odd_m & rst_tri_en: rml_irf_swap_odd_e;
2482
      swap_odd_w <= swap_odd_m_vld;
2483
      swap_even_m <= (sehold)? swap_even_m & rst_tri_en: rml_irf_swap_even_e;
2484
      swap_even_w <= swap_even_m_vld;
2485
      kill_restore_d1 <= kill_restore_w;
2486
   end
2487
   // global swap signals    
2488
   always @ (posedge clk) begin
2489
      swap_global_d1 <= (sehold)? swap_global_d1 & rst_tri_en: rml_irf_swap_global;
2490
      swap_global_d2 <= swap_global_d1_vld;
2491
      global_tid_d1[1:0] <= (sehold)? global_tid_d1[1:0]: rml_irf_global_tid[1:0];
2492
      global_tid_d2[1:0] <= global_tid_d1[1:0];
2493
      old_agp_d1[1:0] <= (sehold)? old_agp_d1[1:0]: rml_irf_old_agp[1:0];
2494
      new_agp_d1[1:0] <= (sehold)? new_agp_d1[1:0]: rml_irf_new_agp[1:0];
2495
      new_agp_d2[1:0] <= new_agp_d1[1:0];
2496
   end
2497 95 fafa1971
 
2498
 
2499 113 albert.wat
   /////////////////////////////////////////////
2500
   // Globals
2501
   //-----------------------------------
2502
   // rml inputs are latched on rising edge
2503
   // 1st cycle used for decode
2504
   // 2nd cycle stores active window in phase 1
2505
   // 3rd cycle loads new globals in phase 1
2506
   /////////////////////////////////////////////
2507
 
2508
   always @ (posedge clk) begin
2509 95 fafa1971
 
2510 113 albert.wat
      if (active_win_thr_rd_w_neg_wr_en & (~rst_tri_en | ~rst_tri_en_neg)) begin
2511
         active_window[thr_rd_w_neg] = active_win_thr_rd_w_neg;
2512
      end
2513
      if (active_win_thr_rd_w2_neg_wr_en & (~rst_tri_en | ~rst_tri_en_neg)) begin
2514
         active_window[thr_rd_w2_neg] = active_win_thr_rd_w2_neg;
2515
      end
2516
      // save active globals in phase 1
2517
      if (swap_global_d1_vld) begin
2518
         for (i = 6'd0; i < 6'd8; i = i + 1) begin
2519
            active_pointer[6:0] = {global_tid_d1[1:0], i[4:0]};
2520
            regfile_pointer[7:0] = {1'b0, global_tid_d1[1:0], old_agp_d1[1:0], i[2:0]};
2521
            // prevent back to back swaps on same thread
2522
            if (swap_global_d2 & (global_tid_d1[1:0] == global_tid_d2[1:0])) begin
2523
               globals[regfile_pointer[6:0]] = {72{1'bx}};
2524
            end
2525
            else globals[regfile_pointer[6:0]] = active_window[active_pointer[6:0]];
2526
         end
2527
      end
2528
 
2529
    // load in new active globals in phase 2
2530
      if (swap_global_d2) begin
2531
         for (i = 6'd0; i < 6'd8; i = i + 1) begin
2532
            active_pointer[6:0] = {global_tid_d2[1:0], i[4:0]};
2533
            regfile_pointer[7:0] = {1'b0, global_tid_d2[1:0], new_agp_d2[1:0], i[2:0]};
2534
            if (swap_global_d1_vld & (global_tid_d1[1:0] == global_tid_d2[1:0])) begin
2535
               active_window[active_pointer] = {72{1'bx}};
2536
               globals[regfile_pointer[6:0]] = {72{1'bx}};
2537
            end
2538
            else active_window[active_pointer] = globals[regfile_pointer[6:0]];
2539
         end
2540
      end
2541 95 fafa1971
 
2542 113 albert.wat
   ////////////////////////////
2543
   // locals, ins and outs
2544
   //-------------------------
2545
   // E - set up inputs to flop
2546
   // M - Decode
2547
   // W (phase 1) - Save
2548
   // W (phase 2) - write is allowed for save because restore will get killed
2549
   // W2 (phase 1) - Restore
2550
   // W2 (phase 2) - write is allowed
2551
   //
2552
   // actions that occur in phase one are modelled as occurring on the
2553
   // rising edge
2554
   //
2555
   // swaps to the same thread in consecutive cycles not allowed
2556
   /////////////////////////////
2557
       if (swap_local_m_vld) begin
2558
          // save the locals (16-23 in active window)
2559
          for (i = 6'd16; i < 6'd24; i = i + 1) begin
2560
             active_pointer[6:0] = {cwpswap_tid_m[1:0], i[4:0]};
2561
             regfile_pointer[7:0] = {cwpswap_tid_m[1:0], old_lo_cwp_m[2:0], i[2:0]};
2562
             if (swap_local_w & ~kill_restore_w & (cwpswap_tid_m[1:0] == cwpswap_tid_w[1:0]))
2563
               locals[regfile_pointer[7:0]] = {72{1'bx}};
2564
             else
2565
               locals[regfile_pointer[7:0]] = active_window[active_pointer];
2566
          end
2567
       end
2568
       if (swap_even_m_vld) begin
2569
          // save the ins in even window (24-31 in active window)
2570
          for (i = 6'd24; i < 6'd32; i = i + 1) begin
2571
             active_pointer[6:0] = {cwpswap_tid_m[1:0], i[4:0]};
2572
             regfile_pointer[7:0] = {1'b0, cwpswap_tid_m[1:0], old_e_cwp_m[1:0], i[2:0]};
2573
             if (swap_even_w & ~kill_restore_w & (cwpswap_tid_m[1:0] == cwpswap_tid_w[1:0]))
2574
               evens[regfile_pointer[6:0]] = {72{1'bx}};
2575
             else
2576
               evens[regfile_pointer[6:0]] = active_window[active_pointer];
2577
          end
2578
       end
2579
       if (swap_odd_m_vld) begin
2580
          // save the ins in odd window (8-15 in active window)
2581
          for (i = 6'd8; i < 6'd16; i = i + 1) begin
2582
             active_pointer[6:0] = {cwpswap_tid_m[1:0], i[4:0]};
2583
             regfile_pointer[7:0] = {1'b0, cwpswap_tid_m[1:0], old_lo_cwp_m[2:1], i[2:0]};
2584
             if (swap_odd_w & ~kill_restore_w & (cwpswap_tid_m[1:0] == cwpswap_tid_w[1:0]))
2585
               odds[regfile_pointer[6:0]] = {72{1'bx}};
2586
             else
2587
               odds[regfile_pointer[6:0]] = active_window[active_pointer];
2588
          end
2589
       end
2590
       if(~kill_restore_w) begin
2591
          if (swap_local_w) begin
2592
            // restore the locals (16-23 in active window)
2593
            for (i = 6'd16; i < 6'd24; i = i + 1) begin
2594
               active_pointer[6:0] = {cwpswap_tid_w[1:0], i[4:0]};
2595
               regfile_pointer[7:0] = {cwpswap_tid_w[1:0], new_lo_cwp_w[2:0], i[2:0]};
2596
               if (swap_local_m_vld & (cwpswap_tid_m[1:0] == cwpswap_tid_w[1:0])) begin
2597
                 active_window[active_pointer] = {72{1'bx}};
2598
                 locals[regfile_pointer[7:0]] = {72{1'bx}};
2599
               end
2600
               else
2601
                 active_window[active_pointer] = locals[regfile_pointer[7:0]];
2602
            end
2603
         end
2604
         if (swap_even_w) begin
2605
            // restore the ins in even window (24-32 in active window)
2606
            for (i = 6'd24; i < 6'd32; i = i + 1) begin
2607
               active_pointer[6:0] = {cwpswap_tid_w[1:0], i[4:0]};
2608
               regfile_pointer[7:0] = {1'b0, cwpswap_tid_w[1:0], new_e_cwp_w[1:0], i[2:0]};
2609
               if (swap_even_m_vld & (cwpswap_tid_m[1:0] == cwpswap_tid_w[1:0])) begin
2610
                 active_window[active_pointer] = {72{1'bx}};
2611
                 evens[regfile_pointer[6:0]] = {72{1'bx}};
2612
               end
2613
               else
2614
                 active_window[active_pointer] = evens[regfile_pointer[6:0]];
2615
            end
2616
         end
2617
         if (swap_odd_w) begin
2618
            // restore the ins in odd window (8-16 in active window)
2619
            for (i = 6'd8; i < 6'd16; i = i + 1) begin
2620
               active_pointer[6:0] = {cwpswap_tid_w[1:0], i[4:0]};
2621
               regfile_pointer[7:0] = {1'b0, cwpswap_tid_w[1:0], new_lo_cwp_w[2:1], i[2:0]};
2622
               if (swap_odd_m_vld & (cwpswap_tid_m[1:0] == cwpswap_tid_w[1:0])) begin
2623
                 active_window[active_pointer] = {72{1'bx}};
2624
                 odds[regfile_pointer[6:0]]  = {72{1'bx}};
2625
               end
2626
               else
2627
                 active_window[active_pointer] = odds[regfile_pointer[6:0]];
2628
            end
2629
         end
2630
       end
2631
    end // always @ (posedge clk)
2632 95 fafa1971
 
2633 113 albert.wat
endmodule // bw_r_irf
2634 95 fafa1971
 
2635 113 albert.wat
`endif

powered by: WebSVN 2.1.0

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