source: XOpenSparcT1/trunk/T1-CPU/ifu/sparc_ifu_dec.v @ 6

Revision 6, 61.8 KB checked in by pntsvt00, 13 years ago (diff)

versione iniziale opensparc

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