NI does not actively maintain this document.
This content provides support for older products and technology, so you may notice outdated links or obsolete information about operating systems or other relevant products.
Beginning with the LabVIEW 2012 FPGA Module, you can perform fixed-point to floating point conversions using the To Single Precision Float function. The following applies to the LabVIEW 2011 FPGA Module and earlier.
The fixed-point data type used by LabVIEW FPGA is a useful feature especially when working with NI C Series modules. In many applications it is necessary to convert fixed-point data to a floating-point representation for processing or streaming operations.
The conversion from fixed-point to floating point may certainly be done by the windows or real-time host application, but depending on available computing resources it can be advantageous to perform that conversion down on the FPGA.
LabVIEW FPGA does not natively support floating-point data types, but an understanding of IEEE Std 754-2008 standard (for floating point binary representation) will enable us to encode floating-point data types as unsigned integers. For example single-precision floating-point data can be stored as an unsigned 32 bit word (U32) on the FPGA and then typecast into a SGL precision floating-point value by the host application. A typecast from U32 to SGL is much cheaper (in terms of CPU resources) than a conversion from FXP to SGL.
IEEE 754 standard defines this data type as:
The mantissa assumes the most significant bit is 1 so only 23 bits of the fractional mantissa is actually encoded. With a 24-bit mantissa, you will get approximately 6 1/2 decimals digits of precision or >120 dB of dynamic range.
The exponent value is is biased by 127 to make floating point conversions more efficient.
To represent a decimal number in the exponent / mantissa form you must:
Example:
To convert 9.5 from a decimal value to the exponent / mantissa form:
A 64.24 fixed-point value reserves 24 bits for the integer and 40 bits for the precision digits. The value 9.5 would be represented as:
40 bits of precision >> << 24 integer bits
00000000 00000000 00000000 00000000 00000001 . 1001000 00000000 00000000
To perform the conversion in binary, the algorithm is much simpler:
While the algorithm mentioned above is simply stated, the most difficult part of the data conversion is finding the position of the most significant bit.
Ultimately, a searching algorithm must be used. The LV FPGA conversion code provided here combines a single-cycle Timed Loop (SCTL) and a state machine architecture to perform the search and encode the data in the least amount of time. The state machine execution follows this progression:
For each data point, the FXPtoSGL_EncodeU32.vi takes 10 ticks of the FPGA clock to execute.
When compiled by itself on an NI cRIO-9074 the VI used:
The FXPtoSGL_EncodeU32.vi requires the following support software: