+ Post New Thread
Results 1 to 7 of 7
  1. #1
    Junior Member level 2
    Points: 1,186, Level: 7

    Join Date
    May 2007
    Location
    Finland
    Posts
    21
    Helped
    1 / 1
    Points
    1,186
    Level
    7

    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.

    •   Alt29th May 2007, 13:02

      advertising

        
       

  2. #2
    Full Member level 4
    Points: 2,890, Level: 12

    Join Date
    Sep 2006
    Posts
    199
    Helped
    56 / 56
    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.

    •   Alt29th May 2007, 15:33

      advertising

        
       

  3. #3
    Junior Member level 2
    Points: 1,186, Level: 7

    Join Date
    May 2007
    Location
    Finland
    Posts
    21
    Helped
    1 / 1
    Points
    1,186
    Level
    7

    vhdl x001

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



    •   Alt30th May 2007, 09:23

      advertising

        
       

  4. #4
    Newbie level 5
    Points: 727, Level: 5
    omar_elruby's Avatar
    Join Date
    Feb 2009
    Location
    Ulm, Germany
    Posts
    9
    Helped
    0 / 0
    Points
    727
    Level
    5

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



  5. #5
    FvM
    FvM is offline
    Advanced Member level 5
    Points: 162,980, Level: 96
    Awards:
    Helpful gold

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    25,681
    Helped
    7957 / 7957
    Points
    162,980
    Level
    96

    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.



  6. #6
    Newbie level 5
    Points: 727, Level: 5
    omar_elruby's Avatar
    Join Date
    Feb 2009
    Location
    Ulm, Germany
    Posts
    9
    Helped
    0 / 0
    Points
    727
    Level
    5

    vhdl multiply by fraction

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



  7. #7
    Full Member level 6
    Points: 2,704, Level: 12
    vipinlal's Avatar
    Join Date
    Mar 2010
    Location
    India
    Posts
    349
    Helped
    75 / 75
    Points
    2,704
    Level
    12

    HELP...fixed-point multiply using VHDL

    Read tutoRial seRies on fixed point vhdl package heRe..
    http://vhdlguru.blogspot.com/2010/03...-tutorial.html



+ Post New Thread
Please login