Skip to content

Commit

Permalink
🐛 Fix status flags for I2F and F2I conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-platzer committed Jun 5, 2024
1 parent 81c53c5 commit 0e2d2c7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/fpnew_cast_multi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,13 @@ module fpnew_cast_multi #(
logic [WIDTH-1:0] fp_result, int_result;
fpnew_pkg::status_t fp_status, int_status;

assign fp_regular_status.NV = src_is_int_q & (of_before_round | of_after_round); // overflow is invalid for I2F casts
assign fp_regular_status.NV = 1'b0; // floating-point results are always valid
assign fp_regular_status.DZ = 1'b0; // no divisions
assign fp_regular_status.OF = ~src_is_int_q & (~info_q.is_inf & (of_before_round | of_after_round)); // inf casts no OF
assign fp_regular_status.OF = ~info_q.is_inf & (of_before_round | of_after_round); // inf casts no OF
assign fp_regular_status.UF = uf_after_round & fp_regular_status.NX;
assign fp_regular_status.NX = src_is_int_q ? (| fp_round_sticky_bits) // overflow is invalid in i2f
: (| fp_round_sticky_bits) | (~info_q.is_inf & (of_before_round | of_after_round));
assign int_regular_status = '{NX: (| int_round_sticky_bits), default: 1'b0};
assign fp_regular_status.NX = (| fp_round_sticky_bits) | (~info_q.is_inf & (of_before_round | of_after_round));
assign int_regular_status = '{NV: of_before_round | of_after_round, // overflow is invalid for F2I casts
NX: (| int_round_sticky_bits), default: 1'b0};

assign fp_result = fp_result_is_special ? fp_special_result : fmt_result[dst_fmt_q2];
assign fp_status = fp_result_is_special ? fp_special_status : fp_regular_status;
Expand Down

0 comments on commit 0e2d2c7

Please sign in to comment.