Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/fpnew_divsqrt_multi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,30 @@ module fpnew_divsqrt_multi #(
fpnew_pkg::status_t unit_status, held_status_q;
logic hold_en;

// Translate the fpnew RISC-V roundmode encoding into the legacy PULP
// div_sqrt_top_mvp RM_SI encoding. Nearest-even and truncate agree, but
// round-down and round-up are swapped, and the legacy unit has no
// ties-to-max mode, so map it to nearest-even.
logic [2:0] divsqrt_rm;
always_comb begin
unique case (rnd_mode_q)
fpnew_pkg::RNE: divsqrt_rm = 3'h0;
fpnew_pkg::RTZ: divsqrt_rm = 3'h1;
fpnew_pkg::RDN: divsqrt_rm = 3'h3;
fpnew_pkg::RUP: divsqrt_rm = 3'h2;
fpnew_pkg::RMM: divsqrt_rm = 3'h0;
default: divsqrt_rm = 3'h0;
endcase
end

div_sqrt_top_mvp i_divsqrt_lei (
.Clk_CI ( clk_i ),
.Rst_RBI ( rst_ni ),
.Div_start_SI ( div_valid ),
.Sqrt_start_SI ( sqrt_valid ),
.Operand_a_DI ( divsqrt_operands[0] ),
.Operand_b_DI ( divsqrt_operands[1] ),
.RM_SI ( rnd_mode_q ),
.RM_SI ( divsqrt_rm ),
.Precision_ctl_SI ( '0 ),
.Format_sel_SI ( divsqrt_fmt ),
.Kill_SI ( flush_i ),
Expand Down