-
Notifications
You must be signed in to change notification settings - Fork 148
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
sqrtFP
is incorrect
#710
Comments
I am not aware of any issues, but because we are not testing that function, its behavior could have changed without us knowing. It's a combinational function for square root, which isn't what you'd use in hardware, so possibly no one has been using it and so no one noticed. It took a while to run on my computer with The
The example is testing hardware modules for performing the operations and has output starting with
we now see two lines:
where the second line shows the combinational logic computing the same result (that matches the expected). For the combinational square root computation, though, we see slight discrepancies:
and this is true for all 30 square root tests, and at the end of the simulation is reported the number of errors:
The results are close, though. I don't know enough about the function to know if this difference is expected or not. It could be that the function is computing in a different way and gets a slightly different approximation; or it could be that the function, while looping through the bits, has an off-by-one bug and if failing to include the contribution due to the last bit, say. I was not involved in writing the library or the tests, so I don't know. Maybe @darius-bluespec knows and can comment? He added the It's a short function, so maybe someone can read what it's doing and figure it out. Is there a reason that you need the |
I actually see some much bigger numerical discrepancies. For example, on a small-ish (<100) perfect squares, the I'd like to use this combinational circuit as part of my FPGA development loop. On the actual FPGA, I'll be using the Xilinx floating point IP and putting it into my design using BVI. However, I can't simulate the binary blob Xilinx IP with Bluesim or Verilator. So, when I am working in simulation, I use simulation-only floating point units that are combinational functions (like Thanks for looking into this! I really appreciate it :) |
Yeah I remember the FP module having some issues. I checked it with tests generated from IBM's fpgen two years ago, and documented the failures (incl. things like IIRC For my application I ended up wrapping DesignWare modules instead, and I used their sim-only Verilog models to simulate stuff, which worked fine. If you can't get Xilinx IP stuff to work (I'd think it would work with the Modelsim Xilinx includes at least?) maybe you can just find something to wrap, or maybe wrap something simple that uses SystemVerilog native But yeah it would be nice if someone with expertise / patience / access to the standard doc could get this fixed. I remember I made some thing that parsed the |
For simulation, you can also import C functions (via import-BDPI) to do the math. For sqrt, an imported function would probably compile and run faster than a large unrolled loop of logic. |
I don't know how well sqrtFP was ever tested or used; the pipelined module was definitely used and tested much more extensively. It looks like sqrtFP uses the same algorithm as the pipelined module, so it probably wouldn't be too difficult to debug and resolve the differences between them. |
Thanks! I agree, that if someone has the time to look, it shouldn't be too difficult to compare with |
Hi,
I've been trying to use
sqrtFP
from theFloatingPoint
library, and I was getting incorrect results. I then ranmake check
intestsuite/bsc.lib/FloatingPoint
(withtestArith = True
) and it seems likesqrtFP
fails all tests with lines like:Is this a known problem? Are there any correct versions of the function available on other branches?
Thanks!
The text was updated successfully, but these errors were encountered: