OpenCores

Fixed Point Math Library for Verilog

Issue List
Sign bit not set properly #1
Closed whzahp opened this issue over 9 years ago
whzahp commented over 9 years ago

Hi, I was using the code of qmult.v The sign bit is not assigned correctly if we multiply a negative number by 0. Ideally the sign bit should be '0'. But the xor of the 2 sign bits (1 ^ 0) gives an incorrect value of 1.

whzahp commented over 9 years ago

I am sorry for opening the bug.. 1000 & 0000 are both valid for representing a '0' for a 4-bit number with sign+magnitude format.

Please close the bug.

BTW, Is there a similar library for doing fixed-point multiplication with 2's complement number format?

tomburkeii commented over 9 years ago

It is correct to have a negative and positive zero in mathematical operations. Imagine, that we performed a multiply by a very small number that essentially caused an underflow (which my modules do not detect). The "ghost" of this number would be only its sign, as it would otherwise be all zeroes in its representation.

This is important for multiple reasons: First, other mathematical functions have definitions based on the sign of zero (logarithms, for instance). second, this keeps an underflow from having the wrong sign in certain applications.

I believe this should stay, and was something I considered when I wrote the module.

As for the question RE: similar library - no, not that I know of. Certainly not by me.

tomburkeii commented over 9 years ago
tomburkeii closed this over 9 years ago
tito86 commented almost 6 years ago

Hello Burke,

In mult.v, Why r_RetValN-2:0 <= r_resultN-2+Q:Q?


Assignee
No one
Labels
Bug