data/full_repos/permissive/418753455/E906_RTL_FACTORY/gen_rtl/fmau/rtl/pa_fmau_frac_add.v
1: b"%Error: data/full_repos/permissive/418753455/E906_RTL_FACTORY/gen_rtl/fmau/rtl/pa_fmau_frac_add.v:289: Cannot find file containing module: 'pa_fmau_lza_single'\npa_fmau_lza_single  x_pa_fmau_lza_single (\n^~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/418753455/E906_RTL_FACTORY/gen_rtl/fmau/rtl,data/full_repos/permissive/418753455/pa_fmau_lza_single\n             data/full_repos/permissive/418753455/E906_RTL_FACTORY/gen_rtl/fmau/rtl,data/full_repos/permissive/418753455/pa_fmau_lza_single.v\n             data/full_repos/permissive/418753455/E906_RTL_FACTORY/gen_rtl/fmau/rtl,data/full_repos/permissive/418753455/pa_fmau_lza_single.sv\n             pa_fmau_lza_single\n             pa_fmau_lza_single.v\n             pa_fmau_lza_single.sv\n             obj_dir/pa_fmau_lza_single\n             obj_dir/pa_fmau_lza_single.v\n             obj_dir/pa_fmau_lza_single.sv\n%Error: Exiting due to 1 error(s)\n"
module pa_fmau_frac_add(
  ctrl_dp_ex2_inst_pipe_down,
  ctrl_dp_ex3_inst_pipe_down,
  ctrl_xx_ex2_warm_up,
  ctrl_xx_ex3_warm_up,
  ex2_adder_0_sel_h,
  ex2_mac,
  ex2_mac_expnt,
  ex2_mult_data,
  ex2_shift_data,
  ex2_sub_vld,
  ex3_inst_rm,
  ex3_mac_expnt,
  ex3_mult_expnt,
  ex3_mult_sign,
  ex3_sub_vld,
  ex4_inst_rm,
  fmau_ex3_data_clk,
  fmau_ex4_data_clk,
  fmau_fpu_ex3_fflags,
  fmau_fpu_ex3_result,
  fmau_fpu_ex4_fflags,
  fmau_fpu_ex4_result
);


input           ctrl_dp_ex2_inst_pipe_down;      
input           ctrl_dp_ex3_inst_pipe_down;      
input           ctrl_xx_ex2_warm_up;             
input           ctrl_xx_ex3_warm_up;             
input           ex2_adder_0_sel_h;               
input           ex2_mac;                         
input   [9 :0]  ex2_mac_expnt;                   
input   [47:0]  ex2_mult_data;                   
input   [52:0]  ex2_shift_data;                  
input           ex2_sub_vld;                     
input   [2 :0]  ex3_inst_rm;                     
input   [9 :0]  ex3_mac_expnt;                   
input   [9 :0]  ex3_mult_expnt;                  
input           ex3_mult_sign;                   
input           ex3_sub_vld;                     
input   [2 :0]  ex4_inst_rm;                     
input           fmau_ex3_data_clk;               
input           fmau_ex4_data_clk;               
output  [4 :0]  fmau_fpu_ex3_fflags;             
output  [31:0]  fmau_fpu_ex3_result;             
output  [4 :0]  fmau_fpu_ex4_fflags;             
output  [31:0]  fmau_fpu_ex4_result;             


reg     [52:0]  ex3_adder_0;                     
reg     [52:0]  ex3_adder_1;                     
reg     [52:0]  ex3_adder_result;                
reg     [22:0]  ex3_mult_frac_result;            
reg             ex3_mult_rnd_in;                 
reg     [1 :0]  ex3_mult_single_gs_bit;          
reg     [15:0]  ex3_shift_limit_low;             
reg     [9 :0]  ex4_mac_expnt;                   
reg             ex4_mac_expnt_neg_max;           
reg     [7 :0]  ex4_mac_expnt_result;            
reg             ex4_mac_frac_not_zero;           
reg     [52:0]  ex4_mac_frac_pre;                
reg     [22:0]  ex4_mac_frac_result;             
reg             ex4_mac_rnd_in;                  
reg             ex4_mac_shift_32_bit;            
reg             ex4_mac_sign;                    


wire            ctrl_dp_ex2_inst_pipe_down;      
wire            ctrl_dp_ex3_inst_pipe_down;      
wire            ctrl_xx_ex2_warm_up;             
wire            ctrl_xx_ex3_warm_up;             
wire    [52:0]  ex2_adder_0;                     
wire    [52:0]  ex2_adder_0_0;                   
wire    [52:0]  ex2_adder_0_1;                   
wire            ex2_adder_0_sel_h;               
wire    [52:0]  ex2_adder_1;                     
wire            ex2_adder_1_for_single_rnd_add_1; 
wire            ex2_adder_1_for_single_rnd_add_2; 
wire    [52:0]  ex2_adder_1_rnd_data;            
wire            ex2_mac;                         
wire    [9 :0]  ex2_mac_expnt;                   
wire    [47:0]  ex2_mult_data;                   
wire    [1 :0]  ex2_mult_single_gs_bit;          
wire    [52:0]  ex2_shift_data;                  
wire    [15:0]  ex2_shift_limit_low;             
wire            ex2_shift_limit_vld;             
wire            ex2_sub_vld;                     
wire    [52:0]  ex3_adder_0_result;              
wire    [52:0]  ex3_adder_1_result;              
wire    [2 :0]  ex3_adder_result_sel;            
wire    [2 :0]  ex3_inst_rm;                     
wire    [6 :0]  ex3_lza_result;                  
wire    [9 :0]  ex3_mac_expnt;                   
wire    [9 :0]  ex3_mac_expnt_adjust;            
wire            ex3_mac_expnt_neg_max;           
wire            ex3_mac_frac_not_zero;           
wire    [52:0]  ex3_mac_result_shift;            
wire            ex3_mac_sign;                    
wire    [9 :0]  ex3_mult_expnt;                  
wire            ex3_mult_expnt_add_in;           
wire    [9 :0]  ex3_mult_expnt_plus_1;           
wire    [7 :0]  ex3_mult_expnt_result;           
wire    [1 :0]  ex3_mult_frac_sel;               
wire    [22:0]  ex3_mult_no_rnd_result;          
wire            ex3_mult_nx;                     
wire    [24:0]  ex3_mult_result;                 
wire    [2 :0]  ex3_mult_rnd_bit;                
wire    [24:0]  ex3_mult_rnd_result;             
wire            ex3_mult_sign;                   
wire    [31:0]  ex3_mult_single_result;          
wire    [52:0]  ex3_shift_limit;                 
wire    [63:0]  ex3_shift_limit_one_hot;         
wire            ex3_sub_vld;                     
wire            ex4_early_of;                    
wire            ex4_expnt_rnd_in;                
wire    [31:0]  ex4_fmau_single_result;          
wire    [2 :0]  ex4_inst_rm;                     
wire            ex4_late_of;                     
wire    [24:0]  ex4_mac_data_for_rnd;            
wire    [23:0]  ex4_mac_data_no_rnd;             
wire            ex4_mac_expnt_plus_1;            
wire    [2 :0]  ex4_mac_expnt_sel;               
wire    [52:0]  ex4_mac_frac;                    
wire    [1 :0]  ex4_mac_frac_sel;                
wire            ex4_mac_nx;                      
wire            ex4_mac_of;                      
wire    [24:0]  ex4_mac_rnd_result;              
wire            ex4_mac_sign_result;             
wire            ex4_mac_uf;                      
wire            ex4_of_frac_bit;                 
wire            ex4_plus_1_of;                   
wire    [2 :0]  ex4_rnd_bit;                     
wire            fmau_ex3_data_clk;               
wire            fmau_ex4_data_clk;               
wire    [4 :0]  fmau_fpu_ex3_fflags;             
wire    [31:0]  fmau_fpu_ex3_result;             
wire    [4 :0]  fmau_fpu_ex4_fflags;             
wire    [31:0]  fmau_fpu_ex4_result;             




parameter DOUBLE_WIDTH= 64;
parameter DOUBLE_FRAC = 52;
parameter DOUBLE_EXPN = 11;
parameter ADD_D_WIDTH =111;

parameter FUNC_WIDTH  = 10;

parameter SINGLE_WIDTH= 32;
parameter SINGLE_FRAC = 23;
parameter SINGLE_EXPN =  8;
parameter ADD_S_WIDTH = 53;











































assign ex2_adder_0_0[ADD_S_WIDTH-1:0] = {2'b00,{SINGLE_FRAC{1'b0}}, 2'b00, ex2_mult_data[2*SINGLE_FRAC+1:SINGLE_FRAC],|ex2_mult_single_gs_bit[1:0]};
assign ex2_adder_0_1[ADD_S_WIDTH-1:0] = {2'b00, ex2_mult_data[2*SINGLE_FRAC+1:0],3'b0};

assign ex2_adder_0[ADD_S_WIDTH-1:0] =  ex2_adder_0_sel_h ? ex2_adder_0_0[ADD_S_WIDTH-1:0] : ex2_adder_0_1[ADD_S_WIDTH-1:0];

assign ex2_adder_1_for_single_rnd_add_1 = !ex2_mac && !ex2_mult_data[2*SINGLE_FRAC+1];
assign ex2_adder_1_for_single_rnd_add_2 = !ex2_mac &&  ex2_mult_data[2*SINGLE_FRAC+1];


assign ex2_adder_1_rnd_data[ADD_S_WIDTH-1:0] = {{51{1'b0}},ex2_adder_1_for_single_rnd_add_1,{1{1'b0}} }
                                             | {{50{1'b0}},ex2_adder_1_for_single_rnd_add_2,{2{1'b0}} };

assign ex2_adder_1[ADD_S_WIDTH-1:0] = ex2_sub_vld 
                                   ? ~ex2_shift_data[ADD_S_WIDTH-1:0]
                                   : (ex2_shift_data[ADD_S_WIDTH-1:0] |ex2_adder_1_rnd_data[ADD_S_WIDTH-1:0]);

assign ex2_mult_single_gs_bit[1:0] = {ex2_mult_data[22], |ex2_mult_data[21: 0]};

assign ex2_shift_limit_low[15:0] = 16'b1000_0000_0000_0000 >> ex2_mac_expnt[3:0];
assign ex2_shift_limit_vld       = (ex2_mac_expnt[9:6]==4'b0000);




always @(posedge fmau_ex3_data_clk)
begin
 if(ctrl_dp_ex2_inst_pipe_down || ctrl_xx_ex2_warm_up) 
 begin
    ex3_mult_single_gs_bit[1:0]    <= ex2_mult_single_gs_bit[1:0];
    ex3_adder_0[ADD_S_WIDTH-1:0]   <= ex2_adder_0[ADD_S_WIDTH-1:0];
    ex3_adder_1[ADD_S_WIDTH-1:0]   <= ex2_adder_1[ADD_S_WIDTH-1:0];
    ex3_shift_limit_low[15:0]      <= ex2_shift_limit_low[15:0] & {16{ex2_shift_limit_vld}};
  end
end

assign ex3_shift_limit_one_hot[63:0] = {ex3_shift_limit_low[15:0],{48{1'b0}} } >> {ex3_mac_expnt[5:4],4'b0};
assign ex3_shift_limit[52:0] = ex3_shift_limit_one_hot[63:11];



assign ex3_adder_0_result[ADD_S_WIDTH-1:0] = ex3_adder_0[ADD_S_WIDTH-1:0] + ex3_adder_1[ADD_S_WIDTH-1:0];
assign ex3_adder_1_result[ADD_S_WIDTH-1:0] = ex3_adder_0[ADD_S_WIDTH-1:0] + ex3_adder_1[ADD_S_WIDTH-1:0] + 1'b1;

assign ex3_adder_result_sel[0] = !ex3_sub_vld;
assign ex3_adder_result_sel[1] =  ex3_sub_vld && ex3_adder_1_result[ADD_S_WIDTH-1];
assign ex3_adder_result_sel[2] =  ex3_sub_vld &&!ex3_adder_1_result[ADD_S_WIDTH-1];


always @( ex3_adder_0_result[52:0]
       or ex3_adder_1_result[52:0]
       or ex3_adder_result_sel[2:0])
begin
case(ex3_adder_result_sel[2:0])
  3'b001: ex3_adder_result[ADD_S_WIDTH-1:0] = ex3_adder_0_result[ADD_S_WIDTH-1:0];
  3'b010: ex3_adder_result[ADD_S_WIDTH-1:0] =~ex3_adder_0_result[ADD_S_WIDTH-1:0];
  3'b100: ex3_adder_result[ADD_S_WIDTH-1:0] = ex3_adder_1_result[ADD_S_WIDTH-1:0];
 default: ex3_adder_result[ADD_S_WIDTH-1:0] = {ADD_S_WIDTH{1'bx}};
endcase

end

assign ex3_mac_sign = ex3_mult_sign ^(ex3_sub_vld && ex3_adder_1_result[ADD_S_WIDTH-1]);
assign ex3_mac_frac_not_zero = |ex3_adder_result[ADD_S_WIDTH-1:0];












pa_fmau_lza_single  x_pa_fmau_lza_single (
  .addend          (ex3_adder_1    ),
  .lza_result      (ex3_lza_result ),
  .sub_vld         (ex3_sub_vld    ),
  .summand         (ex3_adder_0    ),
  .upper_limit     (ex3_shift_limit)
);










assign ex3_mac_result_shift[ADD_S_WIDTH-1:0] = ex3_adder_result[ADD_S_WIDTH-1:0]<<{ex3_lza_result[4:0]};
assign ex3_mac_expnt_adjust[SINGLE_EXPN+1:0] = ex3_mac_expnt[SINGLE_EXPN+1:0] -{ {4{1'b0}},ex3_lza_result[5:0]};

assign ex3_mac_expnt_neg_max                 =(ex3_mac_expnt[SINGLE_EXPN+1:0] == { {4{1'b0}},ex3_lza_result[5:0]});

always @(posedge fmau_ex4_data_clk)
begin
 if(ctrl_dp_ex3_inst_pipe_down || ctrl_xx_ex3_warm_up) 
 begin
    ex4_mac_expnt[SINGLE_EXPN+1:0]     <= ex3_mac_expnt_adjust[SINGLE_EXPN+1:0];
    ex4_mac_frac_pre[ADD_S_WIDTH-1:0]  <= ex3_mac_result_shift[ADD_S_WIDTH-1:0];
    ex4_mac_expnt_neg_max              <= ex3_mac_expnt_neg_max;
    ex4_mac_frac_not_zero              <= ex3_mac_frac_not_zero;
    ex4_mac_shift_32_bit               <= ex3_lza_result[5];
    ex4_mac_sign                       <= ex3_mac_sign;

  end
end



assign ex4_mac_frac[ADD_S_WIDTH-1:0] = ex4_mac_shift_32_bit ? {ex4_mac_frac_pre[ADD_S_WIDTH-33:0], {32{1'b0}} }
                                                            :  ex4_mac_frac_pre[ADD_S_WIDTH- 1:0];

assign ex4_early_of = (ex4_mac_expnt[9 : 8]==2'b01)||(ex4_mac_expnt[9 : 0]==10'b00_1111_1111);

assign ex4_plus_1_of=(ex4_mac_expnt[9:0] == 10'b00_1111_1110) && ex4_mac_expnt_plus_1;

assign ex4_of_frac_bit = (ex4_inst_rm[2:0]==3'b001)
                       ||(ex4_inst_rm[2:0]==3'b010) && !ex4_mac_sign
                       ||(ex4_inst_rm[2:0]==3'b011) &&  ex4_mac_sign;

assign ex4_mac_expnt_plus_1 = ex4_mac_frac[ADD_S_WIDTH-1] || ex4_mac_expnt_neg_max;

assign ex4_mac_data_no_rnd[SINGLE_FRAC:0] =(ex4_mac_frac[ADD_S_WIDTH-1] || ex4_mac_expnt_neg_max)
                                          ? ex4_mac_frac[ADD_S_WIDTH-1:ADD_S_WIDTH-SINGLE_FRAC-1]
                                          : ex4_mac_frac[ADD_S_WIDTH-2:ADD_S_WIDTH-SINGLE_FRAC-2];
                                            

assign ex4_mac_data_for_rnd[SINGLE_FRAC+1:0] = {1'b0, ex4_mac_data_no_rnd[SINGLE_FRAC:0]}; 

assign ex4_mac_rnd_result[SINGLE_FRAC+1:0] = ex4_mac_data_for_rnd[SINGLE_FRAC+1:0] +
                                           { {24{1'b0}},1'b1 };

assign ex4_rnd_bit[2:0] = (ex4_mac_frac[ADD_S_WIDTH-1] || ex4_mac_expnt_neg_max)
                        ? {ex4_mac_frac[29:28],|ex4_mac_frac[27:0]}
                        : {ex4_mac_frac[28:27],|ex4_mac_frac[26:0]};

always @( ex4_inst_rm[2:0]
       or ex4_mac_sign
       or ex4_rnd_bit[2:0])
begin
case(ex4_inst_rm[2:0])
  3'b000: ex4_mac_rnd_in = ex4_rnd_bit[1] && (ex4_rnd_bit[0] || ex4_rnd_bit[2]);
  3'b001: ex4_mac_rnd_in = 1'b0;
  3'b010: ex4_mac_rnd_in = ex4_mac_sign && |ex4_rnd_bit[1:0];
  3'b011: ex4_mac_rnd_in =!ex4_mac_sign && |ex4_rnd_bit[1:0];
  3'b100: ex4_mac_rnd_in = ex4_rnd_bit[1];
default : ex4_mac_rnd_in = 1'b0;
endcase

end

assign ex4_mac_frac_sel[0] = ex4_mac_rnd_result[SINGLE_FRAC+1] && ex4_mac_rnd_in && !ex4_early_of && !ex4_plus_1_of;
assign ex4_mac_frac_sel[1] =!ex4_mac_rnd_result[SINGLE_FRAC+1] && ex4_mac_rnd_in && !ex4_early_of && !ex4_plus_1_of;


always @( ex4_mac_rnd_result[23:0]
       or ex4_early_of
       or ex4_mac_data_no_rnd[22:0]
       or ex4_mac_frac_sel[1:0]
       or ex4_plus_1_of
       or ex4_of_frac_bit)
begin
case(ex4_mac_frac_sel[1:0])
  2'b01: ex4_mac_frac_result[SINGLE_FRAC-1:0] = ex4_mac_rnd_result[SINGLE_FRAC:1];
  2'b10: ex4_mac_frac_result[SINGLE_FRAC-1:0] = ex4_mac_rnd_result[SINGLE_FRAC-1:0];
default: ex4_mac_frac_result[SINGLE_FRAC-1:0] =(ex4_early_of || ex4_plus_1_of) ? {SINGLE_FRAC{ex4_of_frac_bit}} : ex4_mac_data_no_rnd[SINGLE_FRAC-1:0];
endcase

end

assign ex4_expnt_rnd_in = ex4_mac_rnd_in &&
                        &(ex4_mac_data_for_rnd[SINGLE_FRAC-1:0]);

assign ex4_mac_expnt_sel[2] = ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of 
                           && ex4_expnt_rnd_in && ex4_mac_expnt_plus_1 && !ex4_plus_1_of;

assign ex4_mac_expnt_sel[1] = ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of 
                           &&(ex4_expnt_rnd_in ^ ex4_mac_expnt_plus_1) && !ex4_plus_1_of
                           ||!ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of 
                           && ex4_expnt_rnd_in;

assign ex4_mac_expnt_sel[0] = ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of 
                           &&!ex4_expnt_rnd_in && !ex4_mac_expnt_plus_1
                           ||!ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of
                           &&!ex4_expnt_rnd_in;

always @( ex4_mac_expnt[7:0]
       or ex4_mac_expnt_sel[2:0]
       or ex4_early_of
       or ex4_plus_1_of
       or ex4_of_frac_bit)
begin
case(ex4_mac_expnt_sel[2:0])
  3'b100: ex4_mac_expnt_result[SINGLE_EXPN-1:0] = ex4_mac_expnt[SINGLE_EXPN-1:0] + 8'b0000_0010;
  3'b010: ex4_mac_expnt_result[SINGLE_EXPN-1:0] = ex4_mac_expnt[SINGLE_EXPN-1:0] + 8'b0000_0001;
  3'b001: ex4_mac_expnt_result[SINGLE_EXPN-1:0] = ex4_mac_expnt[SINGLE_EXPN-1:0];
 default: ex4_mac_expnt_result[SINGLE_EXPN-1:0] =(ex4_early_of || ex4_plus_1_of) ? {{7{1'b1}},!ex4_of_frac_bit}: 8'b0000_0000; 
endcase

end


assign ex4_mac_sign_result = ex4_mac_frac_not_zero ? ex4_mac_sign : (ex4_inst_rm[2:0]==3'b010);

assign ex4_late_of = (ex4_mac_expnt[7:0]==8'b1111_1101) && ex4_mac_expnt_sel[2]
                   ||(ex4_mac_expnt[7:0]==8'b1111_1110) && ex4_mac_expnt_sel[1];

assign ex4_mac_of = ex4_early_of || ex4_plus_1_of || ex4_late_of;

assign ex4_mac_uf = ex4_mac_expnt_neg_max && |ex4_rnd_bit[1:0]
                && !ex4_expnt_rnd_in && !ex4_mac_data_no_rnd[SINGLE_FRAC];

assign ex4_mac_nx = |ex4_rnd_bit[1:0];

assign fmau_fpu_ex4_fflags[4:0] = {1'b0, 1'b0,ex4_mac_of,ex4_mac_uf,ex4_mac_nx || ex4_mac_of};

assign ex4_fmau_single_result[31:0] = {ex4_mac_sign_result,ex4_mac_expnt_result[7:0],ex4_mac_frac_result[22:0]};

assign fmau_fpu_ex4_result[31:0] = ex4_fmau_single_result[31:0];




assign ex3_mult_result[SINGLE_FRAC+1:0] = ex3_adder_0[SINGLE_FRAC+2:1];

assign ex3_mult_rnd_result[SINGLE_FRAC+1:0] = ex3_adder_0_result[SINGLE_FRAC+2:1];

assign ex3_mult_rnd_bit[2:0] = ex3_mult_result[SINGLE_FRAC+1]
                             ?{ex3_mult_result[1:0],|ex3_mult_single_gs_bit[1:0]}
                             :{ex3_mult_result[0],   ex3_mult_single_gs_bit[1:0]};


always @( ex3_mult_sign
       or ex3_inst_rm[2:0]
       or ex3_mult_rnd_bit[2:0])
begin
case(ex3_inst_rm[2:0])
  3'b000: ex3_mult_rnd_in = ex3_mult_rnd_bit[1] && (ex3_mult_rnd_bit[0] || ex3_mult_rnd_bit[2]);
  3'b001: ex3_mult_rnd_in = 1'b0;
  3'b010: ex3_mult_rnd_in = ex3_mult_sign && |ex3_mult_rnd_bit[1:0];
  3'b011: ex3_mult_rnd_in =!ex3_mult_sign && |ex3_mult_rnd_bit[1:0];
  3'b100: ex3_mult_rnd_in = ex3_mult_rnd_bit[1];
default : ex3_mult_rnd_in = 1'b0;
endcase

end

assign ex3_mult_frac_sel[0] = ex3_mult_rnd_result[SINGLE_FRAC+1] && ex3_mult_rnd_in;
assign ex3_mult_frac_sel[1] =!ex3_mult_rnd_result[SINGLE_FRAC+1] && ex3_mult_rnd_in;

assign ex3_mult_no_rnd_result[SINGLE_FRAC-1:0] = ex3_mult_result[SINGLE_FRAC+1]
                                               ? ex3_mult_result[SINGLE_FRAC:1]
                                               : ex3_mult_result[SINGLE_FRAC-1:0];

always @( ex3_mult_no_rnd_result[22:0]
       or ex3_mult_frac_sel[1:0]
       or ex3_mult_rnd_result[23:0])
begin
case(ex3_mult_frac_sel[1:0])
  2'b01: ex3_mult_frac_result[SINGLE_FRAC-1:0] = ex3_mult_rnd_result[SINGLE_FRAC:1];
  2'b10: ex3_mult_frac_result[SINGLE_FRAC-1:0] = ex3_mult_rnd_result[SINGLE_FRAC-1:0];
default: ex3_mult_frac_result[SINGLE_FRAC-1:0] = ex3_mult_no_rnd_result[SINGLE_FRAC-1:0];
endcase

end

assign ex3_mult_expnt_add_in = ex3_mult_result[SINGLE_FRAC+1] 
                          ||  &ex3_mult_result[SINGLE_FRAC-1:0] && ex3_mult_rnd_in;

assign ex3_mult_expnt_plus_1[SINGLE_EXPN+1:0] = ex3_mult_expnt[SINGLE_EXPN+1:0] + 1'b1;

assign ex3_mult_expnt_result[SINGLE_EXPN-1:0] =  ex3_mult_expnt_add_in 
                                               ? ex3_mult_expnt_plus_1[SINGLE_EXPN-1:0]
                                               : ex3_mult_expnt[SINGLE_EXPN-1:0];

assign ex3_mult_single_result[SINGLE_WIDTH-1:0] = { ex3_mult_sign, 
                                                    ex3_mult_expnt_result[SINGLE_EXPN-1:0],
                                                    ex3_mult_frac_result[SINGLE_FRAC-1:SINGLE_FRAC-SINGLE_FRAC]};

assign ex3_mult_nx = |ex3_mult_rnd_bit[1:0];

assign fmau_fpu_ex3_result[SINGLE_WIDTH-1:0] = ex3_mult_single_result[SINGLE_WIDTH-1:0];

assign fmau_fpu_ex3_fflags[4:0] = {4'b0,ex3_mult_nx};


endmodule
module pa_fmau_frac_add(
  ctrl_dp_ex2_inst_pipe_down,
  ctrl_dp_ex3_inst_pipe_down,
  ctrl_xx_ex2_warm_up,
  ctrl_xx_ex3_warm_up,
  ex2_adder_0_sel_h,
  ex2_mac,
  ex2_mac_expnt,
  ex2_mult_data,
  ex2_shift_data,
  ex2_sub_vld,
  ex3_inst_rm,
  ex3_mac_expnt,
  ex3_mult_expnt,
  ex3_mult_sign,
  ex3_sub_vld,
  ex4_inst_rm,
  fmau_ex3_data_clk,
  fmau_ex4_data_clk,
  fmau_fpu_ex3_fflags,
  fmau_fpu_ex3_result,
  fmau_fpu_ex4_fflags,
  fmau_fpu_ex4_result
);



input           ctrl_dp_ex2_inst_pipe_down;      
input           ctrl_dp_ex3_inst_pipe_down;      
input           ctrl_xx_ex2_warm_up;             
input           ctrl_xx_ex3_warm_up;             
input           ex2_adder_0_sel_h;               
input           ex2_mac;                         
input   [9 :0]  ex2_mac_expnt;                   
input   [47:0]  ex2_mult_data;                   
input   [52:0]  ex2_shift_data;                  
input           ex2_sub_vld;                     
input   [2 :0]  ex3_inst_rm;                     
input   [9 :0]  ex3_mac_expnt;                   
input   [9 :0]  ex3_mult_expnt;                  
input           ex3_mult_sign;                   
input           ex3_sub_vld;                     
input   [2 :0]  ex4_inst_rm;                     
input           fmau_ex3_data_clk;               
input           fmau_ex4_data_clk;               
output  [4 :0]  fmau_fpu_ex3_fflags;             
output  [31:0]  fmau_fpu_ex3_result;             
output  [4 :0]  fmau_fpu_ex4_fflags;             
output  [31:0]  fmau_fpu_ex4_result;             


reg     [52:0]  ex3_adder_0;                     
reg     [52:0]  ex3_adder_1;                     
reg     [52:0]  ex3_adder_result;                
reg     [22:0]  ex3_mult_frac_result;            
reg             ex3_mult_rnd_in;                 
reg     [1 :0]  ex3_mult_single_gs_bit;          
reg     [15:0]  ex3_shift_limit_low;             
reg     [9 :0]  ex4_mac_expnt;                   
reg             ex4_mac_expnt_neg_max;           
reg     [7 :0]  ex4_mac_expnt_result;            
reg             ex4_mac_frac_not_zero;           
reg     [52:0]  ex4_mac_frac_pre;                
reg     [22:0]  ex4_mac_frac_result;             
reg             ex4_mac_rnd_in;                  
reg             ex4_mac_shift_32_bit;            
reg             ex4_mac_sign;                    


wire            ctrl_dp_ex2_inst_pipe_down;      
wire            ctrl_dp_ex3_inst_pipe_down;      
wire            ctrl_xx_ex2_warm_up;             
wire            ctrl_xx_ex3_warm_up;             
wire    [52:0]  ex2_adder_0;                     
wire    [52:0]  ex2_adder_0_0;                   
wire    [52:0]  ex2_adder_0_1;                   
wire            ex2_adder_0_sel_h;               
wire    [52:0]  ex2_adder_1;                     
wire            ex2_adder_1_for_single_rnd_add_1; 
wire            ex2_adder_1_for_single_rnd_add_2; 
wire    [52:0]  ex2_adder_1_rnd_data;            
wire            ex2_mac;                         
wire    [9 :0]  ex2_mac_expnt;                   
wire    [47:0]  ex2_mult_data;                   
wire    [1 :0]  ex2_mult_single_gs_bit;          
wire    [52:0]  ex2_shift_data;                  
wire    [15:0]  ex2_shift_limit_low;             
wire            ex2_shift_limit_vld;             
wire            ex2_sub_vld;                     
wire    [52:0]  ex3_adder_0_result;              
wire    [52:0]  ex3_adder_1_result;              
wire    [2 :0]  ex3_adder_result_sel;            
wire    [2 :0]  ex3_inst_rm;                     
wire    [6 :0]  ex3_lza_result;                  
wire    [9 :0]  ex3_mac_expnt;                   
wire    [9 :0]  ex3_mac_expnt_adjust;            
wire            ex3_mac_expnt_neg_max;           
wire            ex3_mac_frac_not_zero;           
wire    [52:0]  ex3_mac_result_shift;            
wire            ex3_mac_sign;                    
wire    [9 :0]  ex3_mult_expnt;                  
wire            ex3_mult_expnt_add_in;           
wire    [9 :0]  ex3_mult_expnt_plus_1;           
wire    [7 :0]  ex3_mult_expnt_result;           
wire    [1 :0]  ex3_mult_frac_sel;               
wire    [22:0]  ex3_mult_no_rnd_result;          
wire            ex3_mult_nx;                     
wire    [24:0]  ex3_mult_result;                 
wire    [2 :0]  ex3_mult_rnd_bit;                
wire    [24:0]  ex3_mult_rnd_result;             
wire            ex3_mult_sign;                   
wire    [31:0]  ex3_mult_single_result;          
wire    [52:0]  ex3_shift_limit;                 
wire    [63:0]  ex3_shift_limit_one_hot;         
wire            ex3_sub_vld;                     
wire            ex4_early_of;                    
wire            ex4_expnt_rnd_in;                
wire    [31:0]  ex4_fmau_single_result;          
wire    [2 :0]  ex4_inst_rm;                     
wire            ex4_late_of;                     
wire    [24:0]  ex4_mac_data_for_rnd;            
wire    [23:0]  ex4_mac_data_no_rnd;             
wire            ex4_mac_expnt_plus_1;            
wire    [2 :0]  ex4_mac_expnt_sel;               
wire    [52:0]  ex4_mac_frac;                    
wire    [1 :0]  ex4_mac_frac_sel;                
wire            ex4_mac_nx;                      
wire            ex4_mac_of;                      
wire    [24:0]  ex4_mac_rnd_result;              
wire            ex4_mac_sign_result;             
wire            ex4_mac_uf;                      
wire            ex4_of_frac_bit;                 
wire            ex4_plus_1_of;                   
wire    [2 :0]  ex4_rnd_bit;                     
wire            fmau_ex3_data_clk;               
wire            fmau_ex4_data_clk;               
wire    [4 :0]  fmau_fpu_ex3_fflags;             
wire    [31:0]  fmau_fpu_ex3_result;             
wire    [4 :0]  fmau_fpu_ex4_fflags;             
wire    [31:0]  fmau_fpu_ex4_result;             




parameter DOUBLE_WIDTH= 64;
parameter DOUBLE_FRAC = 52;
parameter DOUBLE_EXPN = 11;
parameter ADD_D_WIDTH =111;

parameter FUNC_WIDTH  = 10;

parameter SINGLE_WIDTH= 32;
parameter SINGLE_FRAC = 23;
parameter SINGLE_EXPN =  8;
parameter ADD_S_WIDTH = 53;











































assign ex2_adder_0_0[ADD_S_WIDTH-1:0] = {2'b00,{SINGLE_FRAC{1'b0}}, 2'b00, ex2_mult_data[2*SINGLE_FRAC+1:SINGLE_FRAC],|ex2_mult_single_gs_bit[1:0]};
assign ex2_adder_0_1[ADD_S_WIDTH-1:0] = {2'b00, ex2_mult_data[2*SINGLE_FRAC+1:0],3'b0};

assign ex2_adder_0[ADD_S_WIDTH-1:0] =  ex2_adder_0_sel_h ? ex2_adder_0_0[ADD_S_WIDTH-1:0] : ex2_adder_0_1[ADD_S_WIDTH-1:0];

assign ex2_adder_1_for_single_rnd_add_1 = !ex2_mac && !ex2_mult_data[2*SINGLE_FRAC+1];
assign ex2_adder_1_for_single_rnd_add_2 = !ex2_mac &&  ex2_mult_data[2*SINGLE_FRAC+1];


assign ex2_adder_1_rnd_data[ADD_S_WIDTH-1:0] = {{51{1'b0}},ex2_adder_1_for_single_rnd_add_1,{1{1'b0}} }
                                             | {{50{1'b0}},ex2_adder_1_for_single_rnd_add_2,{2{1'b0}} };

assign ex2_adder_1[ADD_S_WIDTH-1:0] = ex2_sub_vld 
                                   ? ~ex2_shift_data[ADD_S_WIDTH-1:0]
                                   : (ex2_shift_data[ADD_S_WIDTH-1:0] |ex2_adder_1_rnd_data[ADD_S_WIDTH-1:0]);

assign ex2_mult_single_gs_bit[1:0] = {ex2_mult_data[22], |ex2_mult_data[21: 0]};

assign ex2_shift_limit_low[15:0] = 16'b1000_0000_0000_0000 >> ex2_mac_expnt[3:0];
assign ex2_shift_limit_vld       = (ex2_mac_expnt[9:6]==4'b0000);




always @(posedge fmau_ex3_data_clk)
begin
 if(ctrl_dp_ex2_inst_pipe_down || ctrl_xx_ex2_warm_up) 
 begin
    ex3_mult_single_gs_bit[1:0]    <= ex2_mult_single_gs_bit[1:0];
    ex3_adder_0[ADD_S_WIDTH-1:0]   <= ex2_adder_0[ADD_S_WIDTH-1:0];
    ex3_adder_1[ADD_S_WIDTH-1:0]   <= ex2_adder_1[ADD_S_WIDTH-1:0];
    ex3_shift_limit_low[15:0]      <= ex2_shift_limit_low[15:0] & {16{ex2_shift_limit_vld}};
  end
end

assign ex3_shift_limit_one_hot[63:0] = {ex3_shift_limit_low[15:0],{48{1'b0}} } >> {ex3_mac_expnt[5:4],4'b0};
assign ex3_shift_limit[52:0] = ex3_shift_limit_one_hot[63:11];



assign ex3_adder_0_result[ADD_S_WIDTH-1:0] = ex3_adder_0[ADD_S_WIDTH-1:0] + ex3_adder_1[ADD_S_WIDTH-1:0];
assign ex3_adder_1_result[ADD_S_WIDTH-1:0] = ex3_adder_0[ADD_S_WIDTH-1:0] + ex3_adder_1[ADD_S_WIDTH-1:0] + 1'b1;

assign ex3_adder_result_sel[0] = !ex3_sub_vld;
assign ex3_adder_result_sel[1] =  ex3_sub_vld && ex3_adder_1_result[ADD_S_WIDTH-1];
assign ex3_adder_result_sel[2] =  ex3_sub_vld &&!ex3_adder_1_result[ADD_S_WIDTH-1];


always @( ex3_adder_0_result[52:0]
       or ex3_adder_1_result[52:0]
       or ex3_adder_result_sel[2:0])
begin
case(ex3_adder_result_sel[2:0])
  3'b001: ex3_adder_result[ADD_S_WIDTH-1:0] = ex3_adder_0_result[ADD_S_WIDTH-1:0];
  3'b010: ex3_adder_result[ADD_S_WIDTH-1:0] =~ex3_adder_0_result[ADD_S_WIDTH-1:0];
  3'b100: ex3_adder_result[ADD_S_WIDTH-1:0] = ex3_adder_1_result[ADD_S_WIDTH-1:0];
 default: ex3_adder_result[ADD_S_WIDTH-1:0] = {ADD_S_WIDTH{1'bx}};
endcase

end

assign ex3_mac_sign = ex3_mult_sign ^(ex3_sub_vld && ex3_adder_1_result[ADD_S_WIDTH-1]);
assign ex3_mac_frac_not_zero = |ex3_adder_result[ADD_S_WIDTH-1:0];












pa_fmau_lza_single  x_pa_fmau_lza_single (
  .addend          (ex3_adder_1    ),
  .lza_result      (ex3_lza_result ),
  .sub_vld         (ex3_sub_vld    ),
  .summand         (ex3_adder_0    ),
  .upper_limit     (ex3_shift_limit)
);










assign ex3_mac_result_shift[ADD_S_WIDTH-1:0] = ex3_adder_result[ADD_S_WIDTH-1:0]<<{ex3_lza_result[4:0]};
assign ex3_mac_expnt_adjust[SINGLE_EXPN+1:0] = ex3_mac_expnt[SINGLE_EXPN+1:0] -{ {4{1'b0}},ex3_lza_result[5:0]};

assign ex3_mac_expnt_neg_max                 =(ex3_mac_expnt[SINGLE_EXPN+1:0] == { {4{1'b0}},ex3_lza_result[5:0]});

always @(posedge fmau_ex4_data_clk)
begin
 if(ctrl_dp_ex3_inst_pipe_down || ctrl_xx_ex3_warm_up) 
 begin
    ex4_mac_expnt[SINGLE_EXPN+1:0]     <= ex3_mac_expnt_adjust[SINGLE_EXPN+1:0];
    ex4_mac_frac_pre[ADD_S_WIDTH-1:0]  <= ex3_mac_result_shift[ADD_S_WIDTH-1:0];
    ex4_mac_expnt_neg_max              <= ex3_mac_expnt_neg_max;
    ex4_mac_frac_not_zero              <= ex3_mac_frac_not_zero;
    ex4_mac_shift_32_bit               <= ex3_lza_result[5];
    ex4_mac_sign                       <= ex3_mac_sign;

  end
end



assign ex4_mac_frac[ADD_S_WIDTH-1:0] = ex4_mac_shift_32_bit ? {ex4_mac_frac_pre[ADD_S_WIDTH-33:0], {32{1'b0}} }
                                                            :  ex4_mac_frac_pre[ADD_S_WIDTH- 1:0];

assign ex4_early_of = (ex4_mac_expnt[9 : 8]==2'b01)||(ex4_mac_expnt[9 : 0]==10'b00_1111_1111);

assign ex4_plus_1_of=(ex4_mac_expnt[9:0] == 10'b00_1111_1110) && ex4_mac_expnt_plus_1;

assign ex4_of_frac_bit = (ex4_inst_rm[2:0]==3'b001)
                       ||(ex4_inst_rm[2:0]==3'b010) && !ex4_mac_sign
                       ||(ex4_inst_rm[2:0]==3'b011) &&  ex4_mac_sign;

assign ex4_mac_expnt_plus_1 = ex4_mac_frac[ADD_S_WIDTH-1] || ex4_mac_expnt_neg_max;

assign ex4_mac_data_no_rnd[SINGLE_FRAC:0] =(ex4_mac_frac[ADD_S_WIDTH-1] || ex4_mac_expnt_neg_max)
                                          ? ex4_mac_frac[ADD_S_WIDTH-1:ADD_S_WIDTH-SINGLE_FRAC-1]
                                          : ex4_mac_frac[ADD_S_WIDTH-2:ADD_S_WIDTH-SINGLE_FRAC-2];
                                            

assign ex4_mac_data_for_rnd[SINGLE_FRAC+1:0] = {1'b0, ex4_mac_data_no_rnd[SINGLE_FRAC:0]}; 

assign ex4_mac_rnd_result[SINGLE_FRAC+1:0] = ex4_mac_data_for_rnd[SINGLE_FRAC+1:0] +
                                           { {24{1'b0}},1'b1 };

assign ex4_rnd_bit[2:0] = (ex4_mac_frac[ADD_S_WIDTH-1] || ex4_mac_expnt_neg_max)
                        ? {ex4_mac_frac[29:28],|ex4_mac_frac[27:0]}
                        : {ex4_mac_frac[28:27],|ex4_mac_frac[26:0]};

always @( ex4_inst_rm[2:0]
       or ex4_mac_sign
       or ex4_rnd_bit[2:0])
begin
case(ex4_inst_rm[2:0])
  3'b000: ex4_mac_rnd_in = ex4_rnd_bit[1] && (ex4_rnd_bit[0] || ex4_rnd_bit[2]);
  3'b001: ex4_mac_rnd_in = 1'b0;
  3'b010: ex4_mac_rnd_in = ex4_mac_sign && |ex4_rnd_bit[1:0];
  3'b011: ex4_mac_rnd_in =!ex4_mac_sign && |ex4_rnd_bit[1:0];
  3'b100: ex4_mac_rnd_in = ex4_rnd_bit[1];
default : ex4_mac_rnd_in = 1'b0;
endcase

end

assign ex4_mac_frac_sel[0] = ex4_mac_rnd_result[SINGLE_FRAC+1] && ex4_mac_rnd_in && !ex4_early_of && !ex4_plus_1_of;
assign ex4_mac_frac_sel[1] =!ex4_mac_rnd_result[SINGLE_FRAC+1] && ex4_mac_rnd_in && !ex4_early_of && !ex4_plus_1_of;


always @( ex4_mac_rnd_result[23:0]
       or ex4_early_of
       or ex4_mac_data_no_rnd[22:0]
       or ex4_mac_frac_sel[1:0]
       or ex4_plus_1_of
       or ex4_of_frac_bit)
begin
case(ex4_mac_frac_sel[1:0])
  2'b01: ex4_mac_frac_result[SINGLE_FRAC-1:0] = ex4_mac_rnd_result[SINGLE_FRAC:1];
  2'b10: ex4_mac_frac_result[SINGLE_FRAC-1:0] = ex4_mac_rnd_result[SINGLE_FRAC-1:0];
default: ex4_mac_frac_result[SINGLE_FRAC-1:0] =(ex4_early_of || ex4_plus_1_of) ? {SINGLE_FRAC{ex4_of_frac_bit}} : ex4_mac_data_no_rnd[SINGLE_FRAC-1:0];
endcase

end

assign ex4_expnt_rnd_in = ex4_mac_rnd_in &&
                        &(ex4_mac_data_for_rnd[SINGLE_FRAC-1:0]);

assign ex4_mac_expnt_sel[2] = ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of 
                           && ex4_expnt_rnd_in && ex4_mac_expnt_plus_1 && !ex4_plus_1_of;

assign ex4_mac_expnt_sel[1] = ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of 
                           &&(ex4_expnt_rnd_in ^ ex4_mac_expnt_plus_1) && !ex4_plus_1_of
                           ||!ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of 
                           && ex4_expnt_rnd_in;

assign ex4_mac_expnt_sel[0] = ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of 
                           &&!ex4_expnt_rnd_in && !ex4_mac_expnt_plus_1
                           ||!ex4_mac_data_no_rnd[SINGLE_FRAC] && ex4_mac_frac_not_zero && !ex4_early_of
                           &&!ex4_expnt_rnd_in;

always @( ex4_mac_expnt[7:0]
       or ex4_mac_expnt_sel[2:0]
       or ex4_early_of
       or ex4_plus_1_of
       or ex4_of_frac_bit)
begin
case(ex4_mac_expnt_sel[2:0])
  3'b100: ex4_mac_expnt_result[SINGLE_EXPN-1:0] = ex4_mac_expnt[SINGLE_EXPN-1:0] + 8'b0000_0010;
  3'b010: ex4_mac_expnt_result[SINGLE_EXPN-1:0] = ex4_mac_expnt[SINGLE_EXPN-1:0] + 8'b0000_0001;
  3'b001: ex4_mac_expnt_result[SINGLE_EXPN-1:0] = ex4_mac_expnt[SINGLE_EXPN-1:0];
 default: ex4_mac_expnt_result[SINGLE_EXPN-1:0] =(ex4_early_of || ex4_plus_1_of) ? {{7{1'b1}},!ex4_of_frac_bit}: 8'b0000_0000; 
endcase

end


assign ex4_mac_sign_result = ex4_mac_frac_not_zero ? ex4_mac_sign : (ex4_inst_rm[2:0]==3'b010);

assign ex4_late_of = (ex4_mac_expnt[7:0]==8'b1111_1101) && ex4_mac_expnt_sel[2]
                   ||(ex4_mac_expnt[7:0]==8'b1111_1110) && ex4_mac_expnt_sel[1];

assign ex4_mac_of = ex4_early_of || ex4_plus_1_of || ex4_late_of;

assign ex4_mac_uf = ex4_mac_expnt_neg_max && |ex4_rnd_bit[1:0]
                && !ex4_expnt_rnd_in && !ex4_mac_data_no_rnd[SINGLE_FRAC];

assign ex4_mac_nx = |ex4_rnd_bit[1:0];

assign fmau_fpu_ex4_fflags[4:0] = {1'b0, 1'b0,ex4_mac_of,ex4_mac_uf,ex4_mac_nx || ex4_mac_of};

assign ex4_fmau_single_result[31:0] = {ex4_mac_sign_result,ex4_mac_expnt_result[7:0],ex4_mac_frac_result[22:0]};

assign fmau_fpu_ex4_result[31:0] = ex4_fmau_single_result[31:0];




assign ex3_mult_result[SINGLE_FRAC+1:0] = ex3_adder_0[SINGLE_FRAC+2:1];

assign ex3_mult_rnd_result[SINGLE_FRAC+1:0] = ex3_adder_0_result[SINGLE_FRAC+2:1];

assign ex3_mult_rnd_bit[2:0] = ex3_mult_result[SINGLE_FRAC+1]
                             ?{ex3_mult_result[1:0],|ex3_mult_single_gs_bit[1:0]}
                             :{ex3_mult_result[0],   ex3_mult_single_gs_bit[1:0]};


always @( ex3_mult_sign
       or ex3_inst_rm[2:0]
       or ex3_mult_rnd_bit[2:0])
begin
case(ex3_inst_rm[2:0])
  3'b000: ex3_mult_rnd_in = ex3_mult_rnd_bit[1] && (ex3_mult_rnd_bit[0] || ex3_mult_rnd_bit[2]);
  3'b001: ex3_mult_rnd_in = 1'b0;
  3'b010: ex3_mult_rnd_in = ex3_mult_sign && |ex3_mult_rnd_bit[1:0];
  3'b011: ex3_mult_rnd_in =!ex3_mult_sign && |ex3_mult_rnd_bit[1:0];
  3'b100: ex3_mult_rnd_in = ex3_mult_rnd_bit[1];
default : ex3_mult_rnd_in = 1'b0;
endcase

end

assign ex3_mult_frac_sel[0] = ex3_mult_rnd_result[SINGLE_FRAC+1] && ex3_mult_rnd_in;
assign ex3_mult_frac_sel[1] =!ex3_mult_rnd_result[SINGLE_FRAC+1] && ex3_mult_rnd_in;

assign ex3_mult_no_rnd_result[SINGLE_FRAC-1:0] = ex3_mult_result[SINGLE_FRAC+1]
                                               ? ex3_mult_result[SINGLE_FRAC:1]
                                               : ex3_mult_result[SINGLE_FRAC-1:0];

always @( ex3_mult_no_rnd_result[22:0]
       or ex3_mult_frac_sel[1:0]
       or ex3_mult_rnd_result[23:0])
begin
case(ex3_mult_frac_sel[1:0])
  2'b01: ex3_mult_frac_result[SINGLE_FRAC-1:0] = ex3_mult_rnd_result[SINGLE_FRAC:1];
  2'b10: ex3_mult_frac_result[SINGLE_FRAC-1:0] = ex3_mult_rnd_result[SINGLE_FRAC-1:0];
default: ex3_mult_frac_result[SINGLE_FRAC-1:0] = ex3_mult_no_rnd_result[SINGLE_FRAC-1:0];
endcase

end

assign ex3_mult_expnt_add_in = ex3_mult_result[SINGLE_FRAC+1] 
                          ||  &ex3_mult_result[SINGLE_FRAC-1:0] && ex3_mult_rnd_in;

assign ex3_mult_expnt_plus_1[SINGLE_EXPN+1:0] = ex3_mult_expnt[SINGLE_EXPN+1:0] + 1'b1;

assign ex3_mult_expnt_result[SINGLE_EXPN-1:0] =  ex3_mult_expnt_add_in 
                                               ? ex3_mult_expnt_plus_1[SINGLE_EXPN-1:0]
                                               : ex3_mult_expnt[SINGLE_EXPN-1:0];

assign ex3_mult_single_result[SINGLE_WIDTH-1:0] = { ex3_mult_sign, 
                                                    ex3_mult_expnt_result[SINGLE_EXPN-1:0],
                                                    ex3_mult_frac_result[SINGLE_FRAC-1:SINGLE_FRAC-SINGLE_FRAC]};

assign ex3_mult_nx = |ex3_mult_rnd_bit[1:0];

assign fmau_fpu_ex3_result[SINGLE_WIDTH-1:0] = ex3_mult_single_result[SINGLE_WIDTH-1:0];

assign fmau_fpu_ex3_fflags[4:0] = {4'b0,ex3_mult_nx};


endmodule