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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [sparc_exu_rml_cwp.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: sparc_exu_rml_cwp.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: sparc_exu_rml_cwp
29
//      Description: Register management logic.  Contains CWP, CANSAVE, CANRESTORE
30
//              and other window management registers.  Generates RF related traps
31
//              and switches the global registers to alternate globals.  All the registers
32
//              are written in the W stage (there is no bypassing so they must
33
//              swap out) and will either get a new value generated by a window management
34
//              Instruction or by a WRPS instruction.  The following traps can be generated:
35
//                      Fill: restore with canrestore == 0
36
//                      clean_window: save with cleanwin-canrestore == 0
37
//                      spill: flushw with cansave != nwindows -2 or
38
//                              save with cansave == 0
39
//              It is assumed that the contents of the new window will get squashed
40
//              on a clean_window or fill trap so the save or restore gets executed
41
//              normally.  Spill traps or WRCWPs mean that all 16 windowed registers
42
//              must be saved and restored (a 4 cycle operation).
43
*/
44
module sparc_exu_rml_cwp (/*AUTOARG*/
45
   // Outputs
46
   rml_ecl_cwp_d, rml_ecl_cwp_e, exu_tlu_cwp0_w, exu_tlu_cwp1_w,
47
   exu_tlu_cwp2_w, exu_tlu_cwp3_w, rml_irf_cwpswap_tid_e, old_cwp_e,
48
   new_cwp_e, swap_locals_ins, swap_outs, exu_tlu_spill,
49
   exu_tlu_spill_wtype, exu_tlu_spill_other, exu_tlu_spill_tid,
50
   rml_ecl_swap_done, exu_tlu_cwp_cmplt, exu_tlu_cwp_cmplt_tid,
51
   exu_tlu_cwp_retry, oddwin_w,
52
   // Inputs
53
   clk, se, reset, rst_tri_en, rml_ecl_wtype_e, rml_ecl_other_e,
54
   exu_tlu_spill_e, tlu_exu_cwpccr_update_m, tlu_exu_cwp_retry_m,
55
   tlu_exu_cwp_m, thr_d, ecl_rml_thr_m, ecl_rml_thr_w, tid_e,
56
   next_cwp_w, next_cwp_e, cwp_wen_w, save_e, restore_e,
57
   ifu_exu_flushw_e, ecl_rml_cwp_wen_e, full_swap_e, rml_kill_w
58
   ) ;
59
   input clk;
60
   input se;
61
   input reset;
62
   input rst_tri_en;
63
   input [2:0] rml_ecl_wtype_e;
64
   input       rml_ecl_other_e;
65
   input       exu_tlu_spill_e;
66
   input       tlu_exu_cwpccr_update_m;
67
   input       tlu_exu_cwp_retry_m;
68
   input [2:0] tlu_exu_cwp_m; // for switching cwp on return from trap
69
   input [3:0] thr_d;
70
   input [3:0] ecl_rml_thr_m;
71
   input [3:0] ecl_rml_thr_w;
72
   input [1:0] tid_e;
73
   input [2:0] next_cwp_w;
74
   input [2:0] next_cwp_e;
75
   input       cwp_wen_w;
76
   input       save_e;
77
   input       restore_e;
78
   input       ifu_exu_flushw_e;
79
   input       ecl_rml_cwp_wen_e;
80
   input       full_swap_e;
81
   input       rml_kill_w;
82
 
83
   output [2:0] rml_ecl_cwp_d;
84
   output [2:0] rml_ecl_cwp_e;
85
   output [2:0] exu_tlu_cwp0_w;
86
   output [2:0] exu_tlu_cwp1_w;
87
   output [2:0] exu_tlu_cwp2_w;
88
   output [2:0] exu_tlu_cwp3_w;
89
   output [1:0] rml_irf_cwpswap_tid_e;
90
   output [2:0] old_cwp_e;
91
   output [2:0] new_cwp_e;
92
   output       swap_locals_ins;
93
   output       swap_outs;
94
   output      exu_tlu_spill;
95
   output [2:0] exu_tlu_spill_wtype;
96
   output       exu_tlu_spill_other;
97
   output [1:0] exu_tlu_spill_tid;
98
   output [3:0] rml_ecl_swap_done;
99
   output       exu_tlu_cwp_cmplt;
100
   output [1:0] exu_tlu_cwp_cmplt_tid;
101
   output       exu_tlu_cwp_retry;
102
   output [3:0] oddwin_w;
103
 
104
   wire         can_swap;
105
   wire         swapping;
106
   wire         just_swapped;
107
   wire         full_swap_m;
108
   wire         full_swap_w;
109
   wire [3:0]   swap_done_next_cycle;
110
   wire [3:0] swap_sel_input;
111
   wire [3:0] swap_sel_tlu;
112
   wire [3:0] swap_keep_value;
113
   wire [2:0]  trap_old_cwp_m;
114
   wire   tlu_cwp_no_change;
115
   wire [2:0] tlu_cwp_xor;
116
   wire   cwp_cmplt_next;
117
   wire [1:0] cwp_cmplt_tid_next;
118
   wire       cwp_retry_next;
119
   wire   cwp_fastcmplt_m;
120
   wire   cwp_fastcmplt_w;
121
   wire   cwpccr_update_w;
122
   wire   valid_tlu_swap_w;
123
   wire [2:0] tlu_exu_cwp_w;
124
   wire       tlu_exu_cwp_retry_w;
125
 
126
   wire [3:0] swap_thr;
127
   wire [1:0] swap_tid;
128
   wire [3:0] swap_req_vec;
129
   wire       kill_swap_slot_w;
130
   wire [3:0] thr_e;
131
 
132
   wire [1:0] swap_slot0_state;
133
   wire [1:0] swap_slot1_state;
134
   wire [1:0] swap_slot2_state;
135
   wire [1:0] swap_slot3_state;
136
   wire [1:0] swap_slot0_state_valid;
137
   wire [1:0] swap_slot1_state_valid;
138
   wire [1:0] swap_slot2_state_valid;
139
   wire [1:0] swap_slot3_state_valid;
140
   wire [1:0] next_slot0_state;
141
   wire [1:0] next_slot1_state;
142
   wire [1:0] next_slot2_state;
143
   wire [1:0] next_slot3_state;
144
   wire [3:0] swap_keep_state;
145
   wire [3:0] swap_next_state;
146
   wire [1:0] swap_state;
147
 
148
   wire [3:0] next_swap_thr;
149
   wire [12:0] swap_data;
150
   wire [12:0] tlu_swap_data;
151
   wire [12:0] swap_input_data;
152
   wire [12:0] next_slot0_data;
153
   wire [12:0] next_slot1_data;
154
   wire [12:0] next_slot2_data;
155
   wire [12:0] next_slot3_data;
156
   wire [12:0] swap_slot0_data;
157
   wire [12:0] swap_slot1_data;
158
   wire [12:0] swap_slot2_data;
159
   wire [12:0] swap_slot3_data;
160
 
161
   wire        new_cwp_sel_swap;
162
   wire [2:0]  old_swap_cwp;
163
   wire [2:0]  new_swap_cwp;
164
 
165
 
166
   // wires for cwp register
167
   wire [2:0]   cwp_thr0;
168
   wire [2:0]   cwp_thr1;
169
   wire [2:0]   cwp_thr2;
170
   wire [2:0]   cwp_thr3;
171
   wire [2:0]   cwp_thr0_next;
172
   wire [2:0]   cwp_thr1_next;
173
   wire [2:0]   cwp_thr2_next;
174
   wire [2:0]   cwp_thr3_next;
175
   wire          cwp_wen_thr0_w;
176
   wire          cwp_wen_thr1_w;
177
   wire          cwp_wen_thr2_w;
178
   wire          cwp_wen_thr3_w;
179
   wire [3:0]    cwp_wen_tlu_w;
180
   wire [3:0] cwp_wen_spill;
181
   wire [2:0] spill_cwp;
182
   wire [3:0]    cwp_wen_l;
183
   wire [2:0]    old_cwp_w;
184
   wire        spill_next;
185
   wire [1:0]  spill_tid_next;
186
   wire        spill_other_next;
187
   wire [2:0]  spill_wtype_next;
188
 
189
   // decode thr_e
190
   assign        thr_e[0] = ~tid_e[1] & ~tid_e[0];
191
   assign        thr_e[1] = ~tid_e[1] & tid_e[0];
192
   assign        thr_e[2] = tid_e[1] & ~tid_e[0];
193
   assign        thr_e[3] = tid_e[1] & tid_e[0];
194
 
195
   /////////////////////////////////
196
   // CWP output to IRF
197
   /////////////////////////////////
198
   // Output current_d thr on saves or restores
199
   mux2ds #(2) irf_thr_mux(.dout(rml_irf_cwpswap_tid_e[1:0]),
200
                              .in0(tid_e[1:0]),
201
                              .in1(swap_tid[1:0]),
202
                              .sel0(~can_swap),
203
                              .sel1(can_swap));
204
   // Output cwp_e for save, restore, flushw
205
   // and swap_cwp from queue for swap restores (default)
206
   // Need to have an incremented cwp for swap of outs
207
   assign        old_swap_cwp[2:0] = swap_data[2:0];
208
   assign        new_swap_cwp[2:0] = swap_data[5:3];
209
 
210
   assign        new_cwp_sel_swap = can_swap;
211
 
212
   assign new_cwp_e[2:0] = (new_cwp_sel_swap)?  new_swap_cwp[2:0]: next_cwp_e[2:0];
213
   assign old_cwp_e[2:0] = (new_cwp_sel_swap)?  old_swap_cwp[2:0]: rml_ecl_cwp_e[2:0];
214
 
215
 
216
   /////////////////////////////////
217
   // CWP register
218
   /////////////////////////////////
219
   assign exu_tlu_cwp0_w[2:0] = cwp_thr0[2:0];
220
   assign exu_tlu_cwp1_w[2:0] = cwp_thr1[2:0];
221
   assign exu_tlu_cwp2_w[2:0] = cwp_thr2[2:0];
222
   assign exu_tlu_cwp3_w[2:0] = cwp_thr3[2:0];
223
 
224
   mux4ds #(3) mux_cwp_old_w(.dout(old_cwp_w[2:0]), .sel0(ecl_rml_thr_w[0]),
225
                             .sel1(ecl_rml_thr_w[1]), .sel2(ecl_rml_thr_w[2]),
226
                             .sel3(ecl_rml_thr_w[3]), .in0(cwp_thr0[2:0]),
227
                             .in1(cwp_thr1[2:0]), .in2(cwp_thr2[2:0]),
228
                             .in3(cwp_thr3[2:0]));
229
 
230
   //  Output selection for reg
231
   mux4ds #(3) mux_cwp_out_d(.dout(rml_ecl_cwp_d[2:0]), .sel0(thr_d[0]),
232
                             .sel1(thr_d[1]), .sel2(thr_d[2]),
233
                             .sel3(thr_d[3]), .in0(cwp_thr0[2:0]),
234
                             .in1(cwp_thr1[2:0]), .in2(cwp_thr2[2:0]),
235
                             .in3(cwp_thr3[2:0]));
236
   mux4ds #(3) mux_cwp_out_e(.dout(rml_ecl_cwp_e[2:0]), .sel0(thr_e[0]),
237
                             .sel1(thr_e[1]), .sel2(thr_e[2]),
238
                             .sel3(thr_e[3]), .in0(cwp_thr0[2:0]),
239
                             .in1(cwp_thr1[2:0]), .in2(cwp_thr2[2:0]),
240
                             .in3(cwp_thr3[2:0]));
241
   mux4ds #(3) mux_cwp_trap(.dout(trap_old_cwp_m[2:0]), .sel0(ecl_rml_thr_m[0]),
242
                             .sel1(ecl_rml_thr_m[1]), .sel2(ecl_rml_thr_m[2]),
243
                             .sel3(ecl_rml_thr_m[3]), .in0(cwp_thr0[2:0]),
244
                             .in1(cwp_thr1[2:0]), .in2(cwp_thr2[2:0]),
245
                             .in3(cwp_thr3[2:0]));
246
 
247
   //////////////////////////////////////
248
   //  Storage of cwp
249
   //////////////////////////////////////
250
   // enable input for each thread
251
   assign     cwp_wen_spill[3:0] = swap_thr[3:0] & {4{spill_next}};
252
   assign        cwp_wen_thr0_w = ((ecl_rml_thr_w[0] & cwp_wen_w)) & ~cwp_wen_spill[0];
253
   assign        cwp_wen_thr1_w = ((ecl_rml_thr_w[1] & cwp_wen_w)) & ~cwp_wen_spill[1];
254
   assign        cwp_wen_thr2_w = ((ecl_rml_thr_w[2] & cwp_wen_w)) & ~cwp_wen_spill[2];
255
   assign        cwp_wen_thr3_w = ((ecl_rml_thr_w[3] & cwp_wen_w)) & ~cwp_wen_spill[3];
256
   assign        cwp_wen_tlu_w[3:0] = ecl_rml_thr_w[3:0] & {4{valid_tlu_swap_w}} & ~cwp_wen_spill &
257
                                       {~cwp_wen_thr3_w,~cwp_wen_thr2_w,~cwp_wen_thr1_w,~cwp_wen_thr0_w};
258
   assign        cwp_wen_l[3:0] = ~(cwp_wen_tlu_w[3:0] | cwp_wen_spill[3:0] |
259
                                    {cwp_wen_thr3_w,cwp_wen_thr2_w, cwp_wen_thr1_w,cwp_wen_thr0_w});
260
 
261
   // oddwin_w is the new value of cwp[0]
262
   assign        oddwin_w[3:0] = {cwp_thr3_next[0],cwp_thr2_next[0],cwp_thr1_next[0],cwp_thr0_next[0]};
263
   // mux between new and current value
264
   mux4ds #(3) cwp_next0_mux(.dout(cwp_thr0_next[2:0]),
265
                             .in0(cwp_thr0[2:0]),
266
                             .in1(next_cwp_w[2:0]),
267
                             .in2(tlu_exu_cwp_w[2:0]),
268
                             .in3(spill_cwp[2:0]),
269
                             .sel0(cwp_wen_l[0]),
270
                             .sel1(cwp_wen_thr0_w),
271
                             .sel2(cwp_wen_tlu_w[0]),
272
                             .sel3(cwp_wen_spill[0]));
273
   mux4ds #(3) cwp_next1_mux(.dout(cwp_thr1_next[2:0]),
274
                             .in0(cwp_thr1[2:0]),
275
                             .in1(next_cwp_w[2:0]),
276
                             .in2(tlu_exu_cwp_w[2:0]),
277
                             .in3(spill_cwp[2:0]),
278
                             .sel0(cwp_wen_l[1]),
279
                             .sel1(cwp_wen_thr1_w),
280
                             .sel2(cwp_wen_tlu_w[1]),
281
                             .sel3(cwp_wen_spill[1]));
282
   mux4ds #(3) cwp_next2_mux(.dout(cwp_thr2_next[2:0]),
283
                             .in0(cwp_thr2[2:0]),
284
                             .in1(next_cwp_w[2:0]),
285
                             .in2(tlu_exu_cwp_w[2:0]),
286
                             .in3(spill_cwp[2:0]),
287
                             .sel0(cwp_wen_l[2]),
288
                             .sel1(cwp_wen_thr2_w),
289
                             .sel2(cwp_wen_tlu_w[2]),
290
                             .sel3(cwp_wen_spill[2]));
291
   mux4ds #(3) cwp_next3_mux(.dout(cwp_thr3_next[2:0]),
292
                             .in0(cwp_thr3[2:0]),
293
                             .in1(next_cwp_w[2:0]),
294
                             .in2(tlu_exu_cwp_w[2:0]),
295
                             .in3(spill_cwp[2:0]),
296
                             .sel0(cwp_wen_l[3]),
297
                             .sel1(cwp_wen_thr3_w),
298
                             .sel2(cwp_wen_tlu_w[3]),
299
                             .sel3(cwp_wen_spill[3]));
300
 
301
   // store new value
302 113 albert.wat
   dff_s #(3) dff_cwp_thr0(.din(cwp_thr0_next[2:0]), .clk(clk), .q(cwp_thr0[2:0]),
303
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
304
   dff_s #(3) dff_cwp_thr1(.din(cwp_thr1_next[2:0]), .clk(clk), .q(cwp_thr1[2:0]),
305
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
306
   dff_s #(3) dff_cwp_thr2(.din(cwp_thr2_next[2:0]), .clk(clk), .q(cwp_thr2[2:0]),
307
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
308
   dff_s #(3) dff_cwp_thr3(.din(cwp_thr3_next[2:0]), .clk(clk), .q(cwp_thr3[2:0]),
309
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
310 95 fafa1971
 
311
 
312
 
313
   ////////////////////////////////////////////
314
   // Queue for full window swaps
315
   ////////////////////////////////////////////
316
   // A full swap of the current window requires a 2 cycle operation.
317
   // Each cycle must make sure that
318
   // there isn't another instruction trying to save or restore on top of it.
319
   // The same thread also cannot issue a swap to irf in back-to-back cycles.
320
   // Data is stored as follows:
321
   //   2:0 - CWP
322
   //   5:3 - NewCWP
323
   //   6   - !WRCWP/SPILL
324
   //   7   - Trap return
325
   //   8   - OTHER (for spill trap)
326
   //   11:9- WTYPE (for spill trap)
327
   //           12  - Retry (for trap return)
328 113 albert.wat
   dff_s full_swap_e2m(.din(full_swap_e), .clk(clk), .q(full_swap_m), .se(se), `SIMPLY_RISC_SCANIN, .so());
329
   dff_s full_swap_m2w(.din(full_swap_m), .clk(clk), .q(full_swap_w), .se(se), `SIMPLY_RISC_SCANIN, .so());
330 95 fafa1971
   assign     swap_input_data = {1'b0, rml_ecl_wtype_e[2:0], rml_ecl_other_e, 1'b0, exu_tlu_spill_e,
331
                                 next_cwp_e[2:0],rml_ecl_cwp_e[2:0]};
332
   assign     tlu_swap_data = {tlu_exu_cwp_retry_w, 4'b0, 1'b1, 1'b0, tlu_exu_cwp_w[2:0], old_cwp_w[2:0]};
333
 
334
 
335
   assign     swap_sel_input[3:0] = thr_e[3:0] & {4{full_swap_e}};
336
   assign     swap_sel_tlu[3:0] = ecl_rml_thr_w[3:0] & {4{cwpccr_update_w}}
337
                                    & ~swap_sel_input[3:0];
338
   assign     swap_keep_value[3:0] = ~(swap_sel_tlu[3:0] | swap_sel_input[3:0]);
339
   assign     swap_keep_state[3:0] = ~(swap_sel_tlu[3:0] | swap_sel_input[3:0]) &
340
                                        ~(swap_thr[3:0] & {4{can_swap}});
341
   assign     swap_next_state[3:0] = ~(swap_sel_tlu[3:0] | swap_sel_input[3:0])
342
                                         & (swap_thr[3:0] & {4{can_swap}});
343
   mux3ds #(13) slot0_data_mux(.dout(next_slot0_data[12:0]),
344
                               .in0(swap_input_data[12:0]),
345
                               .in1(tlu_swap_data[12:0]),
346
                               .in2(swap_slot0_data[12:0]),
347
                               .sel0(swap_sel_input[0]),
348
                               .sel1(swap_sel_tlu[0]),
349
                               .sel2(swap_keep_value[0]));
350
   mux3ds #(13) slot1_data_mux(.dout(next_slot1_data[12:0]),
351
                               .in0(swap_input_data[12:0]),
352
                               .in1(tlu_swap_data[12:0]),
353
                               .in2(swap_slot1_data[12:0]),
354
                               .sel0(swap_sel_input[1]),
355
                               .sel1(swap_sel_tlu[1]),
356
                               .sel2(swap_keep_value[1]));
357
   mux3ds #(13) slot2_data_mux(.dout(next_slot2_data[12:0]),
358
                               .in0(swap_input_data[12:0]),
359
                               .in1(tlu_swap_data[12:0]),
360
                               .in2(swap_slot2_data[12:0]),
361
                               .sel0(swap_sel_input[2]),
362
                               .sel1(swap_sel_tlu[2]),
363
                               .sel2(swap_keep_value[2]));
364
   mux3ds #(13) slot3_data_mux(.dout(next_slot3_data[12:0]),
365
                               .in0(swap_input_data[12:0]),
366
                               .in1(tlu_swap_data[12:0]),
367
                               .in2(swap_slot3_data[12:0]),
368
                               .sel0(swap_sel_input[3]),
369
                               .sel1(swap_sel_tlu[3]),
370
                               .sel2(swap_keep_value[3]));
371
 
372
   // Muxes for slot state.
373
   // There are 2 possible states:
374
   // No swap done (01)
375
   // Swap locals/ins done (10)
376
   mux4ds #(2) slot0_state_mux(.dout(next_slot0_state[1:0]),
377
                               .in0(2'b10),
378
                               .in1({1'b0, valid_tlu_swap_w}),
379
                               .in2(swap_slot0_state_valid[1:0]),
380
                               .in3({swap_slot0_state_valid[0], 1'b0}),
381
                               .sel0(swap_sel_input[0]),
382
                               .sel1(swap_sel_tlu[0]),
383
                               .sel2(swap_keep_state[0]),
384
                               .sel3(swap_next_state[0]));
385
   mux4ds #(2) slot1_state_mux(.dout(next_slot1_state[1:0]),
386
                               .in0(2'b10),
387
                               .in1({1'b0, valid_tlu_swap_w}),
388
                               .in2(swap_slot1_state_valid[1:0]),
389
                               .in3({swap_slot1_state_valid[0], 1'b0}),
390
                               .sel0(swap_sel_input[1]),
391
                               .sel1(swap_sel_tlu[1]),
392
                               .sel2(swap_keep_state[1]),
393
                               .sel3(swap_next_state[1]));
394
   mux4ds #(2) slot2_state_mux(.dout(next_slot2_state[1:0]),
395
                               .in0(2'b10),
396
                               .in1({1'b0, valid_tlu_swap_w}),
397
                               .in2(swap_slot2_state_valid[1:0]),
398
                               .in3({swap_slot2_state_valid[0], 1'b0}),
399
                               .sel0(swap_sel_input[2]),
400
                               .sel1(swap_sel_tlu[2]),
401
                               .sel2(swap_keep_state[2]),
402
                               .sel3(swap_next_state[2]));
403
   mux4ds #(2) slot3_state_mux(.dout(next_slot3_state[1:0]),
404
                               .in0(2'b10),
405
                               .in1({1'b0, valid_tlu_swap_w}),
406
                               .in2(swap_slot3_state_valid[1:0]),
407
                               .in3({swap_slot3_state_valid[0], 1'b0}),
408
                               .sel0(swap_sel_input[3]),
409
                               .sel1(swap_sel_tlu[3]),
410
                               .sel2(swap_keep_state[3]),
411
                               .sel3(swap_next_state[3]));
412
 
413
   // The kill is only assessed in w1 because back to back swaps are not allowed.
414
   // This means that a swap cannot start in the M or W stage.
415
   assign     kill_swap_slot_w = rml_kill_w & full_swap_w;
416
 
417
   assign     swap_slot0_state_valid[1:0] = {(swap_slot0_state[1] & ~(kill_swap_slot_w & ecl_rml_thr_w[0])),
418
                                             (swap_slot0_state[0])};
419
   assign     swap_slot1_state_valid[1:0] = {(swap_slot1_state[1] & ~(kill_swap_slot_w & ecl_rml_thr_w[1])),
420
                                             (swap_slot1_state[0])};
421
   assign     swap_slot2_state_valid[1:0] = {(swap_slot2_state[1] & ~(kill_swap_slot_w & ecl_rml_thr_w[2])),
422
                                             (swap_slot2_state[0])};
423
   assign     swap_slot3_state_valid[1:0] = {(swap_slot3_state[1] & ~(kill_swap_slot_w & ecl_rml_thr_w[3])),
424
                                             (swap_slot3_state[0])};
425
 
426
   // Flops for cwp_swap data
427 113 albert.wat
   dffr_s #(15) slot0_data_dff(.din({next_slot0_state[1:0], next_slot0_data[12:0]}), .clk(clk),
428 95 fafa1971
                            .q({swap_slot0_state[1:0], swap_slot0_data[12:0]}), .rst(reset),
429 113 albert.wat
                            .se(se), `SIMPLY_RISC_SCANIN, .so());
430
   dffr_s #(15) slot1_data_dff(.din({next_slot1_state[1:0], next_slot1_data[12:0]}), .clk(clk),
431 95 fafa1971
                            .q({swap_slot1_state[1:0], swap_slot1_data[12:0]}), .rst(reset),
432 113 albert.wat
                            .se(se), `SIMPLY_RISC_SCANIN, .so());
433
   dffr_s #(15) slot2_data_dff(.din({next_slot2_state[1:0], next_slot2_data[12:0]}), .clk(clk),
434 95 fafa1971
                            .q({swap_slot2_state[1:0], swap_slot2_data[12:0]}), .rst(reset),
435 113 albert.wat
                            .se(se), `SIMPLY_RISC_SCANIN, .so());
436
   dffr_s #(15) slot3_data_dff(.din({next_slot3_state[1:0], next_slot3_data[12:0]}), .clk(clk),
437 95 fafa1971
                            .q({swap_slot3_state[1:0], swap_slot3_data[12:0]}), .rst(reset),
438 113 albert.wat
                            .se(se), `SIMPLY_RISC_SCANIN, .so());
439 95 fafa1971
 
440
   ////////////////////////////
441
   // Control for queue output
442
   //   ==========================
443
   //   The queue results go into a flop
444
   //   so that they can meet timing.
445
   ////////////////////////////
446
   assign     swap_req_vec[0] = (swap_slot0_state[1] | swap_slot0_state[0]);
447
   assign     swap_req_vec[1] = (swap_slot1_state[1] | swap_slot1_state[0]);
448
   assign     swap_req_vec[2] = (swap_slot2_state[1] | swap_slot2_state[0]);
449
   assign     swap_req_vec[3] = (swap_slot3_state[1] | swap_slot3_state[0]);
450
 
451
   sparc_exu_rndrob cwp_output_queue(// Outputs
452
                                     .grant_vec(next_swap_thr[3:0]),
453
                                     // Inputs
454
                                     .clk(clk),
455
                                     .reset(reset),
456
                                     .se(se),
457
                                     .req_vec(swap_req_vec[3:0]),
458
                                     .advance(can_swap));
459 113 albert.wat
   dff_s #(4) dff_swap_thr(.din(next_swap_thr[3:0]), .clk(clk), .q(swap_thr[3:0]),
460
                         .se(se), `SIMPLY_RISC_SCANIN, .so());
461 95 fafa1971
   assign     swap_tid[1] = swap_thr[3] | swap_thr[2];
462
   assign     swap_tid[0] = swap_thr[3] | swap_thr[1];
463
 
464
   // make selects one hot
465
   wire [3:0] swap_sel;
466
   assign swap_sel[0] = ~(swap_thr[1] | swap_thr[2] | swap_thr[3]) | rst_tri_en;
467
   assign swap_sel[3:1] = swap_thr[3:1] & {3{~rst_tri_en}};
468
 
469
   mux4ds #(15) cwp_output_mux(.dout({swap_state[1:0], swap_data[12:0]}),
470
                               .in0({swap_slot0_state[1:0], swap_slot0_data[12:0]}),
471
                               .in1({swap_slot1_state[1:0], swap_slot1_data[12:0]}),
472
                               .in2({swap_slot2_state[1:0], swap_slot2_data[12:0]}),
473
                               .in3({swap_slot3_state[1:0], swap_slot3_data[12:0]}),
474
                               .sel0(swap_sel[0]),
475
                               .sel1(swap_sel[1]),
476
                               .sel2(swap_sel[2]),
477
                               .sel3(swap_sel[3]));
478
 
479
   // To prevent back to back swap requests on the same thread, the queue cannot swap
480
   // 2 cycles in a row.  Also swaps can't start in M or W to allow flush to be checked
481 113 albert.wat
   dffr_s can_swap_flop(.din(swapping), .clk(clk), .q(just_swapped), .rst(reset), .se(se), `SIMPLY_RISC_SCANIN, .so());
482 95 fafa1971
   assign     can_swap = ~(save_e | restore_e | ifu_exu_flushw_e | ecl_rml_cwp_wen_e | just_swapped);
483
   assign      swap_locals_ins = can_swap & swap_state[0];
484
   assign      swap_outs = can_swap & swap_state[1];
485
   assign      swapping = (can_swap & |swap_state[1:0]) | full_swap_e | full_swap_m;
486
 
487
   ///////////////////////////////////
488
   // Signals for completion of swaps
489
   ///////////////////////////////////
490
   assign spill_next = swap_data[6] & ~swap_data[7] & swap_outs;
491
   assign spill_tid_next[1:0] = swap_tid[1:0];
492
   //assign exu_tlu_spill_ttype[8:0] = {3'b010, swap_data[8], swap_data[11:9], 2'b00};
493
   assign spill_other_next = swap_data[8];
494
   assign spill_wtype_next[2:0] = swap_data[11:9];
495 113 albert.wat
   dff_s #(7) spill_dff(.din({spill_next,spill_tid_next[1:0], spill_other_next, spill_wtype_next[2:0]}),
496 95 fafa1971
                      .q({exu_tlu_spill,exu_tlu_spill_tid[1:0], exu_tlu_spill_other, exu_tlu_spill_wtype[2:0]}),
497 113 albert.wat
                      .clk(clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
498 95 fafa1971
   assign spill_cwp[2:0] = swap_data[5:3];
499
/* -----\/----- EXCLUDED -----\/-----
500 113 albert.wat
   dff_s #(3) spill_cwp_dff(.din(swap_data[5:3]), .clk(clk), .q(spill_cwp[2:0]),
501
                          .se(se), `SIMPLY_RISC_SCANIN, .so());
502 95 fafa1971
 -----/\----- EXCLUDED -----/\----- */
503
   assign swap_done_next_cycle[3] = (swap_outs & ~swap_data[6] & ~swap_data[7] &
504
                                     swap_tid[1] & swap_tid[0]);
505
   assign swap_done_next_cycle[2] = (swap_outs & ~swap_data[6] & ~swap_data[7] &
506
                                     swap_tid[1] & ~swap_tid[0]);
507
   assign swap_done_next_cycle[1] = (swap_outs & ~swap_data[6] & ~swap_data[7] &
508
                                     ~swap_tid[1] & swap_tid[0]);
509
   assign swap_done_next_cycle[0] = (swap_outs & ~swap_data[6] & ~swap_data[7] &
510
                                     ~swap_tid[1] & ~swap_tid[0]);
511
 
512 113 albert.wat
   dff_s #(4) swap_done_dff(.din(swap_done_next_cycle[3:0]), .clk(clk),
513
                        .q(rml_ecl_swap_done[3:0]), .se(se), `SIMPLY_RISC_SCANIN, .so());
514 95 fafa1971
 
515 113 albert.wat
   dff_s #(4) cwp_cmplt_dff(.din({cwp_cmplt_next, cwp_cmplt_tid_next[1:0], cwp_retry_next}),
516 95 fafa1971
                          .q({exu_tlu_cwp_cmplt,exu_tlu_cwp_cmplt_tid[1:0], exu_tlu_cwp_retry}),
517 113 albert.wat
                          .clk(clk), `SIMPLY_RISC_SCANIN, .so(), .se(se));
518 95 fafa1971
   assign cwp_cmplt_next = swap_outs & swap_data[7];
519
   assign cwp_cmplt_tid_next[1:0] = swap_tid[1:0];
520
   assign cwp_retry_next = swap_data[12];
521
 
522
   assign tlu_cwp_xor[2:0] = trap_old_cwp_m[2:0] ^ tlu_exu_cwp_m[2:0];
523
   assign tlu_cwp_no_change = ~(tlu_cwp_xor[2] | tlu_cwp_xor[1] | tlu_cwp_xor[0]);
524
   assign cwp_fastcmplt_m = tlu_exu_cwpccr_update_m & tlu_cwp_no_change;
525
 
526 113 albert.wat
   dff_s fastcmplt_dff(.din(cwp_fastcmplt_m), .clk(clk),
527
                     .q(cwp_fastcmplt_w), .se(se), `SIMPLY_RISC_SCANIN, .so());
528 95 fafa1971
 
529
   ///////////////////////////////////////////////////////////
530
   // Pipe along tlu_exu_done/retry so inst_vld can be caught
531
   ///////////////////////////////////////////////////////////
532 113 albert.wat
   dff_s #(5) tlu_data_dff(.q({cwpccr_update_w,tlu_exu_cwp_w[2:0],tlu_exu_cwp_retry_w}),
533 95 fafa1971
                         .din({tlu_exu_cwpccr_update_m,tlu_exu_cwp_m[2:0],tlu_exu_cwp_retry_m}),
534 113 albert.wat
                         .clk(clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
535 95 fafa1971
   assign valid_tlu_swap_w = cwpccr_update_w & ~rml_kill_w & ~cwp_fastcmplt_w;
536
 
537
endmodule // sparc_exu_rml_cwp

powered by: WebSVN 2.1.0

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