openhwgroup / cva6

The CORE-V CVA6 is an Application class 6-stage RISC-V CPU capable of booting Linux
https://docs.openhwgroup.org/projects/cva6-user-manual/
Other
2.27k stars 685 forks source link

Divider Rounding Issues #242

Open zarubaf opened 5 years ago

zarubaf commented 5 years ago

There is still work to do on sub-normalised divides but this is repeatable and unrelated. For example 2.350988561514729E-38 / 2 => 0. (it should give 1.175494350822288E-38, a subnormal value)

Hello, thanks for your inputs. Indeed we are aware of bugs in the FP divider and square-root unit, however this one I haven't seen yet (see end of post for more thoughts on the bug). The div/sqrt unit we currently have is not very configurable and the code is quite convoluted, so we are hoping to replace it with something more flexible (and IEEE compliant) soon. Hence a bugfix for the current div/sqrt is not a high priority at this time.

Long-winded addendum The result value you list is correct (under default rounding), however it's actually encoded as the smallest normal FP32 value 0x00800000. The infinitely precise result lies exactly between this result and the largest subnormal FP32 value. The div/sqrt bugs we've seen so far concern off-by-one-ulp because of wrong rounding. What's possibly happening here seems to be that the mantissa is correctly rounded from all-ones (from the infinitely precise, subnormal result) up to all-zeroes, however the overflow produced from rounding doesn't seem to be added onto the (subnormal = 0) exponent. This leads to the zero result. I don't know whether this bug is contained to this subnormal/normal border case, but it might be possible that mantissa overflows from rounding in general are buggy.

ghost commented 2 years ago

Hi, I've run Tortoise tests on Ariane and there are some mismatches with the signature produced by Spike regarding the result from the FPU (looks like a rounding issue in sqrt). I was to open an issue when I see this one. Is there any update or is it planning any action?

JeanRochCoulon commented 1 year ago

Hello @ivanvera84 The FPU has just been updated. Can you verify whether the bug has disappeared, in that case the github issue could be closed.