Skip to content

Commit 2c79477

Browse files
🐛 Fix status flags for I2F and F2I conversions (#125)
1 parent 0ad2cd7 commit 2c79477

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/fpnew_cast_multi.sv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,13 +723,13 @@ module fpnew_cast_multi #(
723723
logic [WIDTH-1:0] fp_result, int_result;
724724
fpnew_pkg::status_t fp_status, int_status;
725725

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

734734
assign fp_result = fp_result_is_special ? fp_special_result : fmt_result[dst_fmt_q2];
735735
assign fp_status = fp_result_is_special ? fp_special_status : fp_regular_status;

0 commit comments

Comments
 (0)