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] Incorrectly set fflags: An underflow exception is triggered when the computed result is an exact subnormal number. #121

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

Comments

@fly-1011
Copy link

Bug Description
When using the division instruction, CVA6 incorrectly triggers an underflow exception when the computed result is an exact subnormal number (e.g., 0x00000001). This contradicts the IEEE 754 standard, which specifies that an exact subnormal result should not trigger the underflow exception flag.

Steps to Reproduce:

  1. Initialize ft4 to 0x00000001 and ft6 to 0x3F800000
  2. Execute the instruction: fdiv.s ft1, ft4, ft6.
  3. Observe the value of fflags.

The log from CVA6 is as follows:

core   0: 0x000000008000201e (0x186270d3) fdiv.s  ft1, ft4, ft6
3 0x000000008000201e (0x186270d3) f 1 0xffffffff00000001
core   0: 0x0000000080002022 (0x001023f3) csrrs   t2, fflags, zero
3 0x0000000080002022 (0x001023f3) x 7 0x0000000000000002

The log from Spike is as follows:

core   0: 0x000000008000201e (0x186270d3) fdiv.s  ft1, ft4, ft6
core   0: 3 0x000000008000201e (0x186270d3) f1  0xffffffff00000001
core   0: 0x0000000080002022 (0x001023f3) csrrs   t2, fflags, zero
core   0: 3 0x0000000080002022 (0x001023f3) x7  0x0000000000000000

The computed result is 2^-149, which can be exactly represented as a subnormal number. Therefore, in this case, the underflow exception should not be triggered.

See:openhwgroup/cva6#2129

@pascalgouedo
Copy link

Same answer than #110

@fly-1011
Copy link
Author

fly-1011 commented Sep 9, 2024

与#110答案相同

Please see the answer in #120 (comment)

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