Generate Instantiable Code for Functions
For the MATLAB Function block, you can use the InstantiateFunctions
parameter to generate a VHDL®
entity
, Verilog® or SystemVerilog module
for each function. HDL Coder™ generates code for each entity
or module
in a separate file.
The InstantiateFunctions options for the MATLAB Function block are listed in the following table.
InstantiateFunctions Setting | Description |
---|---|
'off' (default) | Generate code for functions inline. |
'on' | Generate a VHDL
|
How To Generate Instantiable Code for Functions
To set the InstantiateFunctions parameter using the HDL Block Properties dialog box:
Right-click the MATLAB Function block.
Select HDL Code > HDL Block Properties.
For InstantiateFunctions, select on.
To set the InstantiateFunctions parameter
from the command line, use hdlset_param
. For
example, to generate instantiable code for functions in a MATLAB
Function block, myMatlabFcn
, in your DUT
subsystem, myDUT
, enter:
hdlset_param('my_DUT/my_MATLABFcnBlk', 'InstantiateFunctions', 'on')
Generate Code Inline for Specific Functions
If you want to generate instantiable code for some functions
but not others, enable the option to generate instantiable code for
functions, and use coder.inline
. See coder.inline
for details.
Limitations for Instantiable Code Generation for Functions
The software generates code inline when:
Function calls are within conditional code or
for
loops.Any function is called with a nonconstant
struct
input.The function has state, such as a persistent variable, and is called multiple times.
There is an enumeration anywhere in the design function.
See Also
Check for MATLAB Function block settings