Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Regular Visitor
spacegato
Posts: 17
Registered: ‎02-25-2009
0
Accepted Solution

Properly formatting floating point core input values

Hello everyone.  I'm trying to use the Xilinx floating point (FP) Core v5.0 and I am having difficulty figuring out the format of the input values.  I am clear that the core expects input values in the FP representation (with the exception of the fixed-to-float converter) described in DS335.  However, after attempting to the follow DS335 and the Wiki page linked in another forum post, I'm not fully clear on how to properly represent the input.  What I'm looking for is example inputs and the expected output.  For example, if I wanted to multiply (or add) FP values 4.5 (decimal) and 2.5 (decimal), how would I represent these inputs as a 12-bit exponent and 20-bit fraction FP number to the core; the MSB of the exponent is a sign bit.  The fixed point representation of 4.5 is 0x00480000 but I'm pretty certain that this hex value would not be the same in FP representation.  What would I do differently?

 

 

Expert Contributor
eilert
Posts: 2,059
Registered: ‎08-14-2007

Re: Properly formatting floating point core input values

Hi,

take a look at the IEEE-745 floating point number standard. (Can be found in wikipedia, the german version is more helpful, with pictures and examples: http://de.wikipedia.org/wiki/IEEE_754 )

 

Float numbers do a normalisation of numbers, that means leading zeros are obmitted, and even the one that then appears as the first bit is dropped (because it has to be there, so it needs not to be stored).

 

So, your 32.20 fixed point becomes a 20.20 fixed point leaded by a 12 digit signed exponent that tells you how to shift this value to get the true number. (not to mention the sign bit at the beginning)

(There are more nasty tricks used to optimize storage and handling, see the details in the standard)

 

There are Java applets on the net that show how this works in detail. (google for yourself)

 

Actually, to use the FPcore for a single operation, you need three instances of it to simplify your life:

 

1)fix2float

2) your actual operator (+-*/)

[2a)maybe some other float operations ]

3)float2fix

 

 

Have a nice simulation

  Eilert

Regular Visitor
spacegato
Posts: 17
Registered: ‎02-25-2009
0

Re: Properly formatting floating point core input values

That wiki page is awesome and much much better than the US verson!  It helped a lot for propely formating my FP values.  I am doing both FP and Fixed-to-FP operations, i.e. I have some FP values and I also have fixed-point values to perform operations on.  I believe I have a good understanding on what you said about fixed point values but I'm going to ask this question to get clarity on the Fixed-to-FP converter.  Going back to my earlier post, the 12.20 fixed point value of 4.5 (decimal) is 32'h00480000 (Verilog), where the hex value 80000 is the 20-bit fraction part.  If I use the Fixed-to-FP converter (configured as 12.20 in CoreGen) would 32'h00480000 be the proper input or would I need to do something different?  

Expert Contributor
eilert
Posts: 2,059
Registered: ‎08-14-2007
0

Re: Properly formatting floating point core input values

Hi,

if configured correctly it should take the input as described (32'h00480000) and convert it to some FP number.

A short simulation and comparing the result to what you have learned now from Wikipedia should be sufficient to check this.

 

(Or you can simply use the Float2fixed converter core and see if it converts the number back to 4.5 decimal.)

 

For the details of controlling the core (handling controll signals, latency  etc.) please refer to the datasheet.

 

Have anice simulation

  Eilert

Xilinx Employee
chrisar
Posts: 383
Registered: ‎08-01-2007
0

Re: Properly formatting floating point core input values

Here is an website that contains a very useful conversion tool that may be helpful as well for checking your results.

 

http://babbage.cs.qc.edu/IEEE-754/

Chris
Regular Visitor
spacegato
Posts: 17
Registered: ‎02-25-2009
0

Re: Properly formatting floating point core input values

[ Edited ]

Thanks I did a few tests with the Fixed-to-float converter and verified the result with my calculated float from the web link you provided.  Thanks for all the help.