AlexA Posted March 14, 2012 Report Share Posted March 14, 2012 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 Quote Link to comment

Tim_S Posted March 14, 2012 Report Share Posted March 14, 2012 I've not played with floating points for long enough that I'm blanking. Are they in the same units (i.e., both in bits)? Quote Link to comment

ned Posted March 14, 2012 Report Share Posted March 14, 2012 (edited) 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 March 14, 2012 by ned 1 Quote Link to comment

AlexA Posted March 15, 2012 Author Report Share Posted March 15, 2012 Interesting way of looking at it Ned, thanks for the insight. Quote Link to comment

bmouring Posted June 1, 2013 Report Share Posted June 1, 2013 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 Quote Link to comment

hooovahh Posted June 3, 2013 Report Share Posted June 3, 2013 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. Quote Link to comment

flintstone Posted June 3, 2013 Report Share Posted June 3, 2013 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. Quote Link to comment

Dragis Posted July 22, 2013 Report Share Posted July 22, 2013 For those interested in an in-depth look at fixed point, check out http://zone.ni.com/devzone/cda/pub/p/id/303. Quote Link to comment

## Recommended Posts

## Join the conversation

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