Skip to content

Commit

Permalink
Issue openhwgroup#727 correction.
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Gouedo <pascal.gouedo@dolphin.fr>
  • Loading branch information
Pascal Gouedo committed Aug 11, 2023
1 parent 6933aaf commit 4072650
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 4072650

Please sign in to comment.