HDL Code Generation for System Objects
HDL Coder™ supports both predefined and user-defined System objects for code generation.
Why Use System Objects?
System objects provide a design advantage because:
You can save time during design and testing by using existing System object™ components.
You can design and qualify custom System objects for reuse in multiple designs.
You can define your algorithm in a System object once, and reuse multiple instances of it in a single MATLAB design.
This idiom cannot be used with MATLAB functions that have state. For example, if the algorithm has state and requires the use of persistent variables, that function cannot be instantiated multiple times in a design. Instead, you would need to copy and rename the function for each instance.
HDL code that you generate from System objects is modular and more readable.
Predefined System Objects
Predefined System objects that are available with MATLAB®, DSP System Toolbox™, and Communications Toolbox™ are supported for HDL code generation. For a list, see Predefined System Objects Supported for HDL Code Generation.
User-Defined System Objects
You can create user-defined System objects for HDL code generation. For an example, see Generate Code for User-Defined System Objects.
To use a MATLAB class for HDL code generation, the class must be a System object.
Limitations of HDL Code Generation for System Objects
The following limitations apply to HDL code generation for System objects:
Your design can call the System object only once.
You must not call the object inside a nested conditional statement, such as a nested loop,
You must not call the object inside a conditional statement that contains a matrix indexing operation.
A System object must be declared persistent if it has state.
A System object has state when it has a tunable private or public property, or a property with the
You can use the
dsp.DelaySystem object only in feed-forward delay modeling.
System objects in cell arrays are not supported.
Enumerations are not supported.
Global variables are not supported.
For predefined System objects, calling the object itself is supported for HDL code generation, but no other object functions are supported.
For user-defined System objects, either the
step method, or the
update methods, are supported for HDL code
Additional Restrictions for Predefined System Objects
Predefined System objects are not supported for HDL code generation from within a MATLAB System block.
Additional Restrictions for User-Defined System Objects
In addition to the limitations for all System objects, the following restrictions apply to user-defined System objects for HDL code generation:
resetImplmethods, if you assign values to properties or variables, the values must be constants.
If your design uses the
updatemethods, it can call each method only once per System object.
Initial and reset values for properties must be compile-time constant.
User-defined System objects must not be public properties.
A System object with multiple outputs cannot be called within a conditional statement.
System object Examples for HDL Code Generation
To learn how to use System objects for HDL code generation, view the MATLAB designs in the following examples: