Generate Instantiable Code for Functions - MATLAB & Simulink (original) (raw)

Main Content

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 VHDLentity, Verilog or SystemVerilog module for each function, and save each module orentity in a separate file.

How To Generate Instantiable Code for Functions

To set the InstantiateFunctions parameter using the HDL Block Properties dialog box:

  1. Right-click the MATLAB Function block.
  2. Select > .
  3. 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:

See Also

Check for MATLAB Function block settings