Forum Discussion
Altera_Forum
Honored Contributor
16 years agofixed point multiplication
Hi. I have a signed multiplication to perform in the following format:
a(32.0) * b(2.30) Limitation of b(2.30):range from -1 to 1 FYI, i will only get the correct result whenever my output is at least 33.60. Truncation of LSB 60 bit to get signed integer only. The way how i perform multiplication is {a, 32'b0} * b. Is it possible to get a result of 32 bit(signed integer only)? thanks6 Replies
- Altera_Forum
Honored Contributor
Try using the fixed point VHDL package...it works wonders with fixed point
KJ - Altera_Forum
Honored Contributor
Yes, you r right. the saturation logic is needed.
- Altera_Forum
Honored Contributor
Did you verify, that your truncated result is correct for a = -2**31 and b = -1 (the most negative numbers)? If not, saturation logic is required.
- Altera_Forum
Honored Contributor
i am sorry that i make a silly mistake in the simulation. i put high for bit -30 of b that make the result wrong.
I appreciate who view it. thanks - Altera_Forum
Honored Contributor
can you give an example and how u declare the a, b and result? thanks
Besides, my result is very weird. e.g. 3 * 1 = 4. code and vwf is attached. Pls comment on it. However, when i perform 4.0 * 2.2, I get the correct result using the same code. May i know why? - Altera_Forum
Honored Contributor
--- Quote Start --- i will only get the correct result whenever my output is at least 33.60 --- Quote End --- Why? Basically you are performing a 32 * 32 bit multiply, result length is 64 bits (not all bits need to be actually calculated). The remaining problem is how many bits have to be skipped at the right respectively truncated at the left of the result. If the b factor can > +1 or <= -1, saturation logic is required.