data/full_repos/permissive/447681894/pythondata_cpu_marocchino/verilog/rtl/verilog/pfpu_marocchino/pfpu_marocchino_muldiv.v
1: b'%Error: data/full_repos/permissive/447681894/pythondata_cpu_marocchino/verilog/rtl/verilog/pfpu_marocchino/pfpu_marocchino_muldiv.v:40: Cannot find include file: or1k_defines.v\n`include "or1k_defines.v" \n         ^~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/447681894/pythondata_cpu_marocchino/verilog/rtl/verilog/pfpu_marocchino,data/full_repos/permissive/447681894/or1k_defines.v\n             data/full_repos/permissive/447681894/pythondata_cpu_marocchino/verilog/rtl/verilog/pfpu_marocchino,data/full_repos/permissive/447681894/or1k_defines.v.v\n             data/full_repos/permissive/447681894/pythondata_cpu_marocchino/verilog/rtl/verilog/pfpu_marocchino,data/full_repos/permissive/447681894/or1k_defines.v.sv\n             or1k_defines.v\n             or1k_defines.v.v\n             or1k_defines.v.sv\n             obj_dir/or1k_defines.v\n             obj_dir/or1k_defines.v.v\n             obj_dir/or1k_defines.v.sv\n%Error: Exiting due to 1 error(s)\n'
module pfpu_marocchino_muldiv
(

  input             cpu_clk,

  input             pipeline_flush_i,
  input             mul_start_i,
  input             div_start_i,
  output            muldiv_taking_op_o,
  output            mul_rdy_o,
  input             rnd_taking_mul_i,
  output            div_rdy_o,
  input             rnd_taking_div_i,

  input             signa_i,
  input      [12:0] exp13a_i,
  input      [52:0] fract53a_i,

  input             signb_i,
  input      [12:0] exp13b_i,
  input      [52:0] fract53b_i,

  input             exec_op_fp64_arith_i,
  input             dbz_i,
  input             opc_0_i,

  output            mul_sign_o,
  output     [10:0] mul_shr_o,
  output     [12:0] mul_exp13sh0_o,
  output     [56:0] mul_fract57_o,

  output            div_sign_o,
  output     [10:0] div_shr_o,
  output            div_shl_o,
  output     [12:0] div_exp13sh0_o,
  output     [56:0] div_fract57_o,
  output            div_dbz_o
);






  reg  sIo_ready, sIo_pending;
  reg  s0o_mul_ready, s0o_div_ready;
  reg  s1o_mul_ready, s1o_div_ready;

  wire mul_taking_op, mul_busy;
  wire div_taking_op, div_busy;

  wire s1_busy = mul_busy | div_busy;
  wire s0_busy = (s0o_mul_ready | s0o_div_ready) & s1_busy;
  wire sI_busy = sIo_ready & sIo_pending;

  wire sI_adv = (mul_start_i   | div_start_i)   & ~sI_busy;
  wire s0_adv = (sIo_ready     | sIo_pending)   & ~s0_busy;
  wire s1_adv = (s0o_mul_ready | s0o_div_ready) & ~s1_busy;
  wire s2_adv =  mul_taking_op | div_taking_op;

  assign muldiv_taking_op_o = sI_adv;






  reg  [12:0] sIo_exp13a;
  reg  [52:0] sIo_fract53a;

  reg  [12:0] sIo_exp13b;
  reg  [52:0] sIo_fract53b;

  reg         sIo_signc;
  reg         sIo_op_fp64_arith;
  reg         sIo_op_mul;
  reg         sIo_op_div;
  reg         sIo_dbz;
  reg         sIo_opc_0;


  always @(posedge cpu_clk) begin
    if (sI_adv) begin

      sIo_exp13a    <= exp13a_i;
      sIo_fract53a  <= fract53a_i;

      sIo_exp13b    <= exp13b_i;
      sIo_fract53b  <= fract53b_i;

      sIo_signc   <= signa_i ^ signb_i;
      sIo_op_fp64_arith <= exec_op_fp64_arith_i;
      sIo_op_mul  <= mul_start_i;
      sIo_op_div  <= div_start_i;
      sIo_dbz     <= dbz_i;
      sIo_opc_0   <= opc_0_i;
    end
  end


  always @(posedge cpu_clk) begin
    if (pipeline_flush_i)
      sIo_ready <= 1'b0;
    else if (sI_adv)
      sIo_ready <= 1'b1;
    else if (s0_adv)
      sIo_ready <= sI_busy;
    else if (~sIo_pending)
      sIo_ready <= 1'b0;
  end


  always @(posedge cpu_clk) begin
    if (pipeline_flush_i)
      sIo_pending <= 1'b0;
    else if (s0_adv)
      sIo_pending <= 1'b0;
    else if (~sIo_pending)
      sIo_pending <= sIo_ready;
  end






  reg [5:0] s0t_nlza;
  always @(sIo_fract53a) begin
    (* parallel_case *)
    casez (sIo_fract53a)
      53'b1????????????????????????????????????????????????????: s0t_nlza =  6'd0;
      53'b01???????????????????????????????????????????????????: s0t_nlza =  6'd1;
      53'b001??????????????????????????????????????????????????: s0t_nlza =  6'd2;
      53'b0001?????????????????????????????????????????????????: s0t_nlza =  6'd3;
      53'b00001????????????????????????????????????????????????: s0t_nlza =  6'd4;
      53'b000001???????????????????????????????????????????????: s0t_nlza =  6'd5;
      53'b0000001??????????????????????????????????????????????: s0t_nlza =  6'd6;
      53'b00000001?????????????????????????????????????????????: s0t_nlza =  6'd7;
      53'b000000001????????????????????????????????????????????: s0t_nlza =  6'd8;
      53'b0000000001???????????????????????????????????????????: s0t_nlza =  6'd9;
      53'b00000000001??????????????????????????????????????????: s0t_nlza = 6'd10;
      53'b000000000001?????????????????????????????????????????: s0t_nlza = 6'd11;
      53'b0000000000001????????????????????????????????????????: s0t_nlza = 6'd12;
      53'b00000000000001???????????????????????????????????????: s0t_nlza = 6'd13;
      53'b000000000000001??????????????????????????????????????: s0t_nlza = 6'd14;
      53'b0000000000000001?????????????????????????????????????: s0t_nlza = 6'd15;
      53'b00000000000000001????????????????????????????????????: s0t_nlza = 6'd16;
      53'b000000000000000001???????????????????????????????????: s0t_nlza = 6'd17;
      53'b0000000000000000001??????????????????????????????????: s0t_nlza = 6'd18;
      53'b00000000000000000001?????????????????????????????????: s0t_nlza = 6'd19;
      53'b000000000000000000001????????????????????????????????: s0t_nlza = 6'd20;
      53'b0000000000000000000001???????????????????????????????: s0t_nlza = 6'd21;
      53'b00000000000000000000001??????????????????????????????: s0t_nlza = 6'd22;
      53'b000000000000000000000001?????????????????????????????: s0t_nlza = 6'd23;
      53'b0000000000000000000000001????????????????????????????: s0t_nlza = 6'd24;
      53'b00000000000000000000000001???????????????????????????: s0t_nlza = 6'd25;
      53'b000000000000000000000000001??????????????????????????: s0t_nlza = 6'd26;
      53'b0000000000000000000000000001?????????????????????????: s0t_nlza = 6'd27;
      53'b00000000000000000000000000001????????????????????????: s0t_nlza = 6'd28;
      53'b000000000000000000000000000001???????????????????????: s0t_nlza = 6'd29;
      53'b0000000000000000000000000000001??????????????????????: s0t_nlza = 6'd30;
      53'b00000000000000000000000000000001?????????????????????: s0t_nlza = 6'd31;
      53'b000000000000000000000000000000001????????????????????: s0t_nlza = 6'd32;
      53'b0000000000000000000000000000000001???????????????????: s0t_nlza = 6'd33;
      53'b00000000000000000000000000000000001??????????????????: s0t_nlza = 6'd34;
      53'b000000000000000000000000000000000001?????????????????: s0t_nlza = 6'd35;
      53'b0000000000000000000000000000000000001????????????????: s0t_nlza = 6'd36;
      53'b00000000000000000000000000000000000001???????????????: s0t_nlza = 6'd37;
      53'b000000000000000000000000000000000000001??????????????: s0t_nlza = 6'd38;
      53'b0000000000000000000000000000000000000001?????????????: s0t_nlza = 6'd39;
      53'b00000000000000000000000000000000000000001????????????: s0t_nlza = 6'd40;
      53'b000000000000000000000000000000000000000001???????????: s0t_nlza = 6'd41;
      53'b0000000000000000000000000000000000000000001??????????: s0t_nlza = 6'd42;
      53'b00000000000000000000000000000000000000000001?????????: s0t_nlza = 6'd43;
      53'b000000000000000000000000000000000000000000001????????: s0t_nlza = 6'd44;
      53'b0000000000000000000000000000000000000000000001???????: s0t_nlza = 6'd45;
      53'b00000000000000000000000000000000000000000000001??????: s0t_nlza = 6'd46;
      53'b000000000000000000000000000000000000000000000001?????: s0t_nlza = 6'd47;
      53'b0000000000000000000000000000000000000000000000001????: s0t_nlza = 6'd48;
      53'b00000000000000000000000000000000000000000000000001???: s0t_nlza = 6'd49;
      53'b000000000000000000000000000000000000000000000000001??: s0t_nlza = 6'd50;
      53'b0000000000000000000000000000000000000000000000000001?: s0t_nlza = 6'd51;
      53'b00000000000000000000000000000000000000000000000000001: s0t_nlza = 6'd52;
      53'b00000000000000000000000000000000000000000000000000000: s0t_nlza =  6'd0;
    endcase
  end


  reg [5:0] s0t_nlzb;
  always @(sIo_fract53b) begin
    (* parallel_case *)
    casez (sIo_fract53b)
      53'b1????????????????????????????????????????????????????: s0t_nlzb =  6'd0;
      53'b01???????????????????????????????????????????????????: s0t_nlzb =  6'd1;
      53'b001??????????????????????????????????????????????????: s0t_nlzb =  6'd2;
      53'b0001?????????????????????????????????????????????????: s0t_nlzb =  6'd3;
      53'b00001????????????????????????????????????????????????: s0t_nlzb =  6'd4;
      53'b000001???????????????????????????????????????????????: s0t_nlzb =  6'd5;
      53'b0000001??????????????????????????????????????????????: s0t_nlzb =  6'd6;
      53'b00000001?????????????????????????????????????????????: s0t_nlzb =  6'd7;
      53'b000000001????????????????????????????????????????????: s0t_nlzb =  6'd8;
      53'b0000000001???????????????????????????????????????????: s0t_nlzb =  6'd9;
      53'b00000000001??????????????????????????????????????????: s0t_nlzb = 6'd10;
      53'b000000000001?????????????????????????????????????????: s0t_nlzb = 6'd11;
      53'b0000000000001????????????????????????????????????????: s0t_nlzb = 6'd12;
      53'b00000000000001???????????????????????????????????????: s0t_nlzb = 6'd13;
      53'b000000000000001??????????????????????????????????????: s0t_nlzb = 6'd14;
      53'b0000000000000001?????????????????????????????????????: s0t_nlzb = 6'd15;
      53'b00000000000000001????????????????????????????????????: s0t_nlzb = 6'd16;
      53'b000000000000000001???????????????????????????????????: s0t_nlzb = 6'd17;
      53'b0000000000000000001??????????????????????????????????: s0t_nlzb = 6'd18;
      53'b00000000000000000001?????????????????????????????????: s0t_nlzb = 6'd19;
      53'b000000000000000000001????????????????????????????????: s0t_nlzb = 6'd20;
      53'b0000000000000000000001???????????????????????????????: s0t_nlzb = 6'd21;
      53'b00000000000000000000001??????????????????????????????: s0t_nlzb = 6'd22;
      53'b000000000000000000000001?????????????????????????????: s0t_nlzb = 6'd23;
      53'b0000000000000000000000001????????????????????????????: s0t_nlzb = 6'd24;
      53'b00000000000000000000000001???????????????????????????: s0t_nlzb = 6'd25;
      53'b000000000000000000000000001??????????????????????????: s0t_nlzb = 6'd26;
      53'b0000000000000000000000000001?????????????????????????: s0t_nlzb = 6'd27;
      53'b00000000000000000000000000001????????????????????????: s0t_nlzb = 6'd28;
      53'b000000000000000000000000000001???????????????????????: s0t_nlzb = 6'd29;
      53'b0000000000000000000000000000001??????????????????????: s0t_nlzb = 6'd30;
      53'b00000000000000000000000000000001?????????????????????: s0t_nlzb = 6'd31;
      53'b000000000000000000000000000000001????????????????????: s0t_nlzb = 6'd32;
      53'b0000000000000000000000000000000001???????????????????: s0t_nlzb = 6'd33;
      53'b00000000000000000000000000000000001??????????????????: s0t_nlzb = 6'd34;
      53'b000000000000000000000000000000000001?????????????????: s0t_nlzb = 6'd35;
      53'b0000000000000000000000000000000000001????????????????: s0t_nlzb = 6'd36;
      53'b00000000000000000000000000000000000001???????????????: s0t_nlzb = 6'd37;
      53'b000000000000000000000000000000000000001??????????????: s0t_nlzb = 6'd38;
      53'b0000000000000000000000000000000000000001?????????????: s0t_nlzb = 6'd39;
      53'b00000000000000000000000000000000000000001????????????: s0t_nlzb = 6'd40;
      53'b000000000000000000000000000000000000000001???????????: s0t_nlzb = 6'd41;
      53'b0000000000000000000000000000000000000000001??????????: s0t_nlzb = 6'd42;
      53'b00000000000000000000000000000000000000000001?????????: s0t_nlzb = 6'd43;
      53'b000000000000000000000000000000000000000000001????????: s0t_nlzb = 6'd44;
      53'b0000000000000000000000000000000000000000000001???????: s0t_nlzb = 6'd45;
      53'b00000000000000000000000000000000000000000000001??????: s0t_nlzb = 6'd46;
      53'b000000000000000000000000000000000000000000000001?????: s0t_nlzb = 6'd47;
      53'b0000000000000000000000000000000000000000000000001????: s0t_nlzb = 6'd48;
      53'b00000000000000000000000000000000000000000000000001???: s0t_nlzb = 6'd49;
      53'b000000000000000000000000000000000000000000000000001??: s0t_nlzb = 6'd50;
      53'b0000000000000000000000000000000000000000000000000001?: s0t_nlzb = 6'd51;
      53'b00000000000000000000000000000000000000000000000000001: s0t_nlzb = 6'd52;
      53'b00000000000000000000000000000000000000000000000000000: s0t_nlzb =  6'd0;
    endcase
  end


  reg        s0o_opc_0,         s0o_opc_0_p;
  reg        s0o_signc,         s0o_signc_p;
  reg [12:0] s0o_exp13a,        s0o_exp13a_p;
  reg [52:0] s0o_fract53a,      s0o_fract53a_p;
  reg  [5:0] s0o_shla,          s0o_shla_p;
  reg [12:0] s0o_exp13b,        s0o_exp13b_p;
  reg [52:0] s0o_fract53b,      s0o_fract53b_p;
  reg  [5:0] s0o_shlb,          s0o_shlb_p;
  reg        s0o_dbz,           s0o_dbz_p;
  reg        s0o_op_fp64_arith, s0o_op_fp64_arith_p;

  reg s0o_op_div_p, s0o_op_mul_p;

  always @(posedge cpu_clk) begin
    if (~sIo_pending) begin
      s0o_opc_0_p         <= sIo_opc_0;
      s0o_signc_p         <= sIo_signc;
      s0o_exp13a_p        <= sIo_exp13a;
      s0o_fract53a_p      <= sIo_fract53a;
      s0o_shla_p          <= s0t_nlza;
      s0o_exp13b_p        <= sIo_exp13b;
      s0o_fract53b_p      <= sIo_fract53b;
      s0o_shlb_p          <= s0t_nlzb;
      s0o_dbz_p           <= sIo_dbz;
      s0o_op_fp64_arith_p <= sIo_op_fp64_arith;
      s0o_op_div_p        <= sIo_op_div;
      s0o_op_mul_p        <= sIo_op_mul;
    end
  end

  always @(posedge cpu_clk) begin
    if (s0_adv) begin
      s0o_opc_0         <= sIo_pending ? s0o_opc_0_p         : sIo_opc_0;
      s0o_signc         <= sIo_pending ? s0o_signc_p         : sIo_signc;
      s0o_exp13a        <= sIo_pending ? s0o_exp13a_p        : sIo_exp13a;
      s0o_fract53a      <= sIo_pending ? s0o_fract53a_p      : sIo_fract53a;
      s0o_shla          <= sIo_pending ? s0o_shla_p          : s0t_nlza;
      s0o_exp13b        <= sIo_pending ? s0o_exp13b_p        : sIo_exp13b;
      s0o_fract53b      <= sIo_pending ? s0o_fract53b_p      : sIo_fract53b;
      s0o_shlb          <= sIo_pending ? s0o_shlb_p          : s0t_nlzb;
      s0o_dbz           <= sIo_pending ? s0o_dbz_p           : sIo_dbz;
      s0o_op_fp64_arith <= sIo_pending ? s0o_op_fp64_arith_p : sIo_op_fp64_arith;
    end
  end


  always @(posedge cpu_clk) begin
    if (pipeline_flush_i) begin
      s0o_div_ready <= 1'b0;
      s0o_mul_ready <= 1'b0;
    end
    else if (s0_adv) begin
      s0o_div_ready <= sIo_pending ? s0o_op_div_p : sIo_op_div;
      s0o_mul_ready <= sIo_pending ? s0o_op_mul_p : sIo_op_mul;
    end
    else if (s1_adv) begin
      s0o_div_ready <= 1'b0;
      s0o_mul_ready <= 1'b0;
    end
  end






  wire [52:0] s1t_fract53a = s0o_fract53a << s0o_shla;
  wire [52:0] s1t_fract53b = s0o_fract53b << s0o_shlb;

  wire [52:0] s1t_fract53a_mux = (s0o_div_ready | s0o_op_fp64_arith) ? (s1t_fract53a) : ({29'd0,s1t_fract53a[52:29]});
  wire [52:0] s1t_fract53b_mux = (s0o_div_ready | s0o_op_fp64_arith) ? (s1t_fract53b) : ({29'd0,s1t_fract53b[52:29]});


  wire [12:0] s1t_exp_bias = s0o_op_fp64_arith ? 13'd1023 : 13'd127;

  wire [12:0] s1t_exp13mux =
    ({13{s0o_div_ready}} & (s0o_exp13a - {7'd0,s0o_shla} - s0o_exp13b + {7'd0,s0o_shlb} + s1t_exp_bias)) |
    ({13{s0o_mul_ready}} & (s0o_exp13a - {7'd0,s0o_shla} + s0o_exp13b - {7'd0,s0o_shlb} - s1t_exp_bias));


  wire [12:0] s1t_exp13c = s1t_exp13mux & {13{~s0o_opc_0}};


  reg        s1o_opc_0;
  reg        s1o_signc;
  reg [12:0] s1o_exp13c;
  reg [52:0] s1o_fract53a;
  reg [52:0] s1o_fract53b;
  reg        s1o_dbz;
  reg        s1o_op_fp64_arith;

  always @(posedge cpu_clk) begin
    if (s1_adv) begin
      s1o_opc_0         <= s0o_opc_0;
      s1o_signc         <= s0o_signc;
      s1o_exp13c        <= s1t_exp13c;
      s1o_fract53a      <= s1t_fract53a_mux;
      s1o_fract53b      <= s1t_fract53b_mux;
      s1o_dbz           <= s0o_dbz;
      s1o_op_fp64_arith <= s0o_op_fp64_arith;
    end
  end


  always @(posedge cpu_clk) begin
    if (pipeline_flush_i) begin
      s1o_mul_ready <= 1'b0;
      s1o_div_ready <= 1'b0;
    end
    else if (s1_adv) begin
      s1o_mul_ready <= s0o_mul_ready;
      s1o_div_ready <= s0o_div_ready;
    end
    else if (s2_adv) begin
      s1o_mul_ready <= 1'b0;
      s1o_div_ready <= 1'b0;
    end
  end







  wire [10:0] s2t_shrx =


    s1o_exp13c[12] ? ((~s1o_exp13c[10:0]) + 11'd2) :




                     {10'd0,~(|s1o_exp13c)};


  wire [12:0] s2t_exp13c = s1o_opc_0 ? 13'd0 : s1o_exp13c;





  pfpu_marocchino_mul u_fp64_mul
  (

    .cpu_clk              (cpu_clk),

    .pipeline_flush_i     (pipeline_flush_i),
    .s1o_mul_ready_i      (s1o_mul_ready),
    .mul_busy_o           (mul_busy),
    .mul_taking_op_o      (mul_taking_op),
    .mul_rdy_o            (mul_rdy_o),
    .rnd_taking_mul_i     (rnd_taking_mul_i),

    .s1o_signc_i          (s1o_signc),
    .s2t_exp13c_i         (s2t_exp13c),
    .s2t_shrx_i           (s2t_shrx),
    .s1o_opc_0_i          (s1o_opc_0),
    .s1o_fract53a_i       (s1o_fract53a),
    .s1o_fract53b_i       (s1o_fract53b),
    .s1o_op_fp64_arith_i  (s1o_op_fp64_arith),

    .mul_sign_o           (mul_sign_o),
    .mul_shr_o            (mul_shr_o),
    .mul_exp13sh0_o       (mul_exp13sh0_o),
    .mul_fract57_o        (mul_fract57_o)
  );





  pfpu_marocchino_div u_fp64_div
  (

    .cpu_clk              (cpu_clk),

    .pipeline_flush_i     (pipeline_flush_i),
    .s1o_div_ready_i      (s1o_div_ready),
    .div_busy_o           (div_busy),
    .div_taking_op_o      (div_taking_op),
    .div_rdy_o            (div_rdy_o),
    .rnd_taking_div_i     (rnd_taking_div_i),

    .s1o_signc_i          (s1o_signc),
    .s2t_exp13c_i         (s2t_exp13c),
    .s2t_shrx_i           (s2t_shrx),
    .s1o_fract53a_i       (s1o_fract53a),
    .s1o_fract53b_i       (s1o_fract53b),
    .s1o_opc_0_i          (s1o_opc_0),
    .s1o_dbz_i            (s1o_dbz),
    .s1o_op_fp64_arith_i  (s1o_op_fp64_arith),

    .div_sign_o           (div_sign_o),
    .div_shr_o            (div_shr_o),
    .div_shl_o            (div_shl_o),
    .div_exp13sh0_o       (div_exp13sh0_o),
    .div_fract57_o        (div_fract57_o),
    .div_dbz_o            (div_dbz_o)
  );

endmodule
module pfpu_marocchino_muldiv
(

  input             cpu_clk,

  input             pipeline_flush_i,
  input             mul_start_i,
  input             div_start_i,
  output            muldiv_taking_op_o,
  output            mul_rdy_o,
  input             rnd_taking_mul_i,
  output            div_rdy_o,
  input             rnd_taking_div_i,

  input             signa_i,
  input      [12:0] exp13a_i,
  input      [52:0] fract53a_i,

  input             signb_i,
  input      [12:0] exp13b_i,
  input      [52:0] fract53b_i,

  input             exec_op_fp64_arith_i,
  input             dbz_i,
  input             opc_0_i,

  output            mul_sign_o,
  output     [10:0] mul_shr_o,
  output     [12:0] mul_exp13sh0_o,
  output     [56:0] mul_fract57_o,

  output            div_sign_o,
  output     [10:0] div_shr_o,
  output            div_shl_o,
  output     [12:0] div_exp13sh0_o,
  output     [56:0] div_fract57_o,
  output            div_dbz_o
);







  reg  sIo_ready, sIo_pending;
  reg  s0o_mul_ready, s0o_div_ready;
  reg  s1o_mul_ready, s1o_div_ready;

  wire mul_taking_op, mul_busy;
  wire div_taking_op, div_busy;

  wire s1_busy = mul_busy | div_busy;
  wire s0_busy = (s0o_mul_ready | s0o_div_ready) & s1_busy;
  wire sI_busy = sIo_ready & sIo_pending;

  wire sI_adv = (mul_start_i   | div_start_i)   & ~sI_busy;
  wire s0_adv = (sIo_ready     | sIo_pending)   & ~s0_busy;
  wire s1_adv = (s0o_mul_ready | s0o_div_ready) & ~s1_busy;
  wire s2_adv =  mul_taking_op | div_taking_op;

  assign muldiv_taking_op_o = sI_adv;






  reg  [12:0] sIo_exp13a;
  reg  [52:0] sIo_fract53a;

  reg  [12:0] sIo_exp13b;
  reg  [52:0] sIo_fract53b;

  reg         sIo_signc;
  reg         sIo_op_fp64_arith;
  reg         sIo_op_mul;
  reg         sIo_op_div;
  reg         sIo_dbz;
  reg         sIo_opc_0;


  always @(posedge cpu_clk) begin
    if (sI_adv) begin

      sIo_exp13a    <= exp13a_i;
      sIo_fract53a  <= fract53a_i;

      sIo_exp13b    <= exp13b_i;
      sIo_fract53b  <= fract53b_i;

      sIo_signc   <= signa_i ^ signb_i;
      sIo_op_fp64_arith <= exec_op_fp64_arith_i;
      sIo_op_mul  <= mul_start_i;
      sIo_op_div  <= div_start_i;
      sIo_dbz     <= dbz_i;
      sIo_opc_0   <= opc_0_i;
    end
  end


  always @(posedge cpu_clk) begin
    if (pipeline_flush_i)
      sIo_ready <= 1'b0;
    else if (sI_adv)
      sIo_ready <= 1'b1;
    else if (s0_adv)
      sIo_ready <= sI_busy;
    else if (~sIo_pending)
      sIo_ready <= 1'b0;
  end


  always @(posedge cpu_clk) begin
    if (pipeline_flush_i)
      sIo_pending <= 1'b0;
    else if (s0_adv)
      sIo_pending <= 1'b0;
    else if (~sIo_pending)
      sIo_pending <= sIo_ready;
  end






  reg [5:0] s0t_nlza;
  always @(sIo_fract53a) begin
    (* parallel_case *)
    casez (sIo_fract53a)
      53'b1????????????????????????????????????????????????????: s0t_nlza =  6'd0;
      53'b01???????????????????????????????????????????????????: s0t_nlza =  6'd1;
      53'b001??????????????????????????????????????????????????: s0t_nlza =  6'd2;
      53'b0001?????????????????????????????????????????????????: s0t_nlza =  6'd3;
      53'b00001????????????????????????????????????????????????: s0t_nlza =  6'd4;
      53'b000001???????????????????????????????????????????????: s0t_nlza =  6'd5;
      53'b0000001??????????????????????????????????????????????: s0t_nlza =  6'd6;
      53'b00000001?????????????????????????????????????????????: s0t_nlza =  6'd7;
      53'b000000001????????????????????????????????????????????: s0t_nlza =  6'd8;
      53'b0000000001???????????????????????????????????????????: s0t_nlza =  6'd9;
      53'b00000000001??????????????????????????????????????????: s0t_nlza = 6'd10;
      53'b000000000001?????????????????????????????????????????: s0t_nlza = 6'd11;
      53'b0000000000001????????????????????????????????????????: s0t_nlza = 6'd12;
      53'b00000000000001???????????????????????????????????????: s0t_nlza = 6'd13;
      53'b000000000000001??????????????????????????????????????: s0t_nlza = 6'd14;
      53'b0000000000000001?????????????????????????????????????: s0t_nlza = 6'd15;
      53'b00000000000000001????????????????????????????????????: s0t_nlza = 6'd16;
      53'b000000000000000001???????????????????????????????????: s0t_nlza = 6'd17;
      53'b0000000000000000001??????????????????????????????????: s0t_nlza = 6'd18;
      53'b00000000000000000001?????????????????????????????????: s0t_nlza = 6'd19;
      53'b000000000000000000001????????????????????????????????: s0t_nlza = 6'd20;
      53'b0000000000000000000001???????????????????????????????: s0t_nlza = 6'd21;
      53'b00000000000000000000001??????????????????????????????: s0t_nlza = 6'd22;
      53'b000000000000000000000001?????????????????????????????: s0t_nlza = 6'd23;
      53'b0000000000000000000000001????????????????????????????: s0t_nlza = 6'd24;
      53'b00000000000000000000000001???????????????????????????: s0t_nlza = 6'd25;
      53'b000000000000000000000000001??????????????????????????: s0t_nlza = 6'd26;
      53'b0000000000000000000000000001?????????????????????????: s0t_nlza = 6'd27;
      53'b00000000000000000000000000001????????????????????????: s0t_nlza = 6'd28;
      53'b000000000000000000000000000001???????????????????????: s0t_nlza = 6'd29;
      53'b0000000000000000000000000000001??????????????????????: s0t_nlza = 6'd30;
      53'b00000000000000000000000000000001?????????????????????: s0t_nlza = 6'd31;
      53'b000000000000000000000000000000001????????????????????: s0t_nlza = 6'd32;
      53'b0000000000000000000000000000000001???????????????????: s0t_nlza = 6'd33;
      53'b00000000000000000000000000000000001??????????????????: s0t_nlza = 6'd34;
      53'b000000000000000000000000000000000001?????????????????: s0t_nlza = 6'd35;
      53'b0000000000000000000000000000000000001????????????????: s0t_nlza = 6'd36;
      53'b00000000000000000000000000000000000001???????????????: s0t_nlza = 6'd37;
      53'b000000000000000000000000000000000000001??????????????: s0t_nlza = 6'd38;
      53'b0000000000000000000000000000000000000001?????????????: s0t_nlza = 6'd39;
      53'b00000000000000000000000000000000000000001????????????: s0t_nlza = 6'd40;
      53'b000000000000000000000000000000000000000001???????????: s0t_nlza = 6'd41;
      53'b0000000000000000000000000000000000000000001??????????: s0t_nlza = 6'd42;
      53'b00000000000000000000000000000000000000000001?????????: s0t_nlza = 6'd43;
      53'b000000000000000000000000000000000000000000001????????: s0t_nlza = 6'd44;
      53'b0000000000000000000000000000000000000000000001???????: s0t_nlza = 6'd45;
      53'b00000000000000000000000000000000000000000000001??????: s0t_nlza = 6'd46;
      53'b000000000000000000000000000000000000000000000001?????: s0t_nlza = 6'd47;
      53'b0000000000000000000000000000000000000000000000001????: s0t_nlza = 6'd48;
      53'b00000000000000000000000000000000000000000000000001???: s0t_nlza = 6'd49;
      53'b000000000000000000000000000000000000000000000000001??: s0t_nlza = 6'd50;
      53'b0000000000000000000000000000000000000000000000000001?: s0t_nlza = 6'd51;
      53'b00000000000000000000000000000000000000000000000000001: s0t_nlza = 6'd52;
      53'b00000000000000000000000000000000000000000000000000000: s0t_nlza =  6'd0;
    endcase
  end


  reg [5:0] s0t_nlzb;
  always @(sIo_fract53b) begin
    (* parallel_case *)
    casez (sIo_fract53b)
      53'b1????????????????????????????????????????????????????: s0t_nlzb =  6'd0;
      53'b01???????????????????????????????????????????????????: s0t_nlzb =  6'd1;
      53'b001??????????????????????????????????????????????????: s0t_nlzb =  6'd2;
      53'b0001?????????????????????????????????????????????????: s0t_nlzb =  6'd3;
      53'b00001????????????????????????????????????????????????: s0t_nlzb =  6'd4;
      53'b000001???????????????????????????????????????????????: s0t_nlzb =  6'd5;
      53'b0000001??????????????????????????????????????????????: s0t_nlzb =  6'd6;
      53'b00000001?????????????????????????????????????????????: s0t_nlzb =  6'd7;
      53'b000000001????????????????????????????????????????????: s0t_nlzb =  6'd8;
      53'b0000000001???????????????????????????????????????????: s0t_nlzb =  6'd9;
      53'b00000000001??????????????????????????????????????????: s0t_nlzb = 6'd10;
      53'b000000000001?????????????????????????????????????????: s0t_nlzb = 6'd11;
      53'b0000000000001????????????????????????????????????????: s0t_nlzb = 6'd12;
      53'b00000000000001???????????????????????????????????????: s0t_nlzb = 6'd13;
      53'b000000000000001??????????????????????????????????????: s0t_nlzb = 6'd14;
      53'b0000000000000001?????????????????????????????????????: s0t_nlzb = 6'd15;
      53'b00000000000000001????????????????????????????????????: s0t_nlzb = 6'd16;
      53'b000000000000000001???????????????????????????????????: s0t_nlzb = 6'd17;
      53'b0000000000000000001??????????????????????????????????: s0t_nlzb = 6'd18;
      53'b00000000000000000001?????????????????????????????????: s0t_nlzb = 6'd19;
      53'b000000000000000000001????????????????????????????????: s0t_nlzb = 6'd20;
      53'b0000000000000000000001???????????????????????????????: s0t_nlzb = 6'd21;
      53'b00000000000000000000001??????????????????????????????: s0t_nlzb = 6'd22;
      53'b000000000000000000000001?????????????????????????????: s0t_nlzb = 6'd23;
      53'b0000000000000000000000001????????????????????????????: s0t_nlzb = 6'd24;
      53'b00000000000000000000000001???????????????????????????: s0t_nlzb = 6'd25;
      53'b000000000000000000000000001??????????????????????????: s0t_nlzb = 6'd26;
      53'b0000000000000000000000000001?????????????????????????: s0t_nlzb = 6'd27;
      53'b00000000000000000000000000001????????????????????????: s0t_nlzb = 6'd28;
      53'b000000000000000000000000000001???????????????????????: s0t_nlzb = 6'd29;
      53'b0000000000000000000000000000001??????????????????????: s0t_nlzb = 6'd30;
      53'b00000000000000000000000000000001?????????????????????: s0t_nlzb = 6'd31;
      53'b000000000000000000000000000000001????????????????????: s0t_nlzb = 6'd32;
      53'b0000000000000000000000000000000001???????????????????: s0t_nlzb = 6'd33;
      53'b00000000000000000000000000000000001??????????????????: s0t_nlzb = 6'd34;
      53'b000000000000000000000000000000000001?????????????????: s0t_nlzb = 6'd35;
      53'b0000000000000000000000000000000000001????????????????: s0t_nlzb = 6'd36;
      53'b00000000000000000000000000000000000001???????????????: s0t_nlzb = 6'd37;
      53'b000000000000000000000000000000000000001??????????????: s0t_nlzb = 6'd38;
      53'b0000000000000000000000000000000000000001?????????????: s0t_nlzb = 6'd39;
      53'b00000000000000000000000000000000000000001????????????: s0t_nlzb = 6'd40;
      53'b000000000000000000000000000000000000000001???????????: s0t_nlzb = 6'd41;
      53'b0000000000000000000000000000000000000000001??????????: s0t_nlzb = 6'd42;
      53'b00000000000000000000000000000000000000000001?????????: s0t_nlzb = 6'd43;
      53'b000000000000000000000000000000000000000000001????????: s0t_nlzb = 6'd44;
      53'b0000000000000000000000000000000000000000000001???????: s0t_nlzb = 6'd45;
      53'b00000000000000000000000000000000000000000000001??????: s0t_nlzb = 6'd46;
      53'b000000000000000000000000000000000000000000000001?????: s0t_nlzb = 6'd47;
      53'b0000000000000000000000000000000000000000000000001????: s0t_nlzb = 6'd48;
      53'b00000000000000000000000000000000000000000000000001???: s0t_nlzb = 6'd49;
      53'b000000000000000000000000000000000000000000000000001??: s0t_nlzb = 6'd50;
      53'b0000000000000000000000000000000000000000000000000001?: s0t_nlzb = 6'd51;
      53'b00000000000000000000000000000000000000000000000000001: s0t_nlzb = 6'd52;
      53'b00000000000000000000000000000000000000000000000000000: s0t_nlzb =  6'd0;
    endcase
  end


  reg        s0o_opc_0,         s0o_opc_0_p;
  reg        s0o_signc,         s0o_signc_p;
  reg [12:0] s0o_exp13a,        s0o_exp13a_p;
  reg [52:0] s0o_fract53a,      s0o_fract53a_p;
  reg  [5:0] s0o_shla,          s0o_shla_p;
  reg [12:0] s0o_exp13b,        s0o_exp13b_p;
  reg [52:0] s0o_fract53b,      s0o_fract53b_p;
  reg  [5:0] s0o_shlb,          s0o_shlb_p;
  reg        s0o_dbz,           s0o_dbz_p;
  reg        s0o_op_fp64_arith, s0o_op_fp64_arith_p;

  reg s0o_op_div_p, s0o_op_mul_p;

  always @(posedge cpu_clk) begin
    if (~sIo_pending) begin
      s0o_opc_0_p         <= sIo_opc_0;
      s0o_signc_p         <= sIo_signc;
      s0o_exp13a_p        <= sIo_exp13a;
      s0o_fract53a_p      <= sIo_fract53a;
      s0o_shla_p          <= s0t_nlza;
      s0o_exp13b_p        <= sIo_exp13b;
      s0o_fract53b_p      <= sIo_fract53b;
      s0o_shlb_p          <= s0t_nlzb;
      s0o_dbz_p           <= sIo_dbz;
      s0o_op_fp64_arith_p <= sIo_op_fp64_arith;
      s0o_op_div_p        <= sIo_op_div;
      s0o_op_mul_p        <= sIo_op_mul;
    end
  end

  always @(posedge cpu_clk) begin
    if (s0_adv) begin
      s0o_opc_0         <= sIo_pending ? s0o_opc_0_p         : sIo_opc_0;
      s0o_signc         <= sIo_pending ? s0o_signc_p         : sIo_signc;
      s0o_exp13a        <= sIo_pending ? s0o_exp13a_p        : sIo_exp13a;
      s0o_fract53a      <= sIo_pending ? s0o_fract53a_p      : sIo_fract53a;
      s0o_shla          <= sIo_pending ? s0o_shla_p          : s0t_nlza;
      s0o_exp13b        <= sIo_pending ? s0o_exp13b_p        : sIo_exp13b;
      s0o_fract53b      <= sIo_pending ? s0o_fract53b_p      : sIo_fract53b;
      s0o_shlb          <= sIo_pending ? s0o_shlb_p          : s0t_nlzb;
      s0o_dbz           <= sIo_pending ? s0o_dbz_p           : sIo_dbz;
      s0o_op_fp64_arith <= sIo_pending ? s0o_op_fp64_arith_p : sIo_op_fp64_arith;
    end
  end


  always @(posedge cpu_clk) begin
    if (pipeline_flush_i) begin
      s0o_div_ready <= 1'b0;
      s0o_mul_ready <= 1'b0;
    end
    else if (s0_adv) begin
      s0o_div_ready <= sIo_pending ? s0o_op_div_p : sIo_op_div;
      s0o_mul_ready <= sIo_pending ? s0o_op_mul_p : sIo_op_mul;
    end
    else if (s1_adv) begin
      s0o_div_ready <= 1'b0;
      s0o_mul_ready <= 1'b0;
    end
  end






  wire [52:0] s1t_fract53a = s0o_fract53a << s0o_shla;
  wire [52:0] s1t_fract53b = s0o_fract53b << s0o_shlb;

  wire [52:0] s1t_fract53a_mux = (s0o_div_ready | s0o_op_fp64_arith) ? (s1t_fract53a) : ({29'd0,s1t_fract53a[52:29]});
  wire [52:0] s1t_fract53b_mux = (s0o_div_ready | s0o_op_fp64_arith) ? (s1t_fract53b) : ({29'd0,s1t_fract53b[52:29]});


  wire [12:0] s1t_exp_bias = s0o_op_fp64_arith ? 13'd1023 : 13'd127;

  wire [12:0] s1t_exp13mux =
    ({13{s0o_div_ready}} & (s0o_exp13a - {7'd0,s0o_shla} - s0o_exp13b + {7'd0,s0o_shlb} + s1t_exp_bias)) |
    ({13{s0o_mul_ready}} & (s0o_exp13a - {7'd0,s0o_shla} + s0o_exp13b - {7'd0,s0o_shlb} - s1t_exp_bias));


  wire [12:0] s1t_exp13c = s1t_exp13mux & {13{~s0o_opc_0}};


  reg        s1o_opc_0;
  reg        s1o_signc;
  reg [12:0] s1o_exp13c;
  reg [52:0] s1o_fract53a;
  reg [52:0] s1o_fract53b;
  reg        s1o_dbz;
  reg        s1o_op_fp64_arith;

  always @(posedge cpu_clk) begin
    if (s1_adv) begin
      s1o_opc_0         <= s0o_opc_0;
      s1o_signc         <= s0o_signc;
      s1o_exp13c        <= s1t_exp13c;
      s1o_fract53a      <= s1t_fract53a_mux;
      s1o_fract53b      <= s1t_fract53b_mux;
      s1o_dbz           <= s0o_dbz;
      s1o_op_fp64_arith <= s0o_op_fp64_arith;
    end
  end


  always @(posedge cpu_clk) begin
    if (pipeline_flush_i) begin
      s1o_mul_ready <= 1'b0;
      s1o_div_ready <= 1'b0;
    end
    else if (s1_adv) begin
      s1o_mul_ready <= s0o_mul_ready;
      s1o_div_ready <= s0o_div_ready;
    end
    else if (s2_adv) begin
      s1o_mul_ready <= 1'b0;
      s1o_div_ready <= 1'b0;
    end
  end







  wire [10:0] s2t_shrx =


    s1o_exp13c[12] ? ((~s1o_exp13c[10:0]) + 11'd2) :




                     {10'd0,~(|s1o_exp13c)};


  wire [12:0] s2t_exp13c = s1o_opc_0 ? 13'd0 : s1o_exp13c;





  pfpu_marocchino_mul u_fp64_mul
  (

    .cpu_clk              (cpu_clk),

    .pipeline_flush_i     (pipeline_flush_i),
    .s1o_mul_ready_i      (s1o_mul_ready),
    .mul_busy_o           (mul_busy),
    .mul_taking_op_o      (mul_taking_op),
    .mul_rdy_o            (mul_rdy_o),
    .rnd_taking_mul_i     (rnd_taking_mul_i),

    .s1o_signc_i          (s1o_signc),
    .s2t_exp13c_i         (s2t_exp13c),
    .s2t_shrx_i           (s2t_shrx),
    .s1o_opc_0_i          (s1o_opc_0),
    .s1o_fract53a_i       (s1o_fract53a),
    .s1o_fract53b_i       (s1o_fract53b),
    .s1o_op_fp64_arith_i  (s1o_op_fp64_arith),

    .mul_sign_o           (mul_sign_o),
    .mul_shr_o            (mul_shr_o),
    .mul_exp13sh0_o       (mul_exp13sh0_o),
    .mul_fract57_o        (mul_fract57_o)
  );





  pfpu_marocchino_div u_fp64_div
  (

    .cpu_clk              (cpu_clk),

    .pipeline_flush_i     (pipeline_flush_i),
    .s1o_div_ready_i      (s1o_div_ready),
    .div_busy_o           (div_busy),
    .div_taking_op_o      (div_taking_op),
    .div_rdy_o            (div_rdy_o),
    .rnd_taking_div_i     (rnd_taking_div_i),

    .s1o_signc_i          (s1o_signc),
    .s2t_exp13c_i         (s2t_exp13c),
    .s2t_shrx_i           (s2t_shrx),
    .s1o_fract53a_i       (s1o_fract53a),
    .s1o_fract53b_i       (s1o_fract53b),
    .s1o_opc_0_i          (s1o_opc_0),
    .s1o_dbz_i            (s1o_dbz),
    .s1o_op_fp64_arith_i  (s1o_op_fp64_arith),

    .div_sign_o           (div_sign_o),
    .div_shr_o            (div_shr_o),
    .div_shl_o            (div_shl_o),
    .div_exp13sh0_o       (div_exp13sh0_o),
    .div_fract57_o        (div_fract57_o),
    .div_dbz_o            (div_dbz_o)
  );

endmodule