Results 1 to 10 of 10

Thread: Floating point division

  1. #1
    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    1

    Default Floating point division

    Hi,
    does anyone has a code for floating point division?

    i tried using the megafunction tool for division but it keeps giving me error when i run simulation.

  2. #2
    Join Date
    May 2010
    Posts
    193
    Rep Power
    1

    Default Re: Floating point division

    how about your code?

  3. #3
    Join Date
    Jan 2011
    Location
    US-Indiana
    Posts
    143
    Rep Power
    1

    Default Re: Floating point division

    Floating point division in firmware is no trivial task. You could always offload that problem to a NIOS, but that seems like overkill. Are you sure you can't get by with fixed point or avoiding division entirely?

  4. #4
    Join Date
    Oct 2012
    Posts
    9
    Rep Power
    1

    Default Re: Floating point division

    You could try using integers.

    Multiply the FP numbers by a scalar to convert it to a integer, divide the integers, then convert back to FP or divide down to get just the integer result of the multiplication.

  5. #5
    Join Date
    Oct 2008
    Posts
    3,705
    Rep Power
    1

    Default Re: Floating point division

    Quote Originally Posted by danielg1 View Post
    You could try using integers.

    Multiply the FP numbers by a scalar to convert it to a integer, divide the integers, then convert back to FP or divide down to get just the integer result of the multiplication.
    Floating to integer conversion is not as simple as "multiply by a scaler", you need to do a full conversion. You may be thinking of fixed point, which is just integer arithmatic anyway.

  6. #6
    Join Date
    Nov 2009
    Location
    uk
    Posts
    1,617
    Rep Power
    1

    Default Re: Floating point division

    FP division is probably simpler than integer division - especially if you aren't worried about underflow, overflow, infinities, NaNs and denormalised small values.
    Extract and subtract the exponents and then divide the mantissa's - which both start with a 1.

  7. #7
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    1

    Default Re: Floating point division

    Hi,

    For a 32 bit floating point number, i would like to know the split of signbit,exponent,mantissa.

  8. #8
    Join Date
    Dec 2007
    Location
    Bochum Germany
    Posts
    5,844
    Rep Power
    1

    Default Re: Floating point division

    The format is explained in the FP MegaFunction user manual. Or google for IEEE 754.

  9. #9
    Join Date
    Aug 2004
    Location
    Texas Y'all
    Posts
    2,178
    Rep Power
    1

    Default Re: Floating point division

    Sign bit : Exponent (8 bits) : Mantissa (23 bits)

    Keep in mind that the mantissa has the implied '1' that DSL referred to which isn't stored as part of the manatissa field.

    Back when I was working on floating point stuff I found this webpage very handy: http://www.h-schmidt.net/FloatConverter/IEEE754.html

    So DSL said to subtract bits [30:23] and divide bits {1'b1, [22:0]}. For the sign bit you could just XOR those bits since both positive or both negative should result in a positive result (sign bit = 0).

  10. #10
    Join Date
    Nov 2009
    Location
    uk
    Posts
    1,617
    Rep Power
    1

    Default Re: Floating point division

    You are then dividing two values between 0.5 and 1.999999999 - so the exponent may need changing by 1 (or 2?) in order to normalise the resultant mantissa.
    You should also worry aout the rounding rules (round to even is normally specified by default).

Similar Threads

  1. Changing data width in floating point ip vs using fixed point
    By fpga25 in forum General Altera Discussion
    Replies: 3
    Last Post: December 11th, 2010, 03:16 PM
  2. Fixed Point or Floating point implementation
    By napatel81 in forum General Altera Discussion
    Replies: 4
    Last Post: March 16th, 2010, 01:57 PM
  3. Replies: 5
    Last Post: January 7th, 2010, 11:43 AM
  4. I Want Code Verilog To Floating Point Division Or Multiply
    By ALMODAWAN in forum General Altera Discussion
    Replies: 0
    Last Post: July 26th, 2009, 02:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •