System Object Considerations for HLS Code Generation
You can generate HLS code in from your system that contains user-defined System object™ by using HDL Coder™.
Usage Rules and Limitations for System object for Generating Code
The following usage rules and limitations apply to using System object in code generated from MATLAB®.
Object Construction and Initialization
If objects are stored in persistent variables, initialize System objects once by embedding the object handles in an
if
statement with a call toisempty()
.Set arguments to System object constructors as compile-time constants.
Initialize all System object properties that
releaseImpl
uses before the end ofsetupImpl
.You cannot initialize System object properties with other MATLAB class objects as default values in code generation. You must initialize these properties in the constructor.
Inputs and Outputs
System object accept a maximum of 1024 inputs. A maximum of eight dimensions per input is supported.
The data type of the inputs should not change.
The complexity of the inputs should not change.
Do not pass a System object as an example input argument to a function being compiled with
codegen
.Do not pass a System object to functions declared as extrinsic (functions called in interpreted mode) using the
coder.extrinsic
function. System objects returned from extrinsic functions and scope System objects that automatically become extrinsic can be used as inputs to another extrinsic function. But, these functions do not generate code.
Properties
In MATLAB System blocks, you cannot use variable-size for discrete state properties of System objects. Private properties can be variable-size.
Objects cannot be used as default values for properties.
You can only assign values to nontunable properties once, including the assignment in the constructor.
Nontunable property values must be constant.
For fixed-point inputs, if a tunable property has dependent data type properties, you can set tunable properties only at construction time or after the object is locked.
For
getNumInputsImpl
andgetNumOutputsImpl
methods, if you set the return argument from an object property, that object property must have theNontunable
attribute.
Global Variables
Global variables are not allowed in a System object.
Methods
Code generation support is available only for these System object methods:
get
isDone
(for sources only)set
(for tunable properties)
For System object that you define, code generation support is available only for these methods:
releaseImpl
— Code is not generated automatically for this method. To release an object, you must explicitly call therelease
method in your code.