-
Notifications
You must be signed in to change notification settings - Fork 422
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 report: wrong sign injection when encountering NaNs #309
Comments
Hi ^^ It is a known behaviour "documented" as "Very specific, but SGNJ instruction will not mutate the value from/to F32/F64 (no NaN-boxing mutation)" in the main readme.md :) I will have to take a look, i'm not sure if this is a bug which could create practical issues, i would say it isn't ? |
Ah cool, I missed it! What would it cost to fix it? |
Some headaches i think ^^ On NaxRiscv (https://spinalhdl.github.io/NaxRiscv-Rtd/main/NaxRiscv/introduction/index.html) i got it right, mostly because there was no re-encoding |
I'm willing to help! 🙂 if you have some indications I can try. |
I think, the main issue was that mutating the sign, in the case we have a nan boxed f32, would transform it into a f64. Probably something in that kind. Main things to care then is how the last stage handle this (rounding, reformating) : Here is how the internal used to store float value : All sgnj op goes into the "shortPip". Would have to check what that pipeline get in all cases (nan, nan boxed, others) to see how to properly handle it. |
Hi there!
I've detected a bug in VexRiscv.
Brief bug description
Some sign injection instructions, such as
fsgnj.d
orfsgnjx.d
, behave incorrectly when encountering NaNs.Example instance
Snippet
Here is an example RISC-V (rv32imfd) snippet:
Waves
Here is the VCD trace of the execution of this program.
Expected and actual results
We expect
f4 = 0x7fffffff7fc00000
because the sign bit off3
is 0. I verified this with Spike. Other designs such as Rocket and BOOM provide this result as well.However, VexRiscv returns
f4 = 0xffffffff7fc00000
.The specification says:
Fix
I identified the area probably responsible for the sign injection, which is
VexRiscv/src/main/scala/vexriscv/ip/fpu/FpuCore.scala
Lines 797 to 857 in b29eb54
However, I am very unfamiliar with the design itself and with SpinalHDL.
If you provide some guidance, I would be happy to help.
Thanks!
Flavien
The text was updated successfully, but these errors were encountered: