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

[BUG] Incorrect fflags Set When Using fdiv Instruction to Divide by Infinity #120

Open
fly-1011 opened this issue May 15, 2024 · 2 comments

Comments

@fly-1011
Copy link

Bug Description
In the CVA6 implementation, when the fdiv.s instruction is used to divide by a single-precision floating-point number representing positive infinity (0x7F800000), the Overflow (OF) flag in fflags is erroneously set. The value of fflags becomes 0x4, indicating an overflow error. However, in the Spike simulator, the fflags value is 0x0. According to the IEEE 754 standard, an Overflow (OF) condition should not occur in this case.

Steps to Reproduce:

  1. Initialize ft4 to 0x00000000 and ft6 to 0x7F800000 (infinity).
  2. Execute the instruction: fdiv.s ft1, ft4, ft6.
  3. Observe the value of fflags.

The log from CVA6 is as follows:

core   0: 0x0000000080002018 (0x186270d3) fdiv.s  ft1, ft4, ft6
3 0x0000000080002018 (0x186270d3) f 1 0xffffffff00000000
core   0: 0x000000008000201c (0x001023f3) csrrs   t2, fflags, zero
3 0x000000008000201c (0x001023f3) x 7 0x0000000000000004

The log from Spike is as follows:

core   0: 0x0000000080002018 (0x186270d3) fdiv.s  ft1, ft4, ft6
core   0: 3 0x0000000080002018 (0x186270d3) f1  0xffffffff00000000
core   0: 0x000000008000201c (0x001023f3) csrrs   t2, fflags, zero
core   0: 3 0x000000008000201c (0x001023f3) x7  0x0000000000000000

See:openhwgroup/cva6#2111

@pascalgouedo
Copy link

Same answer than #110

@fly-1011
Copy link
Author

fly-1011 commented Sep 9, 2024

Hi @pascalgouedo,😉

Thank you for your detailed explanation.

The bug occurs in the commit version of cvfpu: 3116391, and CVA6 is also using this version of cvfpu.

After reviewing the commit history, I noticed that "THMULTI" was introduced to cvfpu on May 31. When I initially raised this issue, the version in question did not yet include "THMULTI."

Additionally, I have reviewed previously reported bugs but did not find any mention of this particular issue, which is why I decided to raise it. I will proceed to verify if adding "THMULTI" resolves the bug.

Thank you once again for your support and insights.

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

2 participants