Skip to content

Commit

Permalink
🐛 Fix handling of infinity in F2F conversions (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-platzer authored Oct 23, 2024
1 parent a6af691 commit 0ad2cd7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/fpnew_cast_multi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,12 @@ module fpnew_cast_multi #(
end
// Handle FP over-/underflows
end else begin
// Overflow or infinities (for proper rounding)
if ((destination_exp_q >= signed'(2**fpnew_pkg::exp_bits(dst_fmt_q2))-1) ||
(~src_is_int_q && info_q.is_inf)) begin
// Infinities
if (~src_is_int_q && info_q.is_inf) begin
final_exp = unsigned'(2**fpnew_pkg::exp_bits(dst_fmt_q2)-1); // largest exponent
preshift_mant = '0;
// Overflow (for proper rounding)
end else if (destination_exp_q >= signed'(2**fpnew_pkg::exp_bits(dst_fmt_q2))-1) begin
final_exp = unsigned'(2**fpnew_pkg::exp_bits(dst_fmt_q2)-2); // largest normal value
preshift_mant = '1; // largest normal value and RS bits set
of_before_round = 1'b1;
Expand Down

0 comments on commit 0ad2cd7

Please sign in to comment.