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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [sparc_ifu_dec.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_ifu_dec.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_ifu_dec
29
//  Description:
30
//  The decode block implements the sparc instruction decode ROM
31
//  It has a purely combinational part and some staging flops
32
*/
33
////////////////////////////////////////////////////////////////////////
34
 
35
module sparc_ifu_dec(/*AUTOARG*/
36
   // Outputs
37
   so, ifu_exu_aluop_d, ifu_exu_invert_d, ifu_exu_useimm_d,
38
   ifu_exu_usecin_d, ifu_exu_enshift_d, ifu_exu_tagop_d,
39
   ifu_exu_tv_d, ifu_exu_muls_d, ifu_exu_ialign_d,
40
   ifu_exu_range_check_jlret_d, ifu_exu_range_check_other_d,
41
   ifu_exu_shiftop_d, ifu_exu_muldivop_d, ifu_exu_wen_d,
42
   ifu_exu_setcc_d, ifu_exu_rd_ifusr_e, ifu_exu_rd_exusr_e,
43
   ifu_exu_rd_ffusr_e, ifu_exu_rs1_vld_d, ifu_exu_rs2_vld_d,
44
   ifu_exu_rs3e_vld_d, ifu_exu_rs3o_vld_d, ifu_exu_use_rsr_e_l,
45
   ifu_exu_save_d, ifu_exu_restore_d, ifu_exu_return_d,
46
   ifu_exu_flushw_e, ifu_exu_saved_e, ifu_exu_restored_e,
47
   ifu_tlu_rsr_inst_d, ifu_lsu_wsr_inst_d, ifu_exu_wsr_inst_d,
48
   ifu_tlu_done_inst_d, ifu_tlu_retry_inst_d, ifu_lsu_ld_inst_e,
49
   ifu_lsu_st_inst_e, ifu_lsu_pref_inst_e, ifu_lsu_alt_space_e,
50
   ifu_lsu_alt_space_d, ifu_tlu_alt_space_d, ifu_lsu_memref_d,
51
   ifu_lsu_sign_ext_e, ifu_lsu_ldstub_e, ifu_lsu_casa_e,
52
   ifu_exu_casa_d, ifu_lsu_swap_e, ifu_tlu_mb_inst_e,
53
   ifu_tlu_sir_inst_m, ifu_tlu_flsh_inst_e, ifu_lsu_ldst_dbl_e,
54
   ifu_lsu_ldst_fp_e, ifu_lsu_ldst_size_e, ifu_ffu_fpop1_d,
55
   ifu_ffu_visop_d, ifu_ffu_fpop2_d, ifu_ffu_fld_d, ifu_ffu_fst_d,
56
   ifu_ffu_ldst_size_d, ifu_ffu_ldfsr_d, ifu_ffu_ldxfsr_d,
57
   ifu_ffu_stfsr_d, ifu_ffu_quad_op_e, dec_fcl_rdsr_sel_pc_d,
58
   dec_fcl_rdsr_sel_thr_d, dec_imd_call_inst_d,
59
   dtu_fcl_flush_sonly_e, dtu_fcl_illinst_e, dtu_fcl_fpdis_e,
60
   dtu_fcl_privop_e, dtu_fcl_imask_hit_e, dtu_fcl_br_inst_d,
61
   dtu_fcl_sir_inst_e, dtu_ifq_kill_latest_d, dec_swl_wrt_tcr_w,
62
   dec_swl_wrtfprs_w, dec_swl_ll_done_d, dec_swl_br_done_d,
63
   dec_swl_rdsr_sel_thr_d, dec_swl_ld_inst_d, dec_swl_sta_inst_e,
64
   dec_swl_std_inst_d, dec_swl_st_inst_d, dec_swl_fpop_d,
65
   dec_swl_allfp_d, dec_swl_frf_upper_d, dec_swl_frf_lower_d,
66
   dec_swl_div_inst_d, dec_swl_mul_inst_d, wsr_fixed_inst_w,
67
   ifu_exu_sethi_inst_d, dec_dcl_cctype_d,
68
   // Inputs
69
   rclk, se, si, dtu_inst_d, erb_dtu_imask, swl_dec_ibe_e,
70
   dtu_inst_anull_e, lsu_ifu_ldsta_internal_e, fcl_dtu_tlzero_d,
71
   fcl_dtu_privmode_d, fcl_dtu_hprivmode_d, fcl_dtu_inst_vld_d,
72
   fcl_dtu_ely_inst_vld_d, fcl_dec_intr_vld_d, fcl_dtu_inst_vld_e,
73
   fcl_dec_dslot_s, swl_dec_mulbusy_e, swl_dec_fpbusy_e,
74
   swl_dec_divbusy_e, swl_dec_fp_enable_d
75
   );
76
 
77
   input          rclk,
78
                  se,
79
                  si;
80
   input [31:0]   dtu_inst_d;    // fed in at Switch (S) stage.
81
   input [38:0]   erb_dtu_imask;
82
   input          swl_dec_ibe_e;
83
   input          dtu_inst_anull_e;
84
   input          lsu_ifu_ldsta_internal_e;
85
   input          fcl_dtu_tlzero_d;
86
   input          fcl_dtu_privmode_d;
87
   input          fcl_dtu_hprivmode_d;
88
   input          fcl_dtu_inst_vld_d,
89
                  fcl_dtu_ely_inst_vld_d,
90
                  fcl_dec_intr_vld_d,
91
                              fcl_dtu_inst_vld_e;  // qual with this is not necessary
92
 
93
   input          fcl_dec_dslot_s;
94
 
95
   input          swl_dec_mulbusy_e;
96
   input          swl_dec_fpbusy_e;
97
   input          swl_dec_divbusy_e;
98
   input          swl_dec_fp_enable_d;
99
 
100
 
101
   output         so;
102
 
103
   // to EXU
104
   output [2:0]   ifu_exu_aluop_d;// 000 - add/sub
105
                                  // 001 - and
106
                                  // 010 - or
107
                                  // 011 - xor
108
                                  // 1X0 - movcc
109
                                  // 1x1 - movr
110
   output         ifu_exu_invert_d;   // invert rs2 operand
111
   output         ifu_exu_useimm_d;
112
   output         ifu_exu_usecin_d;   // use c from icc
113
   output         ifu_exu_enshift_d;  // turn on shifter
114
 
115
   output         ifu_exu_tagop_d,
116
                              ifu_exu_tv_d,
117
                              ifu_exu_muls_d,
118
                  ifu_exu_ialign_d,
119
                              ifu_exu_range_check_jlret_d,
120
                              ifu_exu_range_check_other_d;
121
 
122
   output [2:0] ifu_exu_shiftop_d;  // b2 - 32b(0) or 64b(1)
123
                                    // b1 - unsigned(0)  or signed(1)
124
                                    // b0 - left(0) or right(1) shift
125
 
126
   output [4:0] ifu_exu_muldivop_d; // b4 - is_mul
127
                                    // b3 - is_div
128
                                    // b2 - 64b if 1, 32b if 0
129
                                    // b1 - signed if 1, unsigned if 0
130
                                    // b0 - set cc's
131
 
132
   output       ifu_exu_wen_d;      // write to rd
133
   output       ifu_exu_setcc_d;    // b0 - write to icc/xcc
134
 
135
   output       ifu_exu_rd_ifusr_e,
136
                            ifu_exu_rd_exusr_e,
137
                            ifu_exu_rd_ffusr_e;
138
 
139
   output       ifu_exu_rs1_vld_d,
140
                            ifu_exu_rs2_vld_d,
141
                            ifu_exu_rs3e_vld_d,
142
                            ifu_exu_rs3o_vld_d;
143
 
144
   output       ifu_exu_use_rsr_e_l;
145
 
146
   output       ifu_exu_save_d,
147
                            ifu_exu_restore_d,
148
                            ifu_exu_return_d,
149
                            ifu_exu_flushw_e,
150
                            ifu_exu_saved_e,
151
                            ifu_exu_restored_e;
152
 
153
   // to TLU
154
   output       ifu_tlu_rsr_inst_d,
155
                            ifu_lsu_wsr_inst_d,
156
                            ifu_exu_wsr_inst_d,
157
                            ifu_tlu_done_inst_d,
158
                            ifu_tlu_retry_inst_d;
159
 
160
   // to LSU 
161
   output       ifu_lsu_ld_inst_e,   // ld inst or atomic
162
                            ifu_lsu_st_inst_e,   // store or atomic
163
                ifu_lsu_pref_inst_e,
164
                            ifu_lsu_alt_space_e, // alt space -- to be removed
165
                            ifu_lsu_alt_space_d, // never x -- to be removed
166
                            ifu_tlu_alt_space_d, // sometimes x but faster
167
                            ifu_lsu_memref_d;    // alerts lsu of upcoming ldst
168
//                          ifu_lsu_imm_asi_vld_d;
169
 
170
   output       ifu_lsu_sign_ext_e,
171
                            ifu_lsu_ldstub_e,
172
                            ifu_lsu_casa_e,
173
                            ifu_exu_casa_d,
174
                            ifu_lsu_swap_e;
175
 
176
   output       ifu_tlu_mb_inst_e,
177
                            ifu_tlu_sir_inst_m,
178
                            ifu_tlu_flsh_inst_e;
179
 
180
   output       ifu_lsu_ldst_dbl_e,
181
                            ifu_lsu_ldst_fp_e;
182
 
183
   output [1:0] ifu_lsu_ldst_size_e;
184
 
185
   // to SPU
186
//   output     ifu_spu_scpy_inst_e,
187
//              ifu_spu_scmp_inst_e;
188
 
189
   // to FFU
190
   output       ifu_ffu_fpop1_d;
191
   output       ifu_ffu_visop_d;
192
   output       ifu_ffu_fpop2_d;
193
   output       ifu_ffu_fld_d;
194
   output       ifu_ffu_fst_d;
195
   output       ifu_ffu_ldst_size_d;
196
 
197
   output       ifu_ffu_ldfsr_d,
198
                            ifu_ffu_ldxfsr_d,
199
                            ifu_ffu_stfsr_d;
200
   output       ifu_ffu_quad_op_e;
201
 
202
   // within IFU
203
   output       dec_fcl_rdsr_sel_pc_d,
204
                            dec_fcl_rdsr_sel_thr_d;
205
 
206
   output       dec_imd_call_inst_d;
207
 
208
   output       dtu_fcl_flush_sonly_e,
209
//                dec_fcl_kill4sta_e,
210
                            dtu_fcl_illinst_e,
211
                            dtu_fcl_fpdis_e,
212
                            dtu_fcl_privop_e,
213
                            dtu_fcl_imask_hit_e,
214
                            dtu_fcl_br_inst_d,
215
                            dtu_fcl_sir_inst_e;
216
 
217
   output       dtu_ifq_kill_latest_d;
218
 
219
   // within DTU
220
   output       dec_swl_wrt_tcr_w,
221
                            dec_swl_wrtfprs_w,
222
                            dec_swl_ll_done_d,
223
                dec_swl_br_done_d,
224
                            dec_swl_rdsr_sel_thr_d,
225
                            dec_swl_ld_inst_d,
226
                            dec_swl_sta_inst_e,
227
                            dec_swl_std_inst_d,
228
                            dec_swl_st_inst_d,
229
                            dec_swl_fpop_d,
230
                            dec_swl_allfp_d,
231
                            dec_swl_frf_upper_d,
232
                            dec_swl_frf_lower_d,
233
                            dec_swl_div_inst_d,
234
                            dec_swl_mul_inst_d,
235
                            wsr_fixed_inst_w,
236
                            ifu_exu_sethi_inst_d;   // can be sethi or no-op
237
 
238
   output [2:0] dec_dcl_cctype_d;       // 0yy - fcc(yy)
239
                                        // 100 - icc
240
                                        // 110 - xcc
241
                                        // 1X1 - illegal inst!
242
 
243
   //------------------------------------------------------------
244
   // Declarations
245
   //------------------------------------------------------------
246
   // Internal Signals
247
   wire [1:0]   op;
248
   wire [2:0]   op2;
249
   wire [5:0]   op3;
250
   wire [8:0]   opf;
251
 
252
   wire         brsethi_inst,  // op types
253
                            call_inst,
254
                            arith_inst,
255
                            mem_inst;
256
   wire         sethi_or_nop;
257
   wire [15:0]  op3_lo;        // decode op3[3:0]
258
   wire [3:0]   op3_hi;        // decode op3[5:4]
259
 
260
   wire         dbr_inst_d,
261
                            ibr_inst_d,    // jmpl or return
262
                            jmpl_inst_d,
263
                            retn_inst_d,
264
                            sethi_inst_d;
265
 
266
   wire         rdsr_done_d,
267
                rdpr_done_d;
268
   wire         dslot_d;
269
 
270
   wire         use_rsr_d_l;
271
 
272
   wire         flushw_d,
273
                            saved_d,
274
                            restored_d;
275
   wire         save_retn_done_d;
276
   wire         privop_d,
277
                            privop_e,
278
                hprivop_d,
279
                hprivop_e,
280
                valid_hp_rs_d,
281
                valid_hp_rd_d,
282
                            inv_reg_access_d,
283
                rsvchk_fail_d,
284
                            ill_inst_d,
285
                            ill_inst_e;
286
 
287
   wire         inst12_5_nonzero_d,
288
                inst11_8_nonzero_d,
289
                inst9_5_nonzero_d,
290
                rs2_nonzero_d;
291
 
292
   wire         state_chg_inst_d,
293
                            state_chg_inst_e,
294
                            flush_inst_d;
295
 
296
   wire         cctype_sel_imov,   // select which CC's to use
297
                            cctype_sel_fmov,
298
                            cctype_sel_bcc,
299
                            cctype_sel_bpcc;
300
 
301
   wire         rs1_vld_d,
302
                            rs2_vld_d,
303
                            rs3_vld_d,
304
                            rs4_vld_d;
305
 
306
   wire [4:0]   rs1,
307
                            rd;
308
 
309
   wire         rs1_00,           // decoded rs1
310
                            rs1_01,
311
                            rs1_02,
312
                            rs1_05,
313
                            rs1_06,
314
                            rs1_07,
315
                            rs1_09_0e,
316
                            rs1_0f,
317
                rs1_10,
318
                            rs1_12,
319
                            rs1_13,
320
                            rs1_14_15,
321
                            rs1_16_17,
322
                rs1_19,
323
                            rs1_1a,
324
                            rs1_1b,
325
                            rs1_1c_1f,
326
                            rd_00,
327
                            rd_01,
328
                            rd_04,
329
                            rd_05,
330
                            rd_06,
331
                            rd_07,
332
                            rd_09,
333
                            rd_0f,
334
                rd_10,
335
                            rd_11,
336
                            rd_12,
337
                rd_13,
338
                rd_18,
339
                            rd_1a,
340
                            rd_1b,
341
                            rd_1c_1f,
342
                rd_1f,
343
                            rs1_1f;
344
 
345
   wire         fcn0;
346
 
347
   wire         rd_ifusr_d,
348
                            rd_ifusr_e,
349
                rd_ffusr_d,
350
                            rd_ffusr_e,
351
                            rd_exusr_d,
352
                            rd_exusr_e;
353
   wire         wsr_fixed_inst_e,
354
                            wsr_fixed_inst_m,
355
                            wsr_inst_next_e,
356
                            wsr_fixed_inst_d;
357
 
358
   wire         wrt_tcr_d,
359
                            wrt_tcr_e,
360
                            wrt_tcr_qual_e,
361
                            wrt_tcr_m;
362
 
363
   wire         wrt_fprs_d,
364
                            wrt_fprs_e,
365
                            wrt_fprs_qual_e,
366
                            wrt_fprs_m;
367
 
368
   wire         prefetch,
369
                impl_prefetch,
370
                illegal_prefetch,
371
                noop_prefetch,
372
                pref_done_d,
373
                prefetch_d,
374
                prefetch_e;
375
 
376
   wire [2:0]   lstype_d,
377
                            lstype_e;
378
   wire [1:0]   lssize_d;
379
   wire         ldst_dbl_d,
380
                            ldst_fp_d,
381
                            sta_inst_d,
382
//                kill_for_sta_d,
383
                sta_nostf_d,
384
                            sta_inst_e,
385
                sta_nostf_e,
386
                            sext_d,
387
                            ldstub_d,
388
                            casa_d,
389
                casa_e,
390
                            swap_d;
391
 
392
   wire         mb_mask_d,
393
                            mb_inst_d,
394
                            mb_inst_e;
395
 
396
   wire         sir_inst_d,
397
                            sir_inst_e,
398
//                          kill_sir_d,
399
                            flag_sir_d,
400
                            flag_sir_e;
401
 
402
   wire         fpld_d,
403
                            fpop1_d,
404
                visop_d,
405
                int_align_d,
406
                            fpop2_d;
407
   wire         quad_ffuop_d;
408
 
409
   wire         allfp_d,
410
                            any_fpinst_d,
411
                            fpdis_trap_d,
412
                            fpdis_trap_e,
413
                            fcc_mov_d,
414
                            fcc_branch_d;
415
 
416
   wire         rs2_hit,
417
                            opf_hit,
418
                            ibit_hit,
419
                            rs1_hit,
420
                            op3_hit,
421
                            rd_hit,
422
                            op_hit,
423
                            imask_hit,
424
                            imask_hit_e;
425
 
426
   wire         clk;
427
 
428
 
429
//----------------------------------------------------------------------
430
// Code Begins Here
431
//----------------------------------------------------------------------
432
   assign       clk = rclk;
433
 
434
 
435
   assign   op  = dtu_inst_d[31:30];
436
   assign   op2 = dtu_inst_d[24:22];
437
   assign   op3 = dtu_inst_d[24:19];
438
   assign   opf = dtu_inst_d[13:5];
439
 
440
   // decode op
441
   assign   brsethi_inst = ~op[1] & ~op[0];
442
   assign   call_inst    = ~op[1] &  op[0];
443
   assign   arith_inst   =  op[1] & ~op[0];
444
   assign   mem_inst     =  op[1] &  op[0];
445
 
446
   // partial decode op2
447
   assign   sethi_or_nop = op2[2] & ~op2[1] & ~op2[0];
448
 
449
   // decode op3
450
   assign   op3_hi[0] = ~op3[5] & ~op3[4];
451
   assign   op3_hi[1] = ~op3[5] &  op3[4];
452
   assign   op3_hi[2] =  op3[5] & ~op3[4];
453
   assign   op3_hi[3] =  op3[5] &  op3[4];
454
 
455
   assign   op3_lo[0]  = ~op3[3] & ~op3[2] & ~op3[1] & ~op3[0];
456
   assign   op3_lo[1]  = ~op3[3] & ~op3[2] & ~op3[1] &  op3[0];
457
   assign   op3_lo[2]  = ~op3[3] & ~op3[2] &  op3[1] & ~op3[0];
458
   assign   op3_lo[3]  = ~op3[3] & ~op3[2] &  op3[1] &  op3[0];
459
   assign   op3_lo[4]  = ~op3[3] &  op3[2] & ~op3[1] & ~op3[0];
460
   assign   op3_lo[5]  = ~op3[3] &  op3[2] & ~op3[1] &  op3[0];
461
   assign   op3_lo[6]  = ~op3[3] &  op3[2] &  op3[1] & ~op3[0];
462
   assign   op3_lo[7]  = ~op3[3] &  op3[2] &  op3[1] &  op3[0];
463
   assign   op3_lo[8]  =  op3[3] & ~op3[2] & ~op3[1] & ~op3[0];
464
   assign   op3_lo[9]  =  op3[3] & ~op3[2] & ~op3[1] &  op3[0];
465
   assign   op3_lo[10] =  op3[3] & ~op3[2] &  op3[1] & ~op3[0];
466
   assign   op3_lo[11] =  op3[3] & ~op3[2] &  op3[1] &  op3[0];
467
   assign   op3_lo[12] =  op3[3] &  op3[2] & ~op3[1] & ~op3[0];
468
   assign   op3_lo[13] =  op3[3] &  op3[2] & ~op3[1] &  op3[0];
469
   assign   op3_lo[14] =  op3[3] &  op3[2] &  op3[1] & ~op3[0];
470
   assign   op3_lo[15] =  op3[3] &  op3[2] &  op3[1] &  op3[0];
471
 
472
   //-------------------------
473
   // Branch and Move Controls
474
   //-------------------------
475
   // brtype
476
   assign dbr_inst_d = brsethi_inst & (op2[1] | op2[0]) |   // regular branch
477
                             call_inst;
478
   assign jmpl_inst_d = arith_inst & op3_hi[3] & op3_lo[8];  // jmpl
479
   assign retn_inst_d = arith_inst & op3_hi[3] & op3_lo[9];  // retn
480
   assign ibr_inst_d = jmpl_inst_d | retn_inst_d;
481
   assign sethi_inst_d = brsethi_inst & sethi_or_nop;
482
   assign ifu_exu_sethi_inst_d = sethi_inst_d;
483
 
484
   assign dec_swl_br_done_d = (dbr_inst_d | jmpl_inst_d); // br compl.
485
                                                  // retn has separate
486
                                                  // completion signal
487
   assign dtu_fcl_br_inst_d = dbr_inst_d | ibr_inst_d;
488
   assign dec_imd_call_inst_d = call_inst;
489
 
490
   // MV-BR Condition
491
   assign   cctype_sel_imov  =  op[1] & ~op3[4];
492
   assign   cctype_sel_fmov  =  op[1] & op3[4];
493
   assign   cctype_sel_bcc  = ~op[1] &  op2[1];
494
   assign   cctype_sel_bpcc = ~op[1] & ~op2[1];
495
 
496
   mux4ds  #(3) cctype_mux(.dout  (dec_dcl_cctype_d),
497
                                           .in0   ({dtu_inst_d[18], dtu_inst_d[12:11]}),
498
                                           .in1   (dtu_inst_d[13:11]),
499
                                           // op2[2]=1 for fp branch
500
                                           .in2   ({~op2[2], 2'b00}),
501
                                           .in3   ({~op2[2], dtu_inst_d[21:20]}),
502
                                           .sel0  (cctype_sel_imov),
503
                                           .sel1  (cctype_sel_fmov),
504
                                           .sel2  (cctype_sel_bcc),
505
                                           .sel3  (cctype_sel_bpcc));
506
 
507
   //-------------
508
   // ALU Controls
509
   //-------------
510
   // mov bit
511
   assign ifu_exu_aluop_d[2] = brsethi_inst & sethi_or_nop |   // sethi
512
                            arith_inst & op3_hi[2] & op3[3];   // mov, rd
513
 
514
   // aluop
515
   assign ifu_exu_aluop_d[1] = (arith_inst &
516
                                      ((op3_hi[3] & (op3_lo[0] |   // wr
517
                                               op3_lo[2] |   // wrpr
518
                                               op3_lo[3])) | // wrhpr
519
                                                         (~op3[5] & op3[1]))         // xor, or
520
                                );
521
 
522
   // aluop/mov type
523
   assign ifu_exu_aluop_d[0] = (arith_inst &
524
                                      ((op3_hi[3] & (op3_lo[0] |
525
                                               op3_lo[2] |
526
                                               op3_lo[3])) | // wr
527
                                                         (~op3[5] & op3[0])        | // xor, and
528
                                                         (op3_hi[2] & op3_lo[15]))   // movr
529
                                );
530
 
531
   // invert rs2
532
   assign ifu_exu_invert_d  = arith_inst &
533
                              (~op3[5] & op3[2]  |   // sub, andn, orn, xorn
534
                               op3_hi[2] & (op3_lo[3] | op3_lo[1])); // tag sub
535
 
536
   assign ifu_exu_usecin_d   = arith_inst & ~op3[5] & op3[3];   // addc, subc
537
 
538
   // tagged ops
539
   assign ifu_exu_tagop_d = arith_inst & op3_hi[2] & ~op3[3] & ~op3[2] &
540
                                  fcl_dtu_inst_vld_d;
541
   assign ifu_exu_tv_d = ifu_exu_tagop_d & op3[1];
542
   assign ifu_exu_muls_d  = arith_inst & op3_hi[2] & op3_lo[4] &
543
                                  ~swl_dec_divbusy_e & fcl_dtu_ely_inst_vld_d;
544
 
545
   // memory for ibr and ldst address range check
546
   assign ifu_exu_range_check_other_d = mem_inst & ~prefetch; // ld, st, atom
547
   assign ifu_exu_range_check_jlret_d = arith_inst & op3_hi[3] &
548
                                        (op3_lo[8] | op3_lo[9]); // jmpl, retn
549
 
550
   //--------------
551
   // SHFT Controls
552
   //--------------
553
   // enable shifter and choose shift output
554
   // This can be simplified a great deal if MULScc could also be
555
   // decoded as a shift instruction.
556
   // 9/26/01: No can do! Mulscc is implemented now
557
   assign ifu_exu_enshift_d = arith_inst & op3_hi[2] &
558
                               (op3_lo[5] | op3_lo[6] | op3_lo[7]);
559
   // unsigned or signed (1 => signed)
560
   assign ifu_exu_shiftop_d[0] = op3[0];
561
   // left or right (1 => right)
562
   assign ifu_exu_shiftop_d[1] = op3[1];
563
   // shift 32b or 64b (1 => 64)
564
   assign ifu_exu_shiftop_d[2] = dtu_inst_d[12];   // was sh32_64
565
 
566
 
567
   //-------------------
568
   // Writeback Controls
569
   //-------------------
570
   //  write to icc/xcc
571
   assign ifu_exu_setcc_d = arith_inst &
572
                             (op3_hi[1] & (~op3[3] | ~op3[1] & ~op3[0]) |
573
                              op3_hi[2] & (~op3[3] & ~op3[2])); // tagged op
574
   //  write to rd
575
   assign ifu_exu_wen_d = ((~rd_00) & brsethi_inst & sethi_or_nop | // sethi
576
                                 (~rd_00) & arith_inst &  // all single cycle insts
577
                                 (~op3[5] & ~op3[3]    |     // alu ops
578
                                              ~op3[5] & op3_lo[8]  |     // addC
579
                                              ~op3[5] & op3_lo[12] |     // subC
580
                                              op3_hi[2] &
581
                                              (~op3[3] & ~op3_lo[4] |    // shft, tag, ~muls
582
                                               // need to kill if rd to invalid reg
583
                                               // all vld regs will retn in W stage
584
                                               op3_lo[8] & ~rs1_0f | op3_lo[10]  | // rd
585
                             op3_lo[9] | // rdhpr
586
                                               op3_lo[12] | op3_lo[15])| // mov
587
                                              op3_hi[3] &
588
                                              (op3_lo[8]  |    // jmpl
589
                                               op3_lo[12] |    // save
590
                                               op3_lo[13] |    // restore
591
                             op3_lo[6] & int_align_d)  // vis int align
592
                                              )           |
593
                                 call_inst);
594
 
595
   //-----------------
596
   // MUL/DIV Controls
597
   //-----------------
598
   // is mul
599
   assign dec_swl_mul_inst_d = (arith_inst &
600
                                                        ((op3_hi[0] &
601
                                                          (op3_lo[9]  |      // mulx
602
                                                           op3_lo[10] |      // umul
603
                                                           op3_lo[11])) |    // smul
604
                                                         (op3_hi[1] &
605
                                                          (op3_lo[10] |      // umulcc
606
                                                           op3_lo[11])))     // smulcc
607
                                                        );
608
 
609
   assign ifu_exu_muldivop_d[4] = dec_swl_mul_inst_d & ~swl_dec_mulbusy_e &
610
                                  fcl_dtu_ely_inst_vld_d;
611
 
612
   // is div
613
   assign dec_swl_div_inst_d = (arith_inst &
614
                                                        ((op3_hi[0] &
615
                                                          (op3_lo[13]  |     // udivx
616
                                                           op3_lo[14]  |     // udiv
617
                                                           op3_lo[15]))  |   // sdiv
618
                                                         (op3_hi[2] &
619
                                                          (op3_lo[13]   |    // sdivx
620
                                                           op3_lo[4]))  |    // muls
621
                                                         (op3_hi[1] &
622
                                                          (op3_lo[14] |      // udivcc
623
                                                           op3_lo[15])))     // sdivcc
624
                                                        );
625
 
626
   assign ifu_exu_muldivop_d[3] = dec_swl_div_inst_d & ~swl_dec_divbusy_e &
627
                                                          op3[3] & fcl_dtu_ely_inst_vld_d; // not muls
628
 
629
   // 64b or 32b (1 => 64b)
630
   assign ifu_exu_muldivop_d[2] = ~op3[1];
631
 
632
   // signed or unsigned (1 => signed)
633
   assign ifu_exu_muldivop_d[1] = op3_hi[2] |          // sdivx
634
                                        (op3[1] & op3[0]);   // smul, sdiv
635
   // set cc as well?
636
   assign ifu_exu_muldivop_d[0] = op3[4];
637
 
638
   //-------------------------
639
   // FP controls
640
   //-------------------------
641
 
642
   // portion of vis that is actually an int instruction
643
   assign int_align_d = (~opf[8] & ~opf[7] & ~opf[6] & ~opf[5] &
644
                         opf[4] & opf[3] & ~opf[2] & ~opf[0]);
645
   assign ifu_exu_ialign_d = arith_inst & op3_hi[3] & op3_lo[6] &
646
                             int_align_d & fcl_dtu_inst_vld_d;
647
 
648
 
649
   assign fpop1_d = arith_inst & op3_hi[3] & op3_lo[4];
650
   assign fpop2_d = arith_inst & op3_hi[3] & op3_lo[5];
651
   assign visop_d = arith_inst & op3_hi[3] & op3_lo[6];
652
   assign fpld_d = mem_inst & op3[5] & ~op3[3] & ~op3[2];
653
 
654
   // FP stores don't switch out and don't block the fpu
655
   assign dec_swl_fpop_d = (fpop1_d | fpop2_d | fpld_d | visop_d);
656
   assign allfp_d = (fpop1_d | fpop2_d | fpld_d | visop_d |
657
                           mem_inst & op3[5] & ~op3[3] & op3[2]);
658
   assign dec_swl_allfp_d = allfp_d;
659
 
660
   assign ifu_ffu_ldfsr_d = op3_lo[1] & op3_hi[2] & ~rd[0];
661
   assign ifu_ffu_ldxfsr_d = op3_lo[1] & op3_hi[2] & rd[0];
662
   assign ifu_ffu_stfsr_d = op3_lo[5] & op3_hi[2];
663
 
664
   assign ifu_ffu_fpop1_d = fpop1_d & ~swl_dec_fpbusy_e &
665
                            fcl_dtu_ely_inst_vld_d;
666
   assign ifu_ffu_fpop2_d = fpop2_d & ~swl_dec_fpbusy_e &
667
                            fcl_dtu_ely_inst_vld_d;
668
   assign ifu_ffu_visop_d = visop_d & ~swl_dec_fpbusy_e &
669
                            fcl_dtu_ely_inst_vld_d;
670
 
671
   assign ifu_ffu_fld_d =  mem_inst & op3[5] & ~op3[3] & ~op3[2] &
672
                                             fcl_dtu_ely_inst_vld_d & ~swl_dec_fpbusy_e;
673
 
674
   assign ifu_ffu_fst_d =  mem_inst & op3[5] & ~op3[3] & op3[2] &
675
                                       fcl_dtu_ely_inst_vld_d & ~swl_dec_fpbusy_e;
676
 
677
   // ldqf and stqf are not fpops
678
   assign quad_ffuop_d = (opf[1] & opf[0] & (fpop1_d | fpop2_d) |
679
                                fpop1_d & opf[3] & opf[2] & // exc div
680
                                ~(~opf[7] & opf[6] & ~opf[5])) &
681
                                 swl_dec_fp_enable_d & fcl_dtu_inst_vld_d;
682
 
683 113 albert.wat
   dff_s #(1) qope_ff(.din  (quad_ffuop_d),
684 95 fafa1971
                              .q    (ifu_ffu_quad_op_e),
685 113 albert.wat
                              .clk  (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
686 95 fafa1971
 
687
   // quiet traps -- flush the pipe but don't take a trap till later
688
//   assign dec_swl_qtrap_d = mem_inst & op3[5] & op3_lo[6] & fcl_dtu_inst_vld_d;  // stq
689
//   dff #(1) qtrpe_ff(.din  (dec_swl_qtrap_d),
690
//                 .q    (dtu_fcl_qtrap_e),
691 113 albert.wat
//                 .clk  (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
692 95 fafa1971
 
693
   // FP Enabled check
694
   assign fcc_branch_d = ~op[1] & ~op[0] & op3[5] & (op3[4] | op3[3]);
695
   assign fcc_mov_d = op[1] & ~op[0] & op3_hi[2] & op3_lo[12] &
696
                            ~dtu_inst_d[18];
697
 
698
   assign any_fpinst_d = allfp_d | fcc_branch_d | fcc_mov_d |
699
                         arith_inst & op3_hi[2] & op3_lo[8] & rs1_13 | // rd gsr
700
                         arith_inst & op3_hi[3] & op3_lo[0] & rd_13;   // wr gsr
701
 
702
   assign fpdis_trap_d = any_fpinst_d & ~swl_dec_fp_enable_d &
703
                         fcl_dtu_inst_vld_d;
704 113 albert.wat
   dff_s #(1) fpdise_ff(.din (fpdis_trap_d),
705 95 fafa1971
                                .q   (fpdis_trap_e),
706 113 albert.wat
                                .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
707 95 fafa1971
   assign dtu_fcl_fpdis_e = fpdis_trap_e;
708
 
709
   // FRF dirty bits
710
   // bit 0 is the msb for double and quad
711
   assign dec_swl_frf_upper_d = rd[0] & (mem_inst & op3_lo[3] |  // fld
712
                                                            fpop1_d & (opf[7] | opf[6] & opf[5]) &
713
                                         (opf[3] | ~opf[2]) |
714
                                                            fpop1_d & ~opf[7] & opf[1] & ~opf[0] |
715
                                                            fpop2_d & opf[1] |
716
                              visop_d & ~opf[0]);
717
 
718
   assign dec_swl_frf_lower_d = ~rd[0] & (mem_inst & op3_lo[3] |  // fld
719
                                                            fpop1_d & (opf[7] | opf[6] & opf[5]) &
720
                                          (opf[3] | ~opf[2]) |
721
                                                            fpop1_d & ~opf[7] & opf[1] & ~opf[0] |
722
                                                            fpop2_d & opf[1] |
723
                              visop_d & ~opf[0]) |
724
                                                      (fpop2_d & ~opf[1] |  // all sgl ops wrt lower
725
                                     fpop1_d & opf[7] & ~opf[3] & opf[2] |
726
                                     //bug 6470 - fdtoi,fstoi,fqtoi
727
                                     (fpop1_d & (opf[7:6]==2'b11) & (opf[3:2]==2'b00)) |
728
                                     //bug6470 - end
729
                                                       fpop1_d & ~opf[7] & ~opf[1] & opf[0] |
730
                               visop_d & opf[0] |
731
                                                       mem_inst & op3_lo[0] & op3[5]);
732
 
733
 
734
   //-------------------------
735
   // Special Reg R/W Controls
736
   //-------------------------
737
   // decode rs1
738
   assign rs1 = dtu_inst_d[18:14];
739
   assign rs1_00 = ~rs1[4] & ~rs1[3] & ~rs1[2] & ~rs1[1] & ~rs1[0]; // Y
740
   assign rs1_01 = ~rs1[4] & ~rs1[3] & ~rs1[2] & ~rs1[1] & rs1[0]; //
741
   assign rs1_02 = ~rs1[4] & ~rs1[3] & ~rs1[2] & rs1[1] & ~rs1[0];  // CCR
742
   assign rs1_05 = ~rs1[4] & ~rs1[3] & rs1[2] & ~rs1[1] & rs1[0]; // PC
743
   assign rs1_06 = ~rs1[4] & ~rs1[3] & rs1[2] & rs1[1] & ~rs1[0]; // fprs
744
   assign rs1_07 = ~rs1[4] & ~rs1[3] & rs1[2] & rs1[1] & rs1[0]; //
745
   assign rs1_0f = ~rs1[4] & rs1[3] & rs1[2] & rs1[1] & rs1[0];   // mem#
746
   assign rs1_10 = rs1[4] & ~rs1[3] & ~rs1[2] & ~rs1[1] & ~rs1[0];
747
   assign rs1_12 = rs1[4] & ~rs1[3] & ~rs1[2] & rs1[1] & ~rs1[0];
748
   assign rs1_13 = rs1[4] & ~rs1[3] & ~rs1[2] & rs1[1] & rs1[0];
749
   assign rs1_14_15 = rs1[4] & ~rs1[3] & rs1[2] & ~rs1[1];
750
   assign rs1_16_17 = rs1[4] & ~rs1[3] & rs1[2] & rs1[1];
751
   assign rs1_19 = rs1[4] & rs1[3] & ~rs1[2] & ~rs1[1] & rs1[0];
752
   assign rs1_1f = rs1[4] & rs1[3] & rs1[2] & rs1[1] & rs1[0];    // 
753
   assign rs1_1a = rs1[4] & rs1[3] & ~rs1[2] & rs1[1] & ~rs1[0]; // THR
754
   assign rs1_1b = rs1[4] & rs1[3] & ~rs1[2] & rs1[1] & rs1[0];
755
   assign rs1_1c_1f = rs1[4] & rs1[3] & rs1[2];
756
   assign rs1_09_0e = ~rs1[4] & rs1[3] &          // all window mgmt regs
757
                      (rs1[2] & ~rs1[1] | rs1[1] & ~rs1[0] |
758
                             rs1[0] & ~rs1[2]);
759
 
760
   // decode rd
761
   assign rd = dtu_inst_d[29:25];
762
   assign rd_00 = ~rd[4] & ~rd[3] & ~rd[2] & ~rd[1] & ~rd[0]; // mem#
763
   assign rd_01 = ~rd[4] & ~rd[3] & ~rd[2] & ~rd[1] & rd[0]; // 
764
   assign rd_04 = ~rd[4] & ~rd[3] & rd[2] & ~rd[1] & ~rd[0]; //  tick
765
   assign rd_05 = ~rd[4] & ~rd[3] & rd[2] & ~rd[1] & rd[0];  //  PC
766
   assign rd_06 = ~rd[4] & ~rd[3] & rd[2] & rd[1] & ~rd[0];
767
   assign rd_07 = ~rd[4] & ~rd[3] & rd[2] & rd[1] & rd[0];
768
   assign rd_09 = ~rd[4] & rd[3] & ~rd[2] & ~rd[1] & rd[0]; // CWP
769
   assign rd_0f = ~rd[4] & rd[3] & rd[2] & rd[1] & rd[0];   // not impl
770
   assign rd_10 = rd[4] & ~rd[3] & ~rd[2] & ~rd[1] & ~rd[0];   // gl
771
   assign rd_11 = rd[4] & ~rd[3] & ~rd[2] & ~rd[1] & rd[0];   // pic
772
   assign rd_12 = rd[4] & ~rd[3] & ~rd[2] & rd[1] & ~rd[0];   // not impl
773
   assign rd_13 = rd[4] & ~rd[3] & ~rd[2] & rd[1] & rd[0];   // GSR
774
   assign rd_18 = rd[4] & rd[3] & ~rd[2] & ~rd[1] & ~rd[0]; // stick   
775
   assign rd_1a = rd[4] & rd[3] & ~rd[2] & rd[1] & ~rd[0]; // Thr
776
   assign rd_1b = rd[4] & rd[3] & ~rd[2] & rd[1] & rd[0];
777
   assign rd_1c_1f = rd[4] & rd[3] & rd[2];
778
   assign rd_1f = rd[4] & rd[3] & rd[2] & rd[1] & rd[0];
779
 
780
   assign ifu_lsu_wsr_inst_d = arith_inst & fcl_dtu_ely_inst_vld_d &
781
                               op3_hi[3] & (op3_lo[0] | op3_lo[2] | op3_lo[3]);
782
   assign ifu_exu_wsr_inst_d = ifu_lsu_wsr_inst_d;
783
 
784
   assign ifu_tlu_rsr_inst_d = arith_inst & fcl_dtu_ely_inst_vld_d &
785
                               op3_hi[2] & (op3_lo[8] & ~rs1_0f | // ~membar
786
                                      op3_lo[9] |           // hpr
787
                                                                    op3_lo[10]);          // pr
788
 
789
   assign rdsr_done_d = arith_inst & op3_hi[2] & op3_lo[8] & ~mb_inst_d;
790
   assign rdpr_done_d = arith_inst & op3_hi[2] & (op3_lo[10] | op3_lo[9]);
791
 
792
   // all wrpr's except cwp are fixed length
793
   // 
794
   assign wsr_fixed_inst_d = arith_inst & op3_hi[3] &
795
                               (op3_lo[2] & ~rd_09 |  // wrpr exc. cwp 
796
                                      op3_lo[0] & ~rd_1a |  // wr exc. thr
797
                                op3_lo[3]);           // wrhpr
798
 
799
 
800 113 albert.wat
   dff_s #(1) wre_ff(.din (wsr_fixed_inst_d),
801 95 fafa1971
                             .clk (clk),
802
                             .q   (wsr_fixed_inst_e),
803 113 albert.wat
                             .se  (se), `SIMPLY_RISC_SCANIN, .so());
804 95 fafa1971
 
805
   assign wsr_inst_next_e = (~dtu_inst_anull_e) & wsr_fixed_inst_e &
806
                                  fcl_dtu_inst_vld_e;
807
 
808 113 albert.wat
   dff_s #(1) wrm_ff(.din (wsr_inst_next_e),
809 95 fafa1971
                             .clk (clk),
810
                             .q   (wsr_fixed_inst_m),
811 113 albert.wat
                             .se  (se), `SIMPLY_RISC_SCANIN, .so());
812 95 fafa1971
 
813 113 albert.wat
   dff_s #(1) wrw_ff(.din (wsr_fixed_inst_m),
814 95 fafa1971
                             .clk (clk),
815
                             .q   (wsr_fixed_inst_w),
816 113 albert.wat
                             .se  (se), `SIMPLY_RISC_SCANIN, .so());
817 95 fafa1971
 
818
   assign use_rsr_d_l = ~(ifu_tlu_rsr_inst_d | ibr_inst_d | call_inst);
819
 
820 113 albert.wat
   dff_s #(1) rdsre_ff(.din (use_rsr_d_l),
821 95 fafa1971
                               .clk (clk),
822
                               .q   (ifu_exu_use_rsr_e_l),
823 113 albert.wat
                               .se  (se), `SIMPLY_RISC_SCANIN, .so());
824 95 fafa1971
 
825
   assign flush_inst_d = fcl_dtu_inst_vld_d & arith_inst &
826
                               op3_hi[3] & op3_lo[11];
827
 
828 113 albert.wat
   dff_s #(1) flsh_ff(.din (flush_inst_d),
829 95 fafa1971
                              .q   (ifu_tlu_flsh_inst_e),
830
                              .clk (clk),
831 113 albert.wat
                              .se  (se), `SIMPLY_RISC_SCANIN, .so());
832 95 fafa1971
 
833
 
834
   // If machine state is changed kill the already fetched instructions
835
   assign state_chg_inst_d = ifu_lsu_wsr_inst_d | flush_inst_d |
836
                                   ifu_tlu_done_inst_d | ifu_tlu_retry_inst_d;
837
 
838
 
839 113 albert.wat
   dff_s #(1) schg_ff(.din (state_chg_inst_d),
840 95 fafa1971
                                .clk (clk),
841
                                .q   (state_chg_inst_e),
842
//                             .rst (reset),
843 113 albert.wat
                                .se  (se), `SIMPLY_RISC_SCANIN, .so());
844 95 fafa1971
 
845
//   assign sta_inst_d = mem_inst & op3[4] & fcl_dtu_inst_vld_d & 
846
//                       (~op3[5] & ~op3[3] & op3[2] |
847
//                                        op3[5] & (op3_lo[4] | op3_lo[7]) |
848
//                                        ~op3[5] & op3_lo[14]);
849
   assign sta_inst_d = mem_inst & op3[4] & op3[2] & fcl_dtu_inst_vld_d & ~prefetch;
850
 
851
   assign sta_nostf_d = mem_inst & op3[4] & fcl_dtu_inst_vld_d &
852
                       (~op3[5] & ~op3[3] & op3[2] |
853
                                          ~op3[5] & op3_lo[14]);
854
 
855 113 albert.wat
   dff_s #(1) sta_ff (.din (sta_inst_d),
856 95 fafa1971
                              .clk (clk),
857
                              .q   (sta_inst_e),
858 113 albert.wat
                              .se  (se), `SIMPLY_RISC_SCANIN, .so());
859 95 fafa1971
 
860 113 albert.wat
   dff_s #(1) stanf_ff (.din (sta_nostf_d),
861 95 fafa1971
                                  .clk (clk),
862
                                  .q   (sta_nostf_e),
863 113 albert.wat
                                  .se  (se), `SIMPLY_RISC_SCANIN, .so());
864 95 fafa1971
 
865
  assign dec_swl_sta_inst_e = sta_nostf_e;
866
 
867
   // Mov qualification with inst_vld_e to FCL?  Done
868
   assign dtu_fcl_flush_sonly_e = (sta_inst_e & lsu_ifu_ldsta_internal_e |
869
                                   state_chg_inst_e);
870
 
871 113 albert.wat
   dff_s #(1) ds_ff(.din (fcl_dec_dslot_s),
872 95 fafa1971
                  .q   (dslot_d),
873 113 albert.wat
                  .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
874 95 fafa1971
 
875
   // suppress ifetch if arch state changes in delay slot (if not 
876
   // suppressed, it may cause in error in the L2 for an unmapped 
877
   // address). 
878
//   assign dtu_ifq_kill_latest_d = ifu_lsu_wsr_inst_d | flush_inst_d |
879
//                                    ifu_tlu_done_inst_d | ifu_tlu_retry_inst_d |  
880
//                                sta_inst_d;
881
   assign dtu_ifq_kill_latest_d = (((arith_inst & op3_hi[3] &
882
                                     (op3_lo[2] | op3_lo[3] | op3_lo[0]) |// wr
883
                                     mem_inst & op3[4] & op3[2]) &
884
                                    fcl_dtu_ely_inst_vld_d) |
885
                                   fcl_dec_intr_vld_d) & dslot_d; // in DS
886
 
887
//   assign kill_for_sta_d = mem_inst & op3[4] & op3[2] & 
888
                           // ~op3[5] &  // sta - excl stf and pref
889
//                           fcl_dtu_ely_inst_vld_d & dslot_d; // in DS
890
 
891
//   dff #(1) kfste_ff(.din (kill_for_sta_d),
892
//                     .q   (kill_for_sta_e),
893 113 albert.wat
//                     .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
894 95 fafa1971
//   assign dec_fcl_kill4sta_e = kill_for_sta_e;
895
 
896
   assign rd_ifusr_d = arith_inst & op3_hi[2] &
897
                             (op3_lo[9] & rs1_06    |  // rdhpr - ver
898
                                          op3_lo[8] & (rs1_05 |    // rdsr - pc
899
                                                             rs1_1a |    // rdsr - thr
900
                                                             rs1_06))  | // rdsr - fprs
901
                                     jmpl_inst_d |                    // jmpl
902
                             call_inst;                         // call
903
 
904
   assign rd_exusr_d = arith_inst & op3_hi[2] &
905
                (op3_lo[10] & rs1_09_0e |         // rdpr (wind)
906
                             op3_lo[8] & (rs1_00 | rs1_02));  // rdsr (y + ccr)
907
 
908
   assign rd_ffusr_d = arith_inst & op3_hi[2] &
909
                                         op3_lo[8] & rs1_13;  // rdsr (gsr)
910
 
911 113 albert.wat
   dff_s #(1) ifusr_ff(.din  (rd_ifusr_d),
912 95 fafa1971
                               .clk  (clk),
913
                               .q    (rd_ifusr_e),
914 113 albert.wat
                               .se   (se), `SIMPLY_RISC_SCANIN, .so());
915
   dff_s #(1) ffusr_ff(.din  (rd_ffusr_d),
916 95 fafa1971
                               .clk  (clk),
917
                               .q    (rd_ffusr_e),
918 113 albert.wat
                               .se   (se), `SIMPLY_RISC_SCANIN, .so());
919
   dff_s #(1) exusr_ff(.din  (rd_exusr_d),
920 95 fafa1971
                               .clk  (clk),
921
                               .q    (rd_exusr_e),
922 113 albert.wat
                               .se   (se), `SIMPLY_RISC_SCANIN, .so());
923 95 fafa1971
 
924
   // make sure they are exclusive
925
   assign ifu_exu_rd_ifusr_e = rd_ifusr_e;
926
   assign ifu_exu_rd_exusr_e = rd_exusr_e;
927
   assign ifu_exu_rd_ffusr_e = rd_ffusr_e;
928
 
929
   // choose which of IFU special regs should be read
930
   // call, jmpl or rdpc (05) => pc
931
   assign dec_fcl_rdsr_sel_pc_d = ~dtu_inst_d[31] | op3_hi[3] | ~rs1[1] & rs1[0];
932
   // read thread conf (1a) or fprs (06)
933
   assign dec_fcl_rdsr_sel_thr_d = dtu_inst_d[31] & op3_hi[2] & op3_lo[8] & ~rs1[0];
934
   // else version reg (rdhpr 06)
935
 
936
   //   dff #(1) rdfprs_ff(.din (rs1[4]),
937
   //               .q   (dec_swl_rdsr_sel_thr_e),
938 113 albert.wat
   //               .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
939 95 fafa1971
   assign dec_swl_rdsr_sel_thr_d = rs1[4];
940
 
941
   assign wrt_tcr_d = arith_inst & fcl_dtu_inst_vld_d &
942
                            op3_hi[3] & op3_lo[0] & rd_1a;
943
 
944 113 albert.wat
   dff_s #(1) tcre_ff(.din  (wrt_tcr_d),
945 95 fafa1971
                                .clk  (clk),
946
                                .q    (wrt_tcr_e),
947 113 albert.wat
                                .se   (se), `SIMPLY_RISC_SCANIN, .so());
948 95 fafa1971
 
949
   assign wrt_tcr_qual_e = wrt_tcr_e & (~dtu_inst_anull_e) &
950
                                                                       fcl_dtu_inst_vld_e;
951
 
952 113 albert.wat
   dff_s #(1) tcrm_ff(.din  (wrt_tcr_qual_e),
953 95 fafa1971
                              .clk  (clk),
954
                              .q    (wrt_tcr_m),
955 113 albert.wat
                              .se   (se), `SIMPLY_RISC_SCANIN, .so());
956 95 fafa1971
 
957 113 albert.wat
   dff_s #(1) tcrw_ff(.din  (wrt_tcr_m),
958 95 fafa1971
                              .clk  (clk),
959
                              .q    (dec_swl_wrt_tcr_w),
960 113 albert.wat
                              .se   (se), `SIMPLY_RISC_SCANIN, .so());
961 95 fafa1971
 
962
   // FPRS write
963
   assign wrt_fprs_d = arith_inst & fcl_dtu_inst_vld_d &
964
                             op3_hi[3] & op3_lo[0] & rd_06;
965 113 albert.wat
   dff_s #(1) fprse_ff(.din  (wrt_fprs_d),
966 95 fafa1971
                               .clk  (clk),
967
                               .q    (wrt_fprs_e),
968 113 albert.wat
                               .se   (se), `SIMPLY_RISC_SCANIN, .so());
969 95 fafa1971
   assign wrt_fprs_qual_e = wrt_fprs_e & (~dtu_inst_anull_e) &
970
                                                                         fcl_dtu_inst_vld_e;
971 113 albert.wat
   dff_s #(1) fprsm_ff(.din  (wrt_fprs_qual_e),
972 95 fafa1971
                               .clk  (clk),
973
                               .q    (wrt_fprs_m),
974 113 albert.wat
                               .se   (se), `SIMPLY_RISC_SCANIN, .so());
975
   dff_s #(1) fprsw_ff(.din  (wrt_fprs_m),
976 95 fafa1971
                               .clk  (clk),
977
                               .q    (dec_swl_wrtfprs_w),
978 113 albert.wat
                               .se   (se), `SIMPLY_RISC_SCANIN, .so());
979 95 fafa1971
 
980
   //----------------
981
   // RF/RML Controls
982
   //----------------
983
   // Reg Valid Signals for doing ECC
984
 
985
   //bug6777 - cas decode is incorrect
986
   //         ~(op3_hi[3] & dtu_inst_d[22] & mem_inst); // CAS
987
   assign ifu_exu_useimm_d = ~dtu_inst_d[31] |
988
                              dtu_inst_d[13] &
989
                             ~(op3_hi[3] & dtu_inst_d[22] & ~op3[0] & mem_inst); // CAS
990
 
991
   // alternately try: ~ren2_d | ~23 | ~22
992
   assign rs1_vld_d = (brsethi_inst & op2[1] & op2[0] |
993
                                   arith_inst & (~op3[5] |
994
                                                             op3_hi[2] & ~op3[3] |
995
                                                             op3_hi[2] & op3_lo[13] |
996
                                                             op3_hi[2] & op3_lo[15] |
997
                                                             op3_hi[3] & op3_lo[0]  |
998
                                                             op3_hi[3] & op3_lo[2]  |
999
                                                             op3_hi[3] & op3_lo[3]  |
1000
                                                             op3_hi[3] & op3_lo[5] &
1001
                                     ~opf[4] & ~opf[3] & opf[2] |  // fmovr
1002
                                                             op3_hi[3] & op3_lo[6] & int_align_d  |
1003
                                                             op3_hi[3] & op3[3] & ~op3[2] |
1004
                                                             op3_hi[3] & op3[3] & ~op3[1]) |
1005
                                   mem_inst & (~op3[5] |
1006
                                                           ~op3[3] |
1007
                                                           op3[4] & op3[3] & op3[2]));
1008
 
1009
   assign ifu_exu_rs1_vld_d = rs1_vld_d;
1010
 
1011
   assign rs2_vld_d = (arith_inst & (~op3[5] |
1012
                                                             op3_hi[2] & (~op3[3] | op3[2]) |
1013
                                                             op3_hi[3] & op3_lo[0]  |
1014
                                                             op3_hi[3] & op3_lo[2]  |
1015
                                                             op3_hi[3] & op3_lo[3]  |
1016
                                                             op3_hi[3] & op3_lo[6] & int_align_d  |
1017
                                                             op3_hi[3] & op3[3] & ~op3[2] |
1018
                                                             op3_hi[3] & op3[3] & ~op3[1]) &
1019
                                               ~dtu_inst_d[13] |
1020
                                   mem_inst & (~op3[5] |
1021
                                                           ~op3[3]) & ~dtu_inst_d[13] |
1022
                                   mem_inst & op3_hi[3] & (op3_lo[12] |   // cas
1023
                                                                             op3_lo[14]));
1024
 
1025
   assign ifu_exu_rs2_vld_d = rs2_vld_d;
1026
 
1027
   assign rs3_vld_d = mem_inst & (~op3[5] & ~op3[3] & op3[2] | // all st
1028
                                                          ~op3[5] & op3[3] & op3[2] | // swp,stx,ldstub
1029
                                                          op3_hi[3] & (op3_lo[12] |   // cas
1030
                                                                             op3_lo[14])) |
1031
                      arith_inst & (op3_hi[2] & (op3_lo[12] |
1032
                                                 op3_lo[15]));
1033
 
1034
   // for std and stq(=stda) & ~stf
1035
   assign rs4_vld_d = mem_inst & ~op3[5] & op3_lo[7];
1036
 
1037
   // rs3even = rs4 + rs3 & ~rd[0]
1038
   // rs3odd = rs4 + rs3 & rd[0]
1039
   // needs both to distinguish std
1040
   assign ifu_exu_rs3e_vld_d = rs4_vld_d | rs3_vld_d & ~rd[0];
1041
   assign ifu_exu_rs3o_vld_d = rs4_vld_d | rs3_vld_d & rd[0];
1042
 
1043
   // RML control signals
1044
   assign ifu_exu_save_d = arith_inst & op3_hi[3] & op3_lo[12] &
1045
                           fcl_dtu_inst_vld_d;
1046
   assign ifu_exu_restore_d = arith_inst & op3_hi[3] & fcl_dtu_inst_vld_d &
1047
                        (op3_lo[13] |       // restore
1048
                                     op3_lo[9]);        // return
1049
   assign ifu_exu_return_d = arith_inst & op3_hi[3] & op3_lo[9] &
1050
                             fcl_dtu_inst_vld_d;
1051
 
1052
   assign save_retn_done_d = arith_inst & op3_hi[3] & (op3_lo[12] | op3_lo[9]);
1053
   assign saved_d = arith_inst & op3_hi[3] & op3_lo[1] & ~dtu_inst_d[25] &
1054
                    fcl_dtu_inst_vld_d;
1055
   assign restored_d = arith_inst & op3_hi[3] & op3_lo[1] & dtu_inst_d[25] &
1056
                     fcl_dtu_inst_vld_d;
1057
   assign flushw_d = arith_inst & op3_hi[2] & op3_lo[11] & fcl_dtu_inst_vld_d;
1058
 
1059 113 albert.wat
   dff_s #(1) savd_ff(.din  (saved_d),
1060 95 fafa1971
                              .clk  (clk),
1061
                              .q    (ifu_exu_saved_e),
1062 113 albert.wat
                              .se   (se), `SIMPLY_RISC_SCANIN, .so());
1063
   dff_s #(1) restd_ff(.din  (restored_d),
1064 95 fafa1971
                               .clk  (clk),
1065
                               .q    (ifu_exu_restored_e),
1066 113 albert.wat
                               .se   (se), `SIMPLY_RISC_SCANIN, .so());
1067
   dff_s #(1) flushw_ff(.din  (flushw_d),
1068 95 fafa1971
                                .clk  (clk),
1069
                                .q    (ifu_exu_flushw_e),
1070 113 albert.wat
                                .se   (se), `SIMPLY_RISC_SCANIN, .so());
1071 95 fafa1971
 
1072
   //-----------------------
1073
   // TLU Controls and Traps
1074
   //-----------------------
1075
   // Done/Retry
1076
   assign ifu_tlu_done_inst_d = arith_inst & op3_hi[3] & op3_lo[14] &
1077
                                fcl_dtu_ely_inst_vld_d &
1078
                                ~dtu_inst_d[25];   // inst_d[25] = lsb of fcn
1079
   assign ifu_tlu_retry_inst_d = arith_inst & op3_hi[3] & op3_lo[14] &
1080
                                fcl_dtu_ely_inst_vld_d & dtu_inst_d[25];
1081
 
1082
   // SIR
1083
   assign sir_inst_d = arith_inst & op3_hi[3] & op3_lo[0] &
1084
                       rs1_00 & rd_0f & dtu_inst_d[13];
1085
 
1086
//   assign kill_sir_d = sir_inst_d & ~(fcl_dtu_privmode_d | fcl_dtu_hprivmode_d);
1087
//bug 6484 - flag sir instrn. to tlu only in hpriv mode
1088
//   assign flag_sir_d = sir_inst_d & (fcl_dtu_privmode_d | fcl_dtu_hprivmode_d);
1089
 
1090
   assign flag_sir_d = sir_inst_d & fcl_dtu_hprivmode_d;
1091
 
1092 113 albert.wat
   dff_s #(1) sire_ff(.din (flag_sir_d),
1093 95 fafa1971
                              .q   (sir_inst_e),
1094 113 albert.wat
                              .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
1095 95 fafa1971
   assign dtu_fcl_sir_inst_e = sir_inst_e;
1096
 
1097
//bug 6484 - kill sir instrn. to tlu if bits other than opcode bits cause illegal instrn.
1098
//   assign flag_sir_e = sir_inst_e & fcl_dtu_inst_vld_e & ~dtu_inst_anull_e;
1099
 
1100
   assign flag_sir_e = sir_inst_e & fcl_dtu_inst_vld_e & ~dtu_inst_anull_e & ~ill_inst_e;
1101
 
1102 113 albert.wat
   dff_s #(1) sirm_ff(.din (flag_sir_e),
1103 95 fafa1971
                              .q   (ifu_tlu_sir_inst_m),
1104 113 albert.wat
                              .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
1105 95 fafa1971
 
1106
 
1107
   // Privileged opcode trap
1108
   assign fcn0 = ~rd[4] & ~rd[3] & ~rd[2] & ~rd[1];
1109
 
1110
         //op3_lo[0] & rd[4] & ~(rd_12 | rd_13 | 
1111
         //rd[3] & ~rd_1a |
1112
   //rd_1f)) | 
1113
 
1114
   assign privop_d = (op3_hi[3] & (op3_lo[14] | // done/retr
1115
                                                           op3_lo[2] |         // wrpr
1116
                                   // & (~rd[4] & ~rd_0f | rd_10) |
1117
                                   // op3_lo[3] |         // wrhpr
1118
                                   // & valid_hp_rd_d |  
1119
                                                           op3_lo[1] |  // savd,restd
1120
                                                           op3_lo[0] & ((rd[4] & ~(rd_11 | rd_12 | rd_13 | rd_1b |
1121
                                                                                                     rd[3] & rd[2])) |
1122
                                                rd_04)) | // wrasr
1123
 
1124
                                  op3_hi[2] & (op3_lo[10] |        // rdpr
1125
                                   // & (~rs1[4] | rs1_10 | rs1_1f) |
1126
                                   // op3_lo[9] |         // rdhpr
1127
                                   // & valid_hp_rs_d |
1128
                                                           op3_lo[8] &           // rdasr & ~mem#
1129
                                                           (rs1_10 | rs1_16_17 | // perf + sftint
1130
                                    rs1_19 | rs1_1a))    // stick, thrd stat
1131
                                  ) & arith_inst & ~(fcl_dtu_privmode_d |
1132
                                         fcl_dtu_hprivmode_d);
1133
 
1134
   // hp regs 0,1,3 and 5, 6 and 1f are implemented
1135
   // 6 is read only
1136
 
1137
   assign valid_hp_rd_d = (~rd[4] & ~rd[3] & rd[0] &
1138
                           (~rd[2] | ~rd[1]) |      // 1,3,5
1139
                           rd_00 | rd_1f );          // 0, 1f
1140
   assign valid_hp_rs_d = (~rs1[4] & ~rs1[3] & rs1[0] &
1141
                           (~rs1[2] | ~rs1[1]) |
1142
                           rs1_00 | rs1_06 | rs1_1f);
1143
 
1144
   assign hprivop_d = arith_inst & ~fcl_dtu_hprivmode_d &
1145
                      (op3_hi[3] & op3_lo[3] |      // wrhpr
1146
                       // & valid_hp_rd_d 
1147
                       op3_hi[2] & op3_lo[9] |      // rdhpr
1148
                       // & valid_hp_rs_d 
1149
                       // bug 6484 ----
1150
                       sir_inst_d |
1151
                       //  ----
1152
                       op3_hi[3] & op3_lo[0] &
1153
                          (rd_04 | rd_18) & fcl_dtu_privmode_d |   // wrsr s/tick
1154
                       op3_hi[3] & op3_lo[2] &
1155
                          rd_04 & fcl_dtu_privmode_d);             // wrpr
1156
 
1157 113 albert.wat
   dff_s #(1) prope_ff(.din (privop_d),
1158 95 fafa1971
                                 .q   (privop_e),
1159 113 albert.wat
                                 .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
1160 95 fafa1971
 
1161 113 albert.wat
   dff_s #(1) hprope_ff(.din (hprivop_d),
1162 95 fafa1971
                                 .q   (hprivop_e),
1163 113 albert.wat
                                 .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
1164 95 fafa1971
   assign dtu_fcl_privop_e = privop_e & ~hprivop_e;
1165
//   assign dtu_fcl_hprivop_e = hprivop_e & ~dtu_inst_anull_e;   
1166
 
1167
   // Illegal Instruction Trap
1168
   // when they are accessed.  
1169
   assign inv_reg_access_d = arith_inst & (op3_hi[2] & op3_lo[8] &    // rd asr
1170
                                                                         (rs1_01 | rs1_07 |         // 1, 7
1171
                                            ~rs1[4] & rs1[3] & ~rs1_0f |  // 8-E, F=mem#
1172
                                                                          rs1_12 | rs1_14_15 |      // 13 is gsr
1173
                                                                   // 14-15 are WO
1174
                                            rs1_1b |
1175
                                            rs1_1c_1f) |
1176
 
1177
                                                                         op3_hi[3] & op3_lo[0] &   // wr asr
1178
                                                                         (rd_01 | rd_05 | rd_07 |
1179
                                            ~rd[4] & rd[3] & ~rd_0f | // 8-E, F is sir
1180
                                                                          rd_12 | rd_1b |
1181
                                            rd_1c_1f)
1182
                                           );
1183
 
1184
   // reserved field checking (more done in ill_inst check below)
1185
   assign inst12_5_nonzero_d = (|dtu_inst_d[12:5]);
1186
   assign inst11_8_nonzero_d = (|dtu_inst_d[11:8]);
1187
   assign inst9_5_nonzero_d = (|dtu_inst_d[9:5]);
1188
   assign rs2_nonzero_d = (|dtu_inst_d[4:0]);
1189
 
1190
   // rsv check is not complete, but most of the important 
1191
   // holes are covered
1192
   assign rsvchk_fail_d = (arith_inst & ((~op3[5] |  // arith
1193
                                          op3_hi[2] & op3_lo[13] | // sdivx
1194
                                          op3_hi[2] & ~op3[3] & ~op3[2] | // tag
1195
                                          op3_hi[2] & op3_lo[4] |  // mulscc
1196
                                          op3_hi[3] & op3_lo[11] | // flsh
1197
                                          op3_hi[3] & op3[3] & ~op3[1]) & // sav,jmp
1198
                                         ~dtu_inst_d[13] & inst12_5_nonzero_d |
1199
 
1200
                                         op3_hi[2] & (op3[3] & ~op3[2] &  // rd/rdpr
1201
                                                      ~(rs1_0f &
1202
                                                        dtu_inst_d[13]) | // ~mem#
1203
                                                      op3_lo[11]) &  // flshw
1204
                                         (inst12_5_nonzero_d |
1205
                                          rs2_nonzero_d |
1206
                                          dtu_inst_d[13]) |
1207
 
1208
                                         op3_hi[3] & ~op3[3] & ~op3[2] & // wr/pr
1209
                                         ~rd_0f &  // ~sir
1210
                                         ~dtu_inst_d[13] & inst12_5_nonzero_d |
1211
 
1212
                                                                 op3_hi[2] & op3_lo[12] &  // movcc
1213
                                         ~dtu_inst_d[13] &
1214
                                         (inst9_5_nonzero_d | dtu_inst_d[10]) |
1215
 
1216
                                         op3_hi[2] & op3_lo[15] &  // movr
1217
                                         ~dtu_inst_d[13] &
1218
                                         inst9_5_nonzero_d |
1219
 
1220
                                         op3_hi[3] & op3_lo[11] &  // flsh
1221
                                         ~rd_00 |
1222
 
1223
                                         op3_hi[2] & op3_lo[11] &  // flshw
1224
                                         (~rd_00 | ~rs1_00) |
1225
 
1226
                                                                 op3_hi[2] &
1227
                                         (op3_lo[5] | op3_lo[6] |
1228
                                          op3_lo[7]) & // shft
1229
                                         (inst11_8_nonzero_d |
1230
                                          dtu_inst_d[7] |
1231
                                          dtu_inst_d[6] |
1232
                                          dtu_inst_d[5] & (~dtu_inst_d[12] |
1233
                                                           ~dtu_inst_d[13]))
1234
                                         ) |
1235
 
1236
                                       mem_inst & (~op3[4] & ~dtu_inst_d[13] &  // ld/st
1237
                                       inst12_5_nonzero_d |
1238
                                       op3_hi[3] &
1239
                                       (op3_lo[12] | op3_lo[14]) &  // cas
1240
                                       dtu_inst_d[13] & inst12_5_nonzero_d) |
1241
 
1242
                                       ((op[1] & ~op[0]) & (op3[5] & op3[4] & op3[3] & ~op3[2] & ~op3[1] & op3[0]) & |rd) // RETURN(rd != 0), bug 4490
1243
 
1244
                           );
1245
 
1246
 
1247
 
1248
   assign ill_inst_d = (brsethi_inst & (~op2[2] & ~op2[1] & ~op2[0] |  // ill inst
1249
                                                                      op2[2] & op2[1] & op2[0] | // null
1250
                                                                      op2[1] & op2[0] &  // wrong bpr cond
1251
                                                                      (~dtu_inst_d[25] & ~dtu_inst_d[26] |
1252
                                         dtu_inst_d[28]) | // b28 has to be 0
1253
                                                                      ~op2[2] & ~op2[1] & op2[0] & // bpcc
1254
                                                                      dtu_inst_d[20]) |
1255
                                          arith_inst & (op3_hi[1] & (op3_lo[9] | op3_lo[13]) |
1256
                                                              op3_hi[3] & (op3_lo[15] | // null
1257
                                                                                       op3_lo[7]) | // impdep2
1258
                                                              op3_hi[3] & op3_lo[14] &
1259
                                                              (~fcn0 | fcl_dtu_tlzero_d |
1260
                                       rs2_nonzero_d | inst12_5_nonzero_d |
1261
                                       dtu_inst_d[13] | ~rs1_00) |  // done/retr
1262
                                                              op3_hi[2] & op3_lo[12] & // movcc
1263
                                                              dtu_inst_d[18] & dtu_inst_d[11] |
1264
                                                              op3_hi[2] & op3_lo[15] &  // movr
1265
                                                              ~dtu_inst_d[11] & ~dtu_inst_d[10] |
1266
                                                              op3_hi[2] & op3_lo[14] | // popc
1267
                                                              op3_hi[2] & op3_lo[9] &  //rdhpr
1268
                                      (~valid_hp_rs_d | rs1_01 & fcl_dtu_tlzero_d) |
1269
                                                              op3_hi[2] & op3_lo[10] &      // rdpr
1270
                                                              (rs1[4] & ~rs1_10 | // not gl
1271
                                       rs1_0f |
1272
                                                               ~rs1[4] & ~rs1[3] & ~rs1[2] & fcl_dtu_tlzero_d) |
1273
                                                              op3_hi[2] & op3_lo[8] &
1274
                                      (rs1_0f & (~rd_00 |
1275
                                                 dtu_inst_d[12] |
1276
                                                 dtu_inst_d[7] |
1277
                                                 inst11_8_nonzero_d)) | // mem#
1278
                                                              op3_hi[3] & op3_lo[1] &
1279
                                      (~fcn0 | ~rs1_00 | rs2_nonzero_d |
1280
                                       inst12_5_nonzero_d |
1281
                                       dtu_inst_d[13]) | // savd, restd
1282
                                                              op3_hi[3] & op3_lo[10] &
1283
                                      (inst11_8_nonzero_d |
1284
                                       dtu_inst_d[7] &
1285
                                       ~(fcl_dtu_privmode_d |
1286
                                         fcl_dtu_hprivmode_d) |
1287
                                       dtu_inst_d[29] |
1288
                                       ~dtu_inst_d[13] & (dtu_inst_d[6] |
1289
                                                          dtu_inst_d[5])) |// tcc
1290
                                      op3_hi[3] & op3_lo[3] &   // wrhpr
1291
                                      (~valid_hp_rd_d | rd_01 & fcl_dtu_tlzero_d) |
1292
                                                              op3_hi[3] & op3_lo[2] &   // wrpr
1293
                                                              (rd[4] & ~rd_10 | rd_0f | // gl=0x10
1294
                                                               ~rd[4] & ~rd[3] & ~rd[2] & fcl_dtu_tlzero_d) |
1295
                                                              op3_hi[3] & op3_lo[0] &
1296
                                                              (rd_0f & ~(rs1_00 & dtu_inst_d[13]))  // sir
1297
                                      ) |
1298
                                          mem_inst & (~op3[5] & op3_lo[12] |
1299
                                                            op3[5] & (op3_lo[2] | op3_lo[6]) | // stqf, ldqf
1300
                                                            op3[5] & op3[3] & ~op3[2] |
1301
                                                            op3_hi[2] & (op3_lo[12] |
1302
                                                                                     op3_lo[14] | op3_lo[15]) |
1303
                                                            op3_hi[3] & (op3_lo[1] | op3_lo[5] |
1304
                                                                                     op3_lo[15]) |    //  null
1305
                                                            ~op3[5] & op3_lo[3] & rd[0] | // ldd w/ odd rd
1306
                                                            op3[5] & op3_lo[1] & ~fcn0 |  // ldfsr
1307
                                                            op3[5] & op3_lo[13] & // prefetch
1308
                                                              illegal_prefetch |
1309
                                                            op3[5] & op3_lo[5] & ~fcn0 | // stfsr
1310
                                                            ~op3[5] & op3_lo[7] & rd[0])  | // std w/ odd rd
1311
                                          inv_reg_access_d |
1312
                        rsvchk_fail_d);
1313
 
1314 113 albert.wat
   dff_s #(1) illinste_ff(.din (ill_inst_d),
1315 95 fafa1971
                                  .q   (ill_inst_e),
1316 113 albert.wat
                                  .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
1317 95 fafa1971
   assign dtu_fcl_illinst_e = (ill_inst_e |
1318
//                               imask_hit_e |
1319
                               hprivop_e);
1320
 
1321
 
1322
   //-------------
1323
   // LSU Controls
1324
   //-------------
1325
   // prefetch
1326
   assign prefetch    = op3_lo[13] & op3[5];
1327
 
1328
   assign impl_prefetch = ~rd[4] & ~rd[3] & ~rd[2] | // 0-3
1329
                           rd[4] & ~rd[3];           // 10-17 (hex)
1330
   assign noop_prefetch = rd_04 | rd[4] & rd[3];     // 4, 18-1f
1331
 
1332
   assign illegal_prefetch = ~rd[4] & rd[2] & (rd[1] | rd[0]) | // 5-7
1333
                             ~rd[4] & rd[3];                    // 8-f
1334
 
1335
   assign prefetch_d = mem_inst & prefetch & impl_prefetch &
1336
                       fcl_dtu_inst_vld_d;
1337
   assign pref_done_d = mem_inst & prefetch & noop_prefetch;
1338
 
1339
   assign dec_swl_ll_done_d = (pref_done_d | rdsr_done_d | rdpr_done_d |
1340
                               save_retn_done_d);
1341
 
1342
   // alt space
1343
   assign lstype_d[2] = mem_inst & op3[4] & fcl_dtu_inst_vld_d;
1344
   // store
1345
   assign lstype_d[1] = mem_inst & op3[2] & ~prefetch & fcl_dtu_inst_vld_d &
1346
                        ~quad_ffuop_d;
1347
   // load
1348
   assign lstype_d[0] = mem_inst & ~prefetch & fcl_dtu_inst_vld_d &
1349
                              (~op3[2] | op3[3]) & (~op3_lo[14] | op3[5]) &
1350
                        ~quad_ffuop_d;
1351
 
1352
 
1353
   // only the stda instruction needs to be flagged
1354
   assign dec_swl_std_inst_d = mem_inst & op3_hi[1] & op3_lo[7] &
1355
                                     fcl_dtu_inst_vld_d;
1356
 
1357
   assign sext_d = op3[3] & ~op3[2]; // load sign extension
1358
   assign ldstub_d = mem_inst & ~op3[5] & op3_lo[13] & fcl_dtu_inst_vld_d;
1359
   assign casa_d = mem_inst & op3[5] & (op3_lo[12] | op3_lo[14]) &
1360
                                         fcl_dtu_inst_vld_d;
1361
   assign swap_d = mem_inst & op3_lo[15] & fcl_dtu_inst_vld_d;
1362
 
1363
   // load inst for speculation
1364
   // fp loads are not speculated on
1365
   // ldd is not speculated on
1366
   assign dec_swl_ld_inst_d = mem_inst & ~op3[2] &
1367
                                    ~op3[5] & ~op3_lo[3];
1368
 
1369
   // store, atomic or flush inst for stb flow control
1370
   // TBD: no need to full decode this if timing is a problem
1371
   assign dec_swl_st_inst_d = mem_inst & op3[2] |   // st, pref, cas, ldstb
1372
                              arith_inst & op3_hi[3] & op3_lo[11];  // flsh
1373
 
1374
   // size(out) 00-b 01-h 10-w 11-x/q/d
1375
   assign lssize_d[0] =  (op3[1] & ~op3_lo[15]) |   // stx,ld/sth,ld/stq, 
1376
                                                    // ldx, ldd, std, ~swap
1377
                                             op3[5] & (op3_lo[1] | op3_lo[5]) & rd[0]; // ldxfsr
1378
 
1379
 
1380
   assign lssize_d[1] =  ~(op3[1]^op3[0])      |  // ~ld/st b,h
1381
                          (op3[5] & op3_lo[2]) |  // ld/stq 
1382
                          op3_lo[14]           |  // stx, casx
1383
                                op3_hi[2] & (op3_lo[1] | op3_lo[5]);  // ldst fsr
1384
 
1385
   assign ifu_ffu_ldst_size_d = ~(op3[1] & op3[0]); // ldf, stf
1386
//   assign ifu_ffu_ldst_size_d[1] = op3[1] & op3[0];    // lddf, stdf
1387
 
1388
 
1389
   assign ldst_fp_d   =  op3[5] & ~op3[3] & fcl_dtu_inst_vld_d &
1390
                         ~swl_dec_fpbusy_e;
1391
 
1392
   assign ldst_dbl_d  =  (~op3[3] & op3[1] & op3[0] | // ldd(f), std(f)
1393
                                op3[5] & (op3_lo[2] | op3_lo[6])) &   // ldq, stq
1394
                                             fcl_dtu_inst_vld_d;
1395
 
1396
   // mem bar
1397
   assign mb_mask_d = dtu_inst_d[1] |   // #storeload
1398
                            dtu_inst_d[5] |   // #memissue
1399
                          dtu_inst_d[6];    // #sync
1400
 
1401
   assign mb_inst_d = arith_inst & op3_hi[2] & op3_lo[8] &
1402
                            rs1_0f & rd_00 & fcl_dtu_inst_vld_d &
1403
                            dtu_inst_d[13] & mb_mask_d;
1404
 
1405
 
1406 113 albert.wat
   dff_s #(3) lstype_reg(.din (lstype_d),
1407 95 fafa1971
                                 .clk (clk),
1408
                                 .q   (lstype_e),
1409 113 albert.wat
                                 .se  (se), `SIMPLY_RISC_SCANIN, .so());
1410
   dff_s #(2) lssize_reg(.din (lssize_d),
1411 95 fafa1971
                                 .clk (clk),
1412
                                 .q   (ifu_lsu_ldst_size_e),
1413 113 albert.wat
                                 .se  (se), `SIMPLY_RISC_SCANIN, .so());
1414
   dff_s #(1) lsfp_reg(.din (ldst_fp_d),
1415 95 fafa1971
                               .clk (clk),
1416
                               .q   (ifu_lsu_ldst_fp_e),
1417 113 albert.wat
                               .se  (se), `SIMPLY_RISC_SCANIN, .so());
1418
   dff_s #(1) lsdbl_reg(.din (ldst_dbl_d),
1419 95 fafa1971
                                .clk (clk),
1420
                                .q   (ifu_lsu_ldst_dbl_e),
1421 113 albert.wat
                                .se  (se), `SIMPLY_RISC_SCANIN, .so());
1422 95 fafa1971
 
1423 113 albert.wat
   dff_s #(1) sext_reg(.din(sext_d),
1424 95 fafa1971
                     .clk(clk),
1425
                     .q(ifu_lsu_sign_ext_e),
1426 113 albert.wat
                     .se(se), `SIMPLY_RISC_SCANIN, .so());
1427
   dff_s #(1) casa_reg(.din(casa_d),
1428 95 fafa1971
                     .clk(clk),
1429
                     .q(casa_e),
1430 113 albert.wat
                     .se(se), `SIMPLY_RISC_SCANIN, .so());
1431
   dff_s #(1) ldstub_reg(.din(ldstub_d),
1432 95 fafa1971
                       .clk(clk),
1433
                       .q(ifu_lsu_ldstub_e),
1434 113 albert.wat
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
1435
   dff_s #(1) swap_reg(.din(swap_d),
1436 95 fafa1971
                     .clk(clk),
1437
                     .q(ifu_lsu_swap_e),
1438 113 albert.wat
                     .se(se), `SIMPLY_RISC_SCANIN, .so());
1439 95 fafa1971
 
1440 113 albert.wat
   dff_s #(1) pfe_ff(.din (prefetch_d),
1441 95 fafa1971
                   .q   (prefetch_e),
1442 113 albert.wat
                   .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
1443 95 fafa1971
 
1444 113 albert.wat
   dff_s #(1) mb_ff(.din (mb_inst_d),
1445 95 fafa1971
                            .q   (mb_inst_e),
1446
                            .clk (clk),
1447 113 albert.wat
                .se(se), `SIMPLY_RISC_SCANIN, .so());
1448 95 fafa1971
 
1449
   assign ifu_lsu_casa_e = casa_e;
1450
   assign ifu_exu_casa_d = casa_d;
1451
 
1452
//   assign ifu_lsu_ld_inst_e = lstype_e[0] & (~dtu_inst_anull_e) & 
1453
//                                                ~ifu_ffu_quad_op_e & fcl_dtu_inst_vld_e;
1454
//   assign ifu_lsu_st_inst_e = lstype_e[1] & (~dtu_inst_anull_e) & 
1455
//                                                ~ifu_ffu_quad_op_e & fcl_dtu_inst_vld_e;
1456
 
1457
   assign ifu_lsu_ld_inst_e = lstype_e[0];
1458
   assign ifu_lsu_st_inst_e = lstype_e[1];
1459
 
1460
   // temporary
1461
//   assign ifu_lsu_alt_space_e = lstype_e[2] & ~dtu_inst_anull_e & 
1462
//                                    fcl_dtu_inst_vld_e;
1463
 
1464
   assign ifu_lsu_alt_space_e = lstype_e[2];
1465
   assign ifu_lsu_alt_space_d = mem_inst & op3[4] & fcl_dtu_inst_vld_d;
1466
   assign ifu_tlu_alt_space_d = op3[4] & fcl_dtu_ely_inst_vld_d;
1467
//   assign ifu_lsu_imm_asi_vld_d = op3[4] & ~dtu_inst_d[13];
1468
   assign ifu_lsu_memref_d = mem_inst & fcl_dtu_ely_inst_vld_d;
1469
 
1470
   assign ifu_tlu_mb_inst_e = mb_inst_e & ~dtu_inst_anull_e &
1471
                                    fcl_dtu_inst_vld_e;
1472
 
1473
   assign ifu_lsu_pref_inst_e = fcl_dtu_inst_vld_e & prefetch_e &
1474
                                ~dtu_inst_anull_e;
1475
 
1476
   //------------
1477
   // IMASK
1478
   //------------
1479
   assign rs2_hit = (dtu_inst_d[4:0] == erb_dtu_imask[4:0]);
1480
   assign opf_hit = (dtu_inst_d[12:5] == erb_dtu_imask[12:5]);
1481
   assign ibit_hit = (dtu_inst_d[13] == erb_dtu_imask[13]);
1482
   assign rs1_hit = (dtu_inst_d[18:14] == erb_dtu_imask[18:14]);
1483
   assign op3_hit = (dtu_inst_d[24:19] == erb_dtu_imask[24:19]);
1484
   assign rd_hit = (dtu_inst_d[29:25] == erb_dtu_imask[29:25]);
1485
   assign op_hit = (dtu_inst_d[31:30] == erb_dtu_imask[31:30]);
1486
 
1487
   assign imask_hit = (rs2_hit  | ~erb_dtu_imask[32]) &
1488
                      (opf_hit  | ~erb_dtu_imask[33]) &
1489
                      (ibit_hit | ~erb_dtu_imask[34]) &
1490
                      (rs1_hit  | ~erb_dtu_imask[35]) &
1491
                      (op3_hit  | ~erb_dtu_imask[36]) &
1492
                      (rd_hit   | ~erb_dtu_imask[37]) &
1493
                      (op_hit   | ~erb_dtu_imask[38]) &
1494
                      (|erb_dtu_imask[38:32]) &
1495
                      fcl_dtu_inst_vld_d;
1496
 
1497 113 albert.wat
   dff_s #(1) imsk_ff(.din (imask_hit),
1498 95 fafa1971
                              .q   (imask_hit_e),
1499 113 albert.wat
                              .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so());
1500 95 fafa1971
   assign dtu_fcl_imask_hit_e = imask_hit_e & swl_dec_ibe_e;
1501
 
1502
 
1503
   //-------------
1504
   // SPU Controls
1505
   //-------------
1506
 
1507
//   assign scpy_inst_d = arith_inst & op3_hi[3] & op3_lo[7] & // use impdep 2
1508
//                      ~dtu_inst_d[13] & dtu_inst_d[12];    // i=0 always
1509
//   assign scmp_inst_d = arith_inst & op3_hi[3] & op3_lo[7] & 
1510
//                      ~dtu_inst_d[13] & ~dtu_inst_d[12];
1511
//
1512
//   dff #(1) scpy_ff (.din (scpy_inst_d),
1513
//                 .clk (clk),
1514
//                 .q   (scpy_inst_e),
1515 113 albert.wat
//                 .se  (se), `SIMPLY_RISC_SCANIN, .so());
1516 95 fafa1971
//
1517
//   assign ifu_spu_scpy_inst_e = scpy_inst_e & ~dtu_inst_anull_e & 
1518
//                              fcl_dtu_inst_vld_e;
1519
//   
1520
//   dff #(1) scmp_ff (.din (scmp_inst_d),
1521
//                 .q   (scmp_inst_e),
1522 113 albert.wat
//                 .clk (clk), .se  (se), `SIMPLY_RISC_SCANIN, .so());
1523 95 fafa1971
//
1524
//   assign ifu_spu_scmp_inst_e = scmp_inst_e & ~dtu_inst_anull_e & 
1525
//                              fcl_dtu_inst_vld_e;
1526
//
1527
//
1528
 
1529
endmodule // sparc_ifu_dec
1530
 
1531
// Local Variables:
1532
// verilog-library-directories:("../rtl" ".")
1533
// End:

powered by: WebSVN 2.1.0

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