DSP Builder for Intel® FPGAs (Advanced Blockset): Handbook

ID 683337
Date 12/12/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

15.4.19. Convert

The Convert block performs a type conversion of the input, and outputs the new data type.

You can optionally perform truncation, biased, or unbiased rounding if the output data type is smaller than the input. The LSB must be a value in the width in bits of the input type.

Table 179.  Parameters for the Convert Block
Parameter Description
Output data type mode Determines how the block sets its output data type:
  • Inherit via internal rule: the number of integer and fractional bits is the maximum of the number of bits in the input data types.
  • Inherit via back projection: a downstream block that this block drives determines the output data type. If the driven block does not propagate a data type to the driver, you must use a Simulink SameDT block to copy the required data type to the output wire.
  • Specify via dialog: you can set the output type of the block explicitly using additional fields that are available when this option is selected.
  • Boolean: the output type is Boolean.
  • Single: single-precision floating-point data.
  • Double: double-precision floating-point data.
  • Variable precision floating point: variable precision floating-point output type
Output data type Specifies the output data type. For example, sfix(16), uint(8).
Output scaling value Specifies the output scaling value. For example, 2^-15.
Rounding method Determines the rounding mode:
  • Truncate: Discard any bits that fall below the new least significant bit.
  • Biased: Add 0.5 LSB and then truncate. This rounds towards infinity.
  • Unbiased: If the discarded bits equal 0.5 LSB of the new value then round towards the even integer, otherwise perform add 0.5 LSB and then truncate. This prevents the rounding operation introducing a DC bias where 0.5 always rounds towards positive infinity.
Saturation The Convert block allows saturation, which has an optional clip detect output that outputs 1 if any clipping has occurred. Saturation choices are none, symmetric, or asymmetric.
Floating point precision Specifies the floating-point precision. For example, float32_m23.

For example, for an Add or Mult block, you can select the output word-length and fractional part using dialog.

Specifying the output type is a casting operation, which does not preserve the numerical value, only the underlying bits. This method never adds hardware to a block— just changes the interpretation of the output bits.

For example, for a multiplier with both input data-types, sfix16_En15 has output type sfix32_En30. If you select output format sfix32_En28, the output numerical value multiplies by four. For example, 1*1 input gives an output value of 4.

If the you select output format sfix32_En31, the output numerical value is divided by two. For example 1*1 input gives an output value of 0.5.

If you want to change data-type format in a way that preserves the numerical value, use a convert block, which adds the corresponding hardware. Adding a convert block directly after a primitive block lets you specify the data-type to preserve the numerical value.

For example, a Mult block followed by a Convert block, with input values 1*1 always give output value 1.

Table 180.  Port Interface for the Convert Block
Signal Direction Type Description Vector Data Support Complex Data Support
a Input Any fixed-point type Data Yes Yes
q Output Specified fixed-point type Data Yes Yes