Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Narrowing converting instruction mismatch issue for number infinity #69

Open
Shafi10x opened this issue Jan 23, 2023 · 3 comments
Open
Assignees

Comments

@Shafi10x
Copy link
Contributor

Shafi10x commented Jan 23, 2023

If a number is infinity in FP64, after converting it into FP32, will it be infinity or of max magnitude? According to spike, it is infinity but according to RTL implementation, it is of max magnitude.Actually, overflow and infinity are handled together i.e saturating it or making it max magnitude. I think it is fine to handle overflow like this, but for infinity, there should be another case i.e infinity should remain infinity.

@pascalgouedo
Copy link

In principle I would agree that infinity stays infinity whatever operation happens to it...

@stmach
Copy link
Collaborator

stmach commented Jan 23, 2023

Indeed, inf should always map to inf, no matter the rounding mode or format in use. Under which circumstances do you observe max magnitude being returned? A quick glance into the RTL indicates that this issue should only happen when casting infs with round mode RDN or RTZ (which should be fixed, of course).

@Shafi10x
Copy link
Contributor Author

In my case it was RTZ mode. I think the following part could be fixed.

      // 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
        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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants