Skip to content

Commit

Permalink
CVFPU 0.8.1 vendorized for bugs correction
Browse files Browse the repository at this point in the history
- Fix Underflow flag for MUL and DIV/SQRT operations (#94 #726 #729)
- Fix for Float to Int conversion (#97 #83 #727)
- Fixed unnecessary trailing semicolon (#99)

Signed-off-by: Pascal Gouedo <[email protected]>
  • Loading branch information
Pascal Gouedo committed Aug 30, 2023
1 parent 0c8c1fd commit f3a904f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rtl/vendor/pulp_platform_fpnew.lock.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
upstream:
{
url: https://github.com/pulp-platform/fpnew.git
rev: 11659d7ff3580ac3226c6d56a90ef717cdc530e3
rev: 79e453139072df42c9ec8f697132ba485d74e23d
}
}
2 changes: 1 addition & 1 deletion rtl/vendor/pulp_platform_fpnew.vendor.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

upstream: {
url: "https://github.com/pulp-platform/fpnew.git",
rev: "11659d7ff3580ac3226c6d56a90ef717cdc530e3",
rev: "79e453139072df42c9ec8f697132ba485d74e23d",
},

exclude_from_upstream: [
Expand Down
6 changes: 5 additions & 1 deletion rtl/vendor/pulp_platform_fpnew/src/fpnew_cast_multi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,11 @@ module fpnew_cast_multi #(
// By default right shift mantissa to be an integer
denorm_shamt = unsigned'(MAX_INT_WIDTH - 1 - input_exp_q);
// overflow: when converting to unsigned the range is larger by one
if (input_exp_q >= signed'(fpnew_pkg::int_width(int_fmt_q2) - 1 + op_mod_q2)) begin
if ((input_exp_q >= signed'(fpnew_pkg::int_width(int_fmt_q2) - 1 + op_mod_q2)) // Exponent larger than max int range,
&& !(!op_mod_q2 // unless cast to signed int
&& input_sign_q // and input value is larges negative int value
&& (input_exp_q == signed'(fpnew_pkg::int_width(int_fmt_q2) - 1))
&& (input_mant_q == {1'b1, {INT_MAN_WIDTH-1{1'b0}}}))) begin
denorm_shamt = '0; // prevent shifting
of_before_round = 1'b1;
// underflow
Expand Down
2 changes: 1 addition & 1 deletion rtl/vendor/pulp_platform_fpnew/src/fpnew_divsqrt_multi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ module fpnew_divsqrt_multi #(
// Valid synch with other lanes
// When one divsqrt unit completes an operation, keep its done high, waiting for the other lanes
// As soon as all the lanes are over, we can clear this FF and start with a new operation
`FFLARNC(unit_done_q, unit_done, unit_done, simd_synch_done, 1'b0, clk_i, rst_ni);
`FFLARNC(unit_done_q, unit_done, unit_done, simd_synch_done, 1'b0, clk_i, rst_ni)
// Tell the other units that this unit has finished now or in the past
assign divsqrt_done_o = (unit_done_q | unit_done) & result_vec_op_q;

Expand Down
4 changes: 3 additions & 1 deletion rtl/vendor/pulp_platform_fpnew/src/fpnew_fma.sv
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,9 @@ module fpnew_fma #(
);

// Classification after rounding
assign uf_after_round = rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0; // exponent = 0
assign uf_after_round = (rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0) // denormal
|| ((pre_round_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0) && (rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == 1) &&
((round_sticky_bits != 2'b11) || (!sum_sticky_bits[MAN_BITS*2 + 4] && ((rnd_mode_i == fpnew_pkg::RNE) || (rnd_mode_i == fpnew_pkg::RMM)))));
assign of_after_round = rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '1; // exponent all ones

// -----------------
Expand Down
6 changes: 4 additions & 2 deletions rtl/vendor/pulp_platform_fpnew/src/fpnew_fma_multi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,10 @@ module fpnew_fma_multi #(

if (FpFmtConfig[fmt]) begin : active_format
always_comb begin : post_process
// detect of / uf
fmt_uf_after_round[fmt] = rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0; // denormal
// detect of / uf
fmt_uf_after_round[fmt] = (rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0) // denormal
|| ((pre_round_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0) && (rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == 1) &&
((round_sticky_bits != 2'b11) || (!sum_sticky_bits[MAN_BITS*2 + 4] && ((rnd_mode_i == fpnew_pkg::RNE) || (rnd_mode_i == fpnew_pkg::RMM)))));
fmt_of_after_round[fmt] = rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '1; // inf exp.

// Assemble regular result, nan box short ones.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ end
assign ex4_rst_norm[31:0] = {fdsu_ex4_result_sign,
ex4_expnt_rst[7:0],
ex4_frac_23[22:0]};
assign ex4_cor_uf = (fdsu_ex4_uf && !ex4_denorm_potnt_norm || ex4_uf_plus)
assign ex4_cor_uf = (fdsu_ex4_uf || ex4_denorm_potnt_norm || ex4_uf_plus)
&& fdsu_ex4_nx;
assign ex4_cor_nx = fdsu_ex4_nx
|| fdsu_ex4_of
Expand Down

0 comments on commit f3a904f

Please sign in to comment.