Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

problem with fixed point number

sir/madam

i want to multiply 2 floating point number(say,1.5 and 2.7).but i can't understand how to convert them in integer (say 8 bit integer). i don't want to use floating multiplier bcoz it takes so many clbs in fpga.plz help.urjent:(

thanks in advance.

12 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    multiply both by 64. (0- (nearly)4 scale using 8 bits, or -2 to + (nearly) 2 if you want signed)

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Your two number example is no good for demonstration.

    Because I can scale up by 10 into 15 * 27 and you get 405 (needs 9 bits) then divide by 100 and you get 4. As such it is restricted and needed division.

    I can also say scale up by 16 instead of 10 and you get

    24 * 43 = 1032 (needs 11 bits) then discard 8 bits and you get 4

    without the need for division.

    The regular method used by classic HDL designers is this:

    You look at your input possible range and scale it up rounding to nearest integer. 8 bits can represent integers from 0 ~ 255 unsigned or -128 ~ +127 signed and the result can be either 16 bits or if you like less e.g. 8 MSBs implying division by 2^8. Once you get the result then you interpret it as required.

    Software designers on the other hand cannot deal with wires and so think of imagiary decimal point to make their life easy and ours hard.