Working with Fixed-Point Data Types - 2022.2 English

Vitis Model Composer User Guide (UG1483)

Document ID
UG1483
Release Date
2023-01-13
Version
2022.2 English

As indicated earlier, Simulink® provides support for fixed-point data types through the Fixed-Point Designer™ product. However, the format of the fixed data type supported by Vitis Model Composer and Simulink are not compatible.

Figure 1. Fixed-Point Data Type

The format used to display the Model Composer fixed-point data types is as follows: x_[u/s]fix[wl]_E[n][fl]

Where:

  • x_: Is the prefix indicating the Xilinx fixed data type.
  • [u/s]: Represents signed or unsigned data.
  • fix: Indicates the fixed-point data type.
  • [wl] Specifies the word length of the data.
  • E: Prefix for the fractional portion of the fixed-point data type. Does not display if the fractional length is 0.
  • n: Displays 'n' if the binary point is to the left of the right-most bit in the word; or displays no 'n' if the binary point is to the right of the right-most bit in the word.
  • [fl]: Specifies the fractional length of the fixed-point data type, indicating the position of the binary point with respect to the right-most bit in the word.

For example, x_sfix16_En6 represents a signed 16-bit fixed-point number, with 6-bits allocated to the right of the binary point.

Notice the fixed-point data type also lets you specify what happens in the case of data overflow, or the need to do rounding or truncation. For more information refer to Data Type Conversion.

You must use a DTC block to convert the Model Composer fixed-point data type into the Simulink fixed-point data type. However, there is no direct conversion between Model Composer fixed-point and Simulink fixed-point data types, so you can use the following method:

  1. Convert Model Composer fixed-point data type to the double data type using the DTC block from the HLS library in the Library Browser.
  2. Convert the double data type to Simulink format fixed-point data type using the Simulink Data Type Conversion block from the Simulink Signal Attributes library in the Library Browser.
  3. Match the signedness, word length, and fractional length between the two fixed-point data types.
Tip: Converting between the Model Composer fixed data type and the Simulink fixed data type is not recommended unless necessary for your design. You can convert from the Model Composer fixed-point data type to double, as shown in the first step, and this should be sufficient for most applications.

Although handling fixed-point data type in a design is more time consuming, the value of using fixed-point data types for applications targeted at implementation in an FPGA is worth the challenge. It is widely accepted that designing in floating point leads to higher power usage for the design. This is true for FPGAs where floating-point DSP blocks have been hardened onto the FPGA and users must implement a floating point solution using DSP blocks and additional device resources. Floating-point implementations require more FPGA resources than an equivalent fixed-point solution. With this higher resource usage comes higher power consumption and ultimately increased overall cost of implementing the design. For more information refer to the white paper Reduce Power and Cost by Converting from Floating Point to Fixed Point (WP491).