Main Content

Simulink Data Type Considerations

You can follow these guidelines to learn the recommended data type settings that you want to use in your Simulink® model for HDL code generation. Each guideline has a severity level that indicates the level of compliance requirements. To learn more, see HDL Modeling Guidelines Severity Levels.

Use Boolean for Logical Data and Ufix1 for Numerical Data

Guideline ID

2.10.1

Severity

Mandatory

Description

Boolean and the fixed-point type, ufix1, are both 1-bit data types in MATLAB® and Simulink. These types are treated differently.

  • Use Boolean for control logic signals such as enable and local reset signals. If you want to calculate a Boolean signal with a fixed-point data type, use a Data Type Conversion to convert the signal to a fixdt (0,1,0) type.

  • To perform numeric calculations, use fixdt (0,1,0). Sometimes, the output bit width can become larger than the bitwidth. To perform such operations, use the Inherit: Inherit via internal rule setting, because of the numerictype property of fixdt (0,1,0).

Specify Data Type of Gain Blocks

Guideline ID

2.10.2

Severity

Recommended

Description

Gain blocks have a Gain parameter and an Output data type setting. It is recommended that you use fixed-point data types for these settings. In the Block Parameters dialog box of the Gain block:

  • Specify a Simulink.NumericType object, such as fixdt (1, 16, 8).

  • Make sure that the Gain parameter of the block does not use a round parameter value. To avoid rounding of the gain value, you can specify a fi object, such as fi(3.44,0,8,4).

  • Avoid using Inherit:Inherit via internal rule. This setting can result in an erroneous data type being assigned to the block, thereby resulting in an HDL code generation error.

Enumerated Data Type Restrictions

Guideline ID

2.10.3

Severity

Mandatory

Description

Certain optimizations such as pipelining and resource sharing do not work seamlessly in the presence of enumerated data types. It is recommended that you use enumerated types on an as needed basis. HDL code generation has certain restrictions when modeling with enumerated types.

  • You cannot use an enumerated data type for the input or output port of the top-level DUT.

  • You cannot perform arithmetic operations such as *, / , -, and + with enumeration values.

See Also

Functions

Related Topics