- 29th May 2007, 13:02 #1
## fixed point multiply

Hi, pals,

I'm a green hand in VHDL and doing a very simple FFT. The first problem I encouter is how to program a 16 bits fixed point multiplier with 8 bits fraction. I don't want to use any multiplier module even they can save a huge number of logic gates. I just want to use "*" to do the multiplication.

But since the data type is fix point with fraction, I suppose the result have to be shifted after calculation by "*". But I am not sure about that and don't know how start this program.

Can anybody show me an example about this matter?

Thanks a lot.

- 29th May 2007, 13:02

- 29th May 2007, 15:33 #2

- Join Date
- Sep 2006
- Posts
- 199
- Helped
- 57 / 57
- Points
- 2,890
- Level
- 12

## vhdl multiply

First, if you are intending to use a fractional fixed notation like xxx.xxx, then you can perform multiplication by shifting each operand to the left by 8 and consider them as integers .Then, you can perform integer multiplication which can be performed by "*" .After finishing the multiplication, you must shift the result by 16 because you shifted each operand by 8 .If you only need 8 bits after the point, you can simply discard the rest of bits .

You can also use the IEEE floating point notation i.e you can represent the number as a sign ,exponent and magnitude .You simply multiply the magnitudes together and add the exponents .Note that this formats considers the number as 1.xxxeyyy i.e after magnitude multiplication, you may need to perform shifting till you achieve only 1 before the point ,and add the number of shifts to the exponent .

If your numbers' range is small I'd recommend the fixed point notation, but if you're expecting your system to handle large values of numbers, then you should consider the floating point notation .

2 members found this post helpful.

- 29th May 2007, 15:33

- 30th May 2007, 09:23 #3
## vhdl x001

Thanks a lot. That's a really smart way to shift and treat it like integer.

- 30th May 2007, 09:23

- 3rd May 2009, 16:27 #4
## vhdl fixed point multiplication

I have tried this, but it's not working with me,

i have inputs X, Y bit_vector( 9 downto 0), i'm having 7 decimal places

mulRes <= bit_vector((signed(X) * signed(Y))); -- mulRes bit_vector(19 downto 0)

res <= mulRes(16 downto 7);

X = 001 1010000 "1.5"

Y = 010 0000000 "2.0"

mulRes = 00001101000000000000

res = 0110100000 which is not 3 :(

Have i understood something in a wrong way ??

Thanks in advance :) ...

- 3rd May 2009, 17:07 #5

- Join Date
- Jan 2008
- Location
- Bochum, Germany
- Posts
- 27,937
- Helped
- 8812 / 8812
- Points
- 172,283
- Level
- 98

## how to multiply integers in vhdl

Yes, you apparently misunderstood the concept of fractional numbers.

This is the correct fractional representation for sfixed(2 downto -7) format

Code:X = 001 1000000 "1.5"

Code:X = 001 1010000 "1.625"

- 3rd May 2009, 19:07 #6
## vhdl multiply by fraction

YESSSSSSS, that's great,

sorry i thought in a wrong way,

It's working perfectlyyy,

Thank you so much :)

- 29th March 2010, 12:41 #7
## HELP...fixed-point multiply using VHDL

Read tutoRial seRies on fixed point vhdl package heRe..

http://vhdlguru.blogspot.com/2010/03...-tutorial.html