Project Full coverage report
Current view: Cores-VeeR-EL2—Cores-VeeR-EL2—design—exu—el2_exu.sv Coverage Hit Total
Test Date: 27-12-2024 Toggle 98.0% 97 99
Test: all Branch 100.0% 3 3

            Line data    Source code
       1              : // SPDX-License-Identifier: Apache-2.0
       2              : // Copyright 2020 Western Digital Corporation or its affiliates.
       3              : //
       4              : // Licensed under the Apache License, Version 2.0 (the "License");
       5              : // you may not use this file except in compliance with the License.
       6              : // You may obtain a copy of the License at
       7              : //
       8              : // http://www.apache.org/licenses/LICENSE-2.0
       9              : //
      10              : // Unless required by applicable law or agreed to in writing, software
      11              : // distributed under the License is distributed on an "AS IS" BASIS,
      12              : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13              : // See the License for the specific language governing permissions and
      14              : // limitations under the License.
      15              : 
      16              : 
      17              : module el2_exu
      18              : import el2_pkg::*;
      19              : #(
      20              : `include "el2_param.vh"
      21              : )
      22              :   (
      23    115884880 :    input logic          clk,                                           // Top level clock
      24          299 :    input logic          rst_l,                                         // Reset
      25              :    // Excluding scan_mode from coverage as its usage is determined by the integrator of the VeeR core.
      26              :    /*pragma coverage off*/
      27              :    input logic          scan_mode,                                     // Scan control
      28              :    /*pragma coverage on*/
      29              : 
      30      9565153 :    input logic  [1:0]   dec_data_en,                                   // Clock enable {x,r}, one cycle pulse
      31      9374887 :    input logic  [1:0]   dec_ctl_en,                                    // Clock enable {x,r}, two cycle pulse
      32         1410 :    input logic  [31:0]  dbg_cmd_wrdata,                                // Debug data   to primary I0 RS1
      33      5718160 :    input el2_alu_pkt_t i0_ap,                                         // DEC alu {valid,predecodes}
      34              : 
      35          528 :    input logic          dec_debug_wdata_rs1_d,                         // Debug select to primary I0 RS1
      36              : 
      37      8786816 :    input el2_predict_pkt_t dec_i0_predict_p_d,                        // DEC branch predict packet
      38      1014661 :    input logic [pt.BHT_GHR_SIZE-1:0] i0_predict_fghr_d,                // DEC predict fghr
      39      8034921 :    input logic [pt.BTB_ADDR_HI:pt.BTB_ADDR_LO] i0_predict_index_d,     // DEC predict index
      40       843062 :    input logic [pt.BTB_BTAG_SIZE-1:0] i0_predict_btag_d,               // DEC predict branch tag
      41              : 
      42       488956 :    input logic  [31:0]  lsu_result_m,                                  // Load result M-stage
      43       332494 :    input logic  [31:0]  lsu_nonblock_load_data,                        // nonblock load data
      44      7445282 :    input logic          dec_i0_rs1_en_d,                               // Qualify GPR RS1 data
      45      3554202 :    input logic          dec_i0_rs2_en_d,                               // Qualify GPR RS2 data
      46      6087803 :    input logic  [31:0]  gpr_i0_rs1_d,                                  // DEC data gpr
      47      3216738 :    input logic  [31:0]  gpr_i0_rs2_d,                                  // DEC data gpr
      48      3732371 :    input logic  [31:0]  dec_i0_immed_d,                                // DEC data immediate
      49      2720050 :    input logic  [31:0]  dec_i0_result_r,                               // DEC result in R-stage
      50      6508413 :    input logic  [12:1]  dec_i0_br_immed_d,                             // Branch immediate
      51      6764944 :    input logic          dec_i0_alu_decode_d,                           // Valid to X-stage ALU
      52      5157654 :    input logic          dec_i0_branch_d,                               // Branch in D-stage
      53       453434 :    input logic          dec_i0_select_pc_d,                            // PC select to RS1
      54      9567809 :    input logic  [31:1]  dec_i0_pc_d,                                   // Instruction PC
      55      1959272 :    input logic  [3:0]   dec_i0_rs1_bypass_en_d,                        // DEC bypass select  1 - X-stage, 0 - dec bypass data
      56       204828 :    input logic  [3:0]   dec_i0_rs2_bypass_en_d,                        // DEC bypass select  1 - X-stage, 0 - dec bypass data
      57        98292 :    input logic          dec_csr_ren_d,                                 // CSR read select
      58     26490189 :    input logic  [31:0]  dec_csr_rddata_d,                              // CSR read data
      59              : 
      60      6722830 :    input logic          dec_qual_lsu_d,                                // LSU instruction at D.  Use to quiet LSU operands
      61       209544 :    input el2_mul_pkt_t mul_p,                                         // DEC {valid, operand signs, low, operand bypass}
      62       951300 :    input el2_div_pkt_t div_p,                                         // DEC {valid, unsigned, rem}
      63         2466 :    input logic          dec_div_cancel,                                // Cancel the divide operation
      64              : 
      65      5905542 :    input logic  [31:1]  pred_correct_npc_x,                            // DEC NPC for correctly predicted branch
      66              : 
      67      1277508 :    input logic          dec_tlu_flush_lower_r,                         // Flush divide and secondary ALUs
      68       277796 :    input logic  [31:1]  dec_tlu_flush_path_r,                          // Redirect target
      69              : 
      70              : 
      71            0 :    input logic         dec_extint_stall,                               // External stall mux select
      72            1 :    input logic [31:2]  dec_tlu_meihap,                                 // External stall mux data
      73              : 
      74              : 
      75      2793306 :    output logic [31:0]  exu_lsu_rs1_d,                                 // LSU operand
      76       521112 :    output logic [31:0]  exu_lsu_rs2_d,                                 // LSU operand
      77              : 
      78      3019974 :    output logic         exu_flush_final,                               // Pipe is being flushed this cycle
      79      1520068 :    output logic [31:1]  exu_flush_path_final,                          // Target for the oldest flush source
      80              : 
      81      3413026 :    output logic [31:0]  exu_i0_result_x,                               // Primary ALU result to DEC
      82      6907455 :    output logic [31:1]  exu_i0_pc_x,                                   // Primary PC  result to DEC
      83        12560 :    output logic [31:0]  exu_csr_rs1_x,                                 // RS1 source for a CSR instruction
      84              : 
      85      7119563 :    output logic [31:1]  exu_npc_r,                                     // Divide NPC
      86      3533005 :    output logic [1:0]   exu_i0_br_hist_r,                              // to DEC  I0 branch history
      87        22483 :    output logic         exu_i0_br_error_r,                             // to DEC  I0 branch error
      88         6778 :    output logic         exu_i0_br_start_error_r,                       // to DEC  I0 branch start error
      89       658661 :    output logic [pt.BTB_ADDR_HI:pt.BTB_ADDR_LO] exu_i0_br_index_r,     // to DEC  I0 branch index
      90      3656597 :    output logic         exu_i0_br_valid_r,                             // to DEC  I0 branch valid
      91      1062423 :    output logic         exu_i0_br_mp_r,                                // to DEC  I0 branch mispredict
      92      3172993 :    output logic         exu_i0_br_middle_r,                            // to DEC  I0 branch middle
      93       446728 :    output logic [pt.BHT_GHR_SIZE-1:0]  exu_i0_br_fghr_r,               // to DEC  I0 branch fghr
      94      2544533 :    output logic         exu_i0_br_way_r,                               // to DEC  I0 branch way
      95              : 
      96      1726742 :    output el2_predict_pkt_t exu_mp_pkt,                               // Mispredict branch packet
      97      1604394 :    output logic [pt.BHT_GHR_SIZE-1:0]  exu_mp_eghr,                    // Mispredict global history
      98       442089 :    output logic [pt.BHT_GHR_SIZE-1:0]  exu_mp_fghr,                    // Mispredict fghr
      99      1080606 :    output logic [pt.BTB_ADDR_HI:pt.BTB_ADDR_LO]  exu_mp_index,         // Mispredict index
     100       368988 :    output logic [pt.BTB_BTAG_SIZE-1:0]  exu_mp_btag,                   // Mispredict btag
     101              : 
     102              : 
     103      1062423 :    output logic         exu_pmu_i0_br_misp,                            // to PMU - I0 E4 branch mispredict
     104      3508329 :    output logic         exu_pmu_i0_br_ataken,                          // to PMU - I0 E4 taken
     105      3567147 :    output logic         exu_pmu_i0_pc4,                                // to PMU - I0 E4 PC
     106              : 
     107              : 
     108        42072 :    output logic [31:0]  exu_div_result,                                // Divide result
     109       124898 :    output logic         exu_div_wren                                   // Divide write enable to GPR
     110              :   );
     111              : 
     112              : 
     113              : 
     114              : 
     115      1123675 :    logic [31:0]                i0_rs1_bypass_data_d;
     116       184564 :    logic [31:0]                i0_rs2_bypass_data_d;
     117       642784 :    logic                       i0_rs1_bypass_en_d;
     118       343166 :    logic                       i0_rs2_bypass_en_d;
     119      7236033 :    logic [31:0]                i0_rs1_d,  i0_rs2_d;
     120      5932347 :    logic [31:0]                muldiv_rs1_d;
     121      5905536 :    logic [31:1]                pred_correct_npc_r;
     122      2958972 :    logic                       i0_pred_correct_upper_r;
     123      6655607 :    logic [31:1]                i0_flush_path_upper_r;
     124     11352897 :    logic                       x_data_en, x_data_en_q1, x_data_en_q2, r_data_en, r_data_en_q2;
     125      9374887 :    logic                       x_ctl_en,  r_ctl_en;
     126              : 
     127       442834 :    logic [pt.BHT_GHR_SIZE-1:0] ghr_d_ns, ghr_d;
     128       442776 :    logic [pt.BHT_GHR_SIZE-1:0] ghr_x_ns, ghr_x;
     129      4186330 :    logic                       i0_taken_d;
     130      4186321 :    logic                       i0_taken_x;
     131      4384462 :    logic                       i0_valid_d;
     132      4384453 :    logic                       i0_valid_x;
     133       442089 :    logic [pt.BHT_GHR_SIZE-1:0] after_flush_eghr;
     134              : 
     135      1726742 :    el2_predict_pkt_t          final_predict_mp;
     136      9871579 :    el2_predict_pkt_t          i0_predict_newp_d;
     137              : 
     138            0 :    logic                       flush_in_d;
     139      3349285 :    logic [31:0]                alu_result_x;
     140              : 
     141       209544 :    logic                       mul_valid_x;
     142        48078 :    logic [31:0]                mul_result_x;
     143              : 
     144      5773253 :    el2_predict_pkt_t          i0_pp_r;
     145              : 
     146      1742500 :    logic                       i0_flush_upper_d;
     147      9713066 :    logic [31:1]                i0_flush_path_d;
     148      9850994 :    el2_predict_pkt_t          i0_predict_p_d;
     149      2958975 :    logic                       i0_pred_correct_upper_d;
     150              : 
     151      1742500 :    logic                       i0_flush_upper_x;
     152      6655612 :    logic [31:1]                i0_flush_path_x;
     153      5773261 :    el2_predict_pkt_t          i0_predict_p_x;
     154      2958973 :    logic                       i0_pred_correct_upper_x;
     155      5157644 :    logic                       i0_branch_x;
     156              : 
     157              :    localparam PREDPIPESIZE = pt.BTB_ADDR_HI-pt.BTB_ADDR_LO+1+pt.BHT_GHR_SIZE+pt.BTB_BTAG_SIZE;
     158      8533497 :    logic [PREDPIPESIZE-1:0]    predpipe_d, predpipe_x, predpipe_r, final_predpipe_mp;
     159              : 
     160              : 
     161              : 
     162              : 
     163              :    rvdffpcie #(31)                       i_flush_path_x_ff    (.*, .clk(clk),        .en ( x_data_en     ),  .din ( i0_flush_path_d[31:1]         ),  .dout( i0_flush_path_x[31:1]      ) );
     164              :    rvdffe #(32)                          i_csr_rs1_x_ff       (.*, .clk(clk),        .en ( x_data_en_q1  ),  .din ( i0_rs1_d[31:0]                ),  .dout( exu_csr_rs1_x[31:0]        ) );
     165              :    rvdffppe #($bits(el2_predict_pkt_t)) i_predictpacket_x_ff (.*, .clk(clk),        .en ( x_data_en     ),  .din ( i0_predict_p_d                ),  .dout( i0_predict_p_x             ) );
     166              :    rvdffe #(PREDPIPESIZE)                i_predpipe_x_ff      (.*, .clk(clk),        .en ( x_data_en_q2  ),  .din ( predpipe_d                    ),  .dout( predpipe_x                 ) );
     167              :    rvdffe #(PREDPIPESIZE)                i_predpipe_r_ff      (.*, .clk(clk),        .en ( r_data_en_q2  ),  .din ( predpipe_x                    ),  .dout( predpipe_r                 ) );
     168              : 
     169              :    rvdffe #(4+pt.BHT_GHR_SIZE)          i_x_ff               (.*, .clk(clk),        .en ( x_ctl_en      ),  .din ({i0_valid_d,i0_taken_d,i0_flush_upper_d,i0_pred_correct_upper_d,ghr_x_ns[pt.BHT_GHR_SIZE-1:0]} ),
     170              :                                                                                                             .dout({i0_valid_x,i0_taken_x,i0_flush_upper_x,i0_pred_correct_upper_x,ghr_x[pt.BHT_GHR_SIZE-1:0]}    ) );
     171              : 
     172              :    rvdffppe #($bits(el2_predict_pkt_t)+1) i_r_ff0         (.*, .clk(clk),        .en ( r_ctl_en      ),  .din ({i0_pred_correct_upper_x, i0_predict_p_x}),
     173              :                                                                                                           .dout({i0_pred_correct_upper_r, i0_pp_r       }) );
     174              : 
     175              :    rvdffpcie #(31)                      i_flush_r_ff         (.*, .clk(clk),        .en ( r_data_en     ),  .din ( i0_flush_path_x[31:1]         ),  .dout( i0_flush_path_upper_r[31:1]) );
     176              :    rvdffpcie #(31)                      i_npc_r_ff           (.*, .clk(clk),        .en ( r_data_en     ),  .din ( pred_correct_npc_x[31:1]      ),  .dout( pred_correct_npc_r[31:1]   ) );
     177              : 
     178              :    rvdffie #(pt.BHT_GHR_SIZE+2,1)       i_misc_ff            (.*, .clk(clk),                                .din ({ghr_d_ns[pt.BHT_GHR_SIZE-1:0], mul_p.valid, dec_i0_branch_d}),
     179              :                                                                                                             .dout({ghr_d[pt.BHT_GHR_SIZE-1:0]   , mul_valid_x, i0_branch_x}) );
     180              : 
     181              : 
     182              : 
     183              : 
     184              : 
     185              :    assign predpipe_d[PREDPIPESIZE-1:0]
     186              :                                    = {i0_predict_fghr_d, i0_predict_index_d, i0_predict_btag_d};
     187              : 
     188              : 
     189              :    assign i0_rs1_bypass_en_d       = dec_i0_rs1_bypass_en_d[0] | dec_i0_rs1_bypass_en_d[1] | dec_i0_rs1_bypass_en_d[2] | dec_i0_rs1_bypass_en_d[3];
     190              :    assign i0_rs2_bypass_en_d       = dec_i0_rs2_bypass_en_d[0] | dec_i0_rs2_bypass_en_d[1] | dec_i0_rs2_bypass_en_d[2] | dec_i0_rs2_bypass_en_d[3];
     191              : 
     192              :    assign i0_rs1_bypass_data_d[31:0]=({32{dec_i0_rs1_bypass_en_d[0]}} & dec_i0_result_r[31:0]       ) |
     193              :                                      ({32{dec_i0_rs1_bypass_en_d[1]}} & lsu_result_m[31:0]          ) |
     194              :                                      ({32{dec_i0_rs1_bypass_en_d[2]}} & exu_i0_result_x[31:0]       ) |
     195              :                                      ({32{dec_i0_rs1_bypass_en_d[3]}} & lsu_nonblock_load_data[31:0]);
     196              : 
     197              :    assign i0_rs2_bypass_data_d[31:0]=({32{dec_i0_rs2_bypass_en_d[0]}} & dec_i0_result_r[31:0]       ) |
     198              :                                      ({32{dec_i0_rs2_bypass_en_d[1]}} & lsu_result_m[31:0]          ) |
     199              :                                      ({32{dec_i0_rs2_bypass_en_d[2]}} & exu_i0_result_x[31:0]       ) |
     200              :                                      ({32{dec_i0_rs2_bypass_en_d[3]}} & lsu_nonblock_load_data[31:0]);
     201              : 
     202              : 
     203              :    assign i0_rs1_d[31:0]           = ({32{ i0_rs1_bypass_en_d                                           }}             & i0_rs1_bypass_data_d[31:0]) |
     204              :                                      ({32{~i0_rs1_bypass_en_d &  dec_i0_select_pc_d                     }}             & {dec_i0_pc_d[31:1],1'b0}  ) |    // for jal's
     205              :                                      ({32{~i0_rs1_bypass_en_d &  dec_debug_wdata_rs1_d                  }}             & dbg_cmd_wrdata[31:0]      ) |
     206              :                                      ({32{~i0_rs1_bypass_en_d & ~dec_debug_wdata_rs1_d & dec_i0_rs1_en_d}}             & gpr_i0_rs1_d[31:0]        );
     207              : 
     208              :    assign i0_rs2_d[31:0]           = ({32{~i0_rs2_bypass_en_d & dec_i0_rs2_en_d}}                                      & gpr_i0_rs2_d[31:0]        ) |
     209              :                                      ({32{~i0_rs2_bypass_en_d                  }}                                      & dec_i0_immed_d[31:0]      ) |
     210              :                                      ({32{ i0_rs2_bypass_en_d                  }}                                      & i0_rs2_bypass_data_d[31:0]);
     211              : 
     212              : 
     213              :    assign exu_lsu_rs1_d[31:0]      = ({32{~i0_rs1_bypass_en_d & ~dec_extint_stall & dec_i0_rs1_en_d & dec_qual_lsu_d}} & gpr_i0_rs1_d[31:0]        ) |
     214              :                                      ({32{ i0_rs1_bypass_en_d & ~dec_extint_stall                   & dec_qual_lsu_d}} & i0_rs1_bypass_data_d[31:0]) |
     215              :                                      ({32{                       dec_extint_stall                   & dec_qual_lsu_d}} & {dec_tlu_meihap[31:2],2'b0});
     216              : 
     217              :    assign exu_lsu_rs2_d[31:0]      = ({32{~i0_rs2_bypass_en_d & ~dec_extint_stall & dec_i0_rs2_en_d & dec_qual_lsu_d}} & gpr_i0_rs2_d[31:0]        ) |
     218              :                                      ({32{ i0_rs2_bypass_en_d & ~dec_extint_stall                   & dec_qual_lsu_d}} & i0_rs2_bypass_data_d[31:0]);
     219              : 
     220              : 
     221              :    assign muldiv_rs1_d[31:0]       = ({32{~i0_rs1_bypass_en_d & dec_i0_rs1_en_d}}                                      & gpr_i0_rs1_d[31:0]        ) |
     222              :                                      ({32{ i0_rs1_bypass_en_d                  }}                                      & i0_rs1_bypass_data_d[31:0]);
     223              : 
     224              : 
     225              :    assign x_data_en                =  dec_data_en[1];
     226              :    assign x_data_en_q1             =  dec_data_en[1] & dec_csr_ren_d;
     227              :    assign x_data_en_q2             =  dec_data_en[1] & dec_i0_branch_d;
     228              :    assign r_data_en                =  dec_data_en[0];
     229              :    assign r_data_en_q2             =  dec_data_en[0] & i0_branch_x;
     230              :    assign x_ctl_en                 =  dec_ctl_en[1];
     231              :    assign r_ctl_en                 =  dec_ctl_en[0];
     232              : 
     233              : 
     234              : 
     235              : 
     236              :    el2_exu_alu_ctl #(.pt(pt)) i_alu  (.*,
     237              :                           .enable            ( x_data_en                   ),   // I
     238              :                           .pp_in             ( i0_predict_newp_d           ),   // I
     239              :                           .valid_in          ( dec_i0_alu_decode_d         ),   // I
     240              :                           .flush_upper_x     ( i0_flush_upper_x            ),   // I
     241              :                           .flush_lower_r     ( dec_tlu_flush_lower_r       ),   // I
     242              :                           .a_in              ( i0_rs1_d[31:0]              ),   // I
     243              :                           .b_in              ( i0_rs2_d[31:0]              ),   // I
     244              :                           .pc_in             ( dec_i0_pc_d[31:1]           ),   // I
     245              :                           .brimm_in          ( dec_i0_br_immed_d[12:1]     ),   // I
     246              :                           .ap                ( i0_ap                       ),   // I
     247              :                           .csr_ren_in        ( dec_csr_ren_d               ),   // I
     248              :                           .csr_rddata_in     ( dec_csr_rddata_d[31:0]      ),   // I
     249              :                           .result_ff         ( alu_result_x[31:0]          ),   // O
     250              :                           .flush_upper_out   ( i0_flush_upper_d            ),   // O
     251              :                           .flush_final_out   ( exu_flush_final             ),   // O
     252              :                           .flush_path_out    ( i0_flush_path_d[31:1]       ),   // O
     253              :                           .predict_p_out     ( i0_predict_p_d              ),   // O
     254              :                           .pred_correct_out  ( i0_pred_correct_upper_d     ),   // O
     255              :                           .pc_ff             ( exu_i0_pc_x[31:1]           ));  // O
     256              : 
     257              : 
     258              : 
     259              :    el2_exu_mul_ctl #(.pt(pt)) i_mul   (.*,
     260              :                           .mul_p             ( mul_p              & {$bits(el2_mul_pkt_t){mul_p.valid}} ),   // I
     261              :                           .rs1_in            ( muldiv_rs1_d[31:0] & {32{mul_p.valid}}                    ),   // I
     262              :                           .rs2_in            ( i0_rs2_d[31:0]     & {32{mul_p.valid}}                    ),   // I
     263              :                           .result_x          ( mul_result_x[31:0]                                        ));  // O
     264              : 
     265              : 
     266              : 
     267              :    el2_exu_div_ctl #(.pt(pt)) i_div   (.*,
     268              :                           .cancel            ( dec_div_cancel              ),   // I
     269              :                           .dp                ( div_p                       ),   // I
     270              :                           .dividend          ( muldiv_rs1_d[31:0]          ),   // I
     271              :                           .divisor           ( i0_rs2_d[31:0]              ),   // I
     272              :                           .finish_dly        ( exu_div_wren                ),   // O
     273              :                           .out               ( exu_div_result[31:0]        ));  // O
     274              : 
     275              : 
     276              : 
     277              :    assign exu_i0_result_x[31:0]    =  (mul_valid_x)  ?  mul_result_x[31:0]  :  alu_result_x[31:0];
     278              : 
     279              : 
     280              : 
     281              : 
     282          298 :    always_comb begin
     283          298 :       i0_predict_newp_d            =  dec_i0_predict_p_d;
     284          298 :       i0_predict_newp_d.boffset    =  dec_i0_pc_d[1];  // from the start of inst
     285              :    end
     286              : 
     287              : 
     288              :    assign exu_pmu_i0_br_misp       =  i0_pp_r.misp;
     289              :    assign exu_pmu_i0_br_ataken     =  i0_pp_r.ataken;
     290              :    assign exu_pmu_i0_pc4           =  i0_pp_r.pc4;
     291              : 
     292              : 
     293              :    assign i0_valid_d               =  i0_predict_p_d.valid  & dec_i0_alu_decode_d & ~dec_tlu_flush_lower_r;
     294              :    assign i0_taken_d               = (i0_predict_p_d.ataken & dec_i0_alu_decode_d);
     295              : 
     296              : if(pt.BTB_ENABLE==1) begin
     297              :    // maintain GHR at D
     298              :    assign ghr_d_ns[pt.BHT_GHR_SIZE-1:0]
     299              :                                    = ({pt.BHT_GHR_SIZE{~dec_tlu_flush_lower_r &  i0_valid_d}} & {ghr_d[pt.BHT_GHR_SIZE-2:0], i0_taken_d}) |
     300              :                                      ({pt.BHT_GHR_SIZE{~dec_tlu_flush_lower_r & ~i0_valid_d}} &  ghr_d[pt.BHT_GHR_SIZE-1:0]             ) |
     301              :                                      ({pt.BHT_GHR_SIZE{ dec_tlu_flush_lower_r              }} &  ghr_x[pt.BHT_GHR_SIZE-1:0]             );
     302              : 
     303              :    // maintain GHR at X
     304              :    assign ghr_x_ns[pt.BHT_GHR_SIZE-1:0]
     305              :                                    = ({pt.BHT_GHR_SIZE{ i0_valid_x}} & {ghr_x[pt.BHT_GHR_SIZE-2:0], i0_taken_x}) |
     306              :                                      ({pt.BHT_GHR_SIZE{~i0_valid_x}} &  ghr_x[pt.BHT_GHR_SIZE-1:0]             ) ;
     307              : 
     308              : 
     309              :    assign exu_i0_br_valid_r                                 =  i0_pp_r.valid;
     310              :    assign exu_i0_br_mp_r                                    =  i0_pp_r.misp;
     311              :    assign exu_i0_br_way_r                                   =  i0_pp_r.way;
     312              :    assign exu_i0_br_hist_r[1:0]                             =  {2{i0_pp_r.valid}} & i0_pp_r.hist[1:0];
     313              :    assign exu_i0_br_error_r                                 =  i0_pp_r.br_error;
     314              :    assign exu_i0_br_middle_r                                =  i0_pp_r.pc4 ^ i0_pp_r.boffset;
     315              :    assign exu_i0_br_start_error_r                           =  i0_pp_r.br_start_error;
     316              : 
     317              :    assign {exu_i0_br_fghr_r[pt.BHT_GHR_SIZE-1:0],
     318              :            exu_i0_br_index_r[pt.BTB_ADDR_HI:pt.BTB_ADDR_LO]}=  predpipe_r[PREDPIPESIZE-1:pt.BTB_BTAG_SIZE];
     319              : 
     320              : 
     321              :    assign final_predict_mp                                  = (i0_flush_upper_x)  ?  i0_predict_p_x  :  '0;
     322              : 
     323              :    assign final_predpipe_mp[PREDPIPESIZE-1:0]               = (i0_flush_upper_x)  ?  predpipe_x      :  '0;
     324              : 
     325              :    assign after_flush_eghr[pt.BHT_GHR_SIZE-1:0]             = (i0_flush_upper_x & ~dec_tlu_flush_lower_r)  ?  ghr_d[pt.BHT_GHR_SIZE-1:0]  :  ghr_x[pt.BHT_GHR_SIZE-1:0];
     326              : 
     327              : 
     328              :    assign exu_mp_pkt.valid                                  =  final_predict_mp.valid;
     329              :    assign exu_mp_pkt.way                                    =  final_predict_mp.way;
     330              :    assign exu_mp_pkt.misp                                   =  final_predict_mp.misp;
     331              :    assign exu_mp_pkt.pcall                                  =  final_predict_mp.pcall;
     332              :    assign exu_mp_pkt.pja                                    =  final_predict_mp.pja;
     333              :    assign exu_mp_pkt.pret                                   =  final_predict_mp.pret;
     334              :    assign exu_mp_pkt.ataken                                 =  final_predict_mp.ataken;
     335              :    assign exu_mp_pkt.boffset                                =  final_predict_mp.boffset;
     336              :    assign exu_mp_pkt.pc4                                    =  final_predict_mp.pc4;
     337              :    assign exu_mp_pkt.hist[1:0]                              =  final_predict_mp.hist[1:0];
     338              :    assign exu_mp_pkt.toffset[11:0]                          =  final_predict_mp.toffset[11:0];
     339              : 
     340              :    assign exu_mp_fghr[pt.BHT_GHR_SIZE-1:0]                  =  after_flush_eghr[pt.BHT_GHR_SIZE-1:0];
     341              : 
     342              :    assign {exu_mp_index[pt.BTB_ADDR_HI:pt.BTB_ADDR_LO],
     343              :            exu_mp_btag[pt.BTB_BTAG_SIZE-1:0]}               =  final_predpipe_mp[PREDPIPESIZE-pt.BHT_GHR_SIZE-1:0];
     344              : 
     345              :    assign exu_mp_eghr[pt.BHT_GHR_SIZE-1:0]                  =  final_predpipe_mp[PREDPIPESIZE-1:pt.BTB_ADDR_HI-pt.BTB_ADDR_LO+pt.BTB_BTAG_SIZE+1]; // mp ghr for bht write
     346              : end // if (pt.BTB_ENABLE==1)
     347              : else begin
     348              :    assign ghr_d_ns = '0;
     349              :    assign ghr_x_ns = '0;
     350              :    assign exu_mp_pkt = '0;
     351              :    assign exu_mp_eghr = '0;
     352              :    assign exu_mp_fghr = '0;
     353              :    assign exu_mp_index = '0;
     354              :    assign exu_mp_btag = '0;
     355              :    assign exu_i0_br_hist_r = '0;
     356              :    assign exu_i0_br_error_r = '0;
     357              :    assign exu_i0_br_start_error_r = '0;
     358              :    assign exu_i0_br_index_r = '0;
     359              :    assign exu_i0_br_valid_r = '0;
     360              :    assign exu_i0_br_mp_r = '0;
     361              :    assign exu_i0_br_middle_r = '0;
     362              :    assign exu_i0_br_fghr_r = '0;
     363              :    assign exu_i0_br_way_r = '0;
     364              : end // else: !if(pt.BTB_ENABLE==1)
     365              : 
     366              :    assign exu_flush_path_final[31:1] = ( {31{ dec_tlu_flush_lower_r                   }} & dec_tlu_flush_path_r[31:1] ) |
     367              :                                        ( {31{~dec_tlu_flush_lower_r & i0_flush_upper_d}} & i0_flush_path_d[31:1]      );
     368              : 
     369              :    assign exu_npc_r[31:1]            = (i0_pred_correct_upper_r)  ?  pred_correct_npc_r[31:1]    :  i0_flush_path_upper_r[31:1];
     370              : 
     371              : 
     372              : endmodule // el2_exu