LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Odd fixed point saturation

I ran into an issue where when I saturate to a particular fixed point type, it doesn't saturate to use the full number of bits, it saturates to some other odd number. Does anyone have a script to search for these weird fixed point types?

Weird coercion2.png

0 Kudos
Message 1 of 5
(1,373 Views)

What's the datatype of the FXP constant you're coercing to?

0 Kudos
Message 2 of 5
(1,349 Views)

The properties of the second one are messed up.  Right click properties on it, then go to Data Type:

Kyle97330_1-1669856438250.png

If you then change the word length to a different amount of bits, then back to 25, the minimum and maximum values change:

Kyle97330_0-1669856420675.png

Once you have done that, then the data types match and give the same result:

Kyle97330_2-1669856596871.png

 

0 Kudos
Message 3 of 5
(1,325 Views)

Hmm, interesting.

I do know that LabVIEW kind of keeps track of arithmetic done on FXP on FPGA.

If you wire a FXP +8 to a "+1" node and look at the context help of the output, it will list it as FXP 9, but with a range of 0...256. Adding another "+1" will leave tha data type at FXP9, but will increase the range to "0..257".

This way LabVIEW can prevent an explosion of the bit width of math operations on FPGA. MAybe you created a constant from one such terminal and it messes with the "Boolean to Number" function. That's my guess. Don't have LabVIEW open right now, can't check.

0 Kudos
Message 4 of 5
(1,282 Views)

Yes, that's probably what happened. I guess I'd prefer it was my job to prevent "bit width explosion" rather than the IDE though I could also imagine the compiler optimizing some bit widths behind the scenes. Seems something like that is dangerous enough that it deserves a special color or something. In the meanwhile, I was hoping someone had a script (maybe for VI analyzer) to find these "bugs waiting to happen". I guessing many of you might have some of these buried in your code too.

0 Kudos
Message 5 of 5
(1,257 Views)