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

Subversion Repositories sparc64soc

[/] [sparc64soc/] [trunk/] [T1-CPU/] [exu/] [sparc_exu_rml_cwp.v] - Blame information for rev 4

Details | Compare with Previous | View Log

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