ZipCPU/zipcpu

Wrong division in Div module

muhammedkocaoglu opened this issue · 5 comments

I am having a problem with the div module you are using.

-15 / -4 = -1 but it should be 3
15 / 4 = 3 which is true
-15 / 4 = 1 but it should be -3
15 / -4 = -3 which is true

2 out of 4 cases are wrong which I corrected. I just wanted you to know.

Thanks! Let me take a look into this and see what's going on.

Okay, thanks. If I am not mistaken, if there is really a problem with div module, I can show you the way I corrected the design. Please make sure there is a problem and I am not mistaken.
With the changes I made, it uses less LUT and achieves better timing on ZYNQ 7010.
Regards.

I have now confirmed the bug, and issued a fix in 1f7f4eb. The test bench has been updated so that it fails (properly) before the fix, and passes afterwards.

Dan

This should really remain open until the fixed version of div.v has been merged into the main repository, or until the zipcore branch has been merged into the main repository.

These changes have now been merged into the main branch.

Dan