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.
Boolean and the fixed-point type,
1-bit data types in MATLAB® and Simulink. These types are treated differently.
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
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
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:
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
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.
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 must use monotonically increasing enumeration values. For example, see this code:
classdef BasicColors < Simulink.IntEnumType enumeration Red(0) Yellow(1) Blue(2) end methods (Static) function retVal = getDefaultValue() retVal = BasicColors.Blue; end end end
You cannot perform arithmetic operations such as
+ with enumeration
You cannot perform comparison operations such as
enumeration values. You can perform a
operation or a conditional branch such as if or switch.