Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

HELP...fixed-point multiply using VHDL

Status
Not open for further replies.

Alexander Yin

Junior Member level 2
Joined
May 29, 2007
Messages
21
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
Finland
Activity points
1,450
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.
 

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 .
 

    Alexander Yin

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
vhdl x001

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

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 :) ...
 

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"
Your example represents a different value
Code:
X = 001 1010000 "1.625"
Generally, you have to multiply your input number (e.g. 1.5) with a power of two to get the integer representing the fractional number.
 

vhdl multiply by fraction

YESSSSSSS, that's great,
sorry i thought in a wrong way,
It's working perfectlyyy,
Thank you so much :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top