Jump to content

Meaning of FXP "Word Length" vs "Integer Word Length"


AlexA

Recommended Posts

Hi Guys,

Tinkering with my FPGA code today, I ran into a question which I'd never really contemplated before. Say I have an unsigned FXP number with word length = 1 and integer word length = 2. Labview tells me that this gives a maximum of 2 with a delta of 2, so the number can either be 0 or 2.

This makes no intuitive sense to me, the way I understood it, the word length is the total number of bits used to capture the number, the integer word length is the number of bits dedicated to capturing the integer portion, in other words, it kind of defines the "magnitude" of the number that can be captured, the remaining bits are used to give the "precision" to which the number is captured. So how is it even possible for the "integer word length" to be greater than the "word length"?

Insight much appreciated.

Cheers,

Alex

Link to comment

I'm not sure why you'd do that, but it makes sense. Think of the difference between the integer word length and the word length as the power of 2 that a single bit represents. If your word length and your integer word length are both the same, that difference is 0, and a single bit represents 2^0=1 (a fixed-point value with an integer length equal to word length has no fractional portion). If the integer word length is 6 and the word length is 8, a single bit is 2^(6-8) = 2^(-2) = 0.25. In your case, you have an integer word length of 2 and a word length of 1, so a single bit represents 2^(2-1) = 2^1 = 2, which matches what LabVIEW is telling you: the number has 1 bit, which represents either 0 or 2.

Edited by ned
  • Like 1
Link to comment
  • 1 year later...

The example that I keep tucked in the ol' noodle is the exceedingly bizarre situation of a FXP number with a WL of 1 and an IWL of -1024, meaning you have 1 bit to represent the value (so only two numbers in the range) and that they are the exceedingly small numbers around 0, so ±2^-1024

Link to comment

If you are ever unsure of the range a number holds I just test it.  Put in a few numbers into both controls and then try to end numbers into the control to see the range and resolution.  I agree that the controls aren't labeled in an intuitive way but I can always test it to make sure it is working right.

Link to comment

You could also look at it as the position where the decimal point is set. If you have (word length == integer length) then you have the decimal point just after the last bit so this comes out as a normal integer. With your settings you get a single flip-flop which is interpreted as bit 1 of an integer, therefore you get the two values 0 = 0*2^1 and 2 = 1*2^1.

Link to comment
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.