Main Content

Generate Simulink Model from MATLAB Design

R2026b

Using the HDL Workflow Advisor, you can generate a Simulink® model that represents your MATLAB® design. Use this workflow to port a MATLAB design into Simulink for model‑based design, where you can then generate HDL code from the Simulink model.

Enable Fixed-Point Conversion

Before you generate the Simulink model, complete the floating-point to fixed-point conversion process, even if the MATLAB design is already fixed-point. For more information, see Floating-Point to Fixed-Point Conversion.

Generate a Simulink Model

You can generate a Simulink model from a MATLAB design by using the HDL Workflow Advisor or programmatically by creating a coder.config object and enabling model generation.

To generate a Simulink model by using the Workflow Advisor:

  1. In the Workflow Advisor, on the left pane, click HDL Code Generation.

  2. In the Advanced tab, select the Generate Simulink model (Simulink license is required) parameter.

To generate a Simulink model at the command line, enter:

hdlcfg = coder.config("hdl");
hdlcfg.GenerateMLFcnBlock = true;

Note

The top-level MATLAB design function cannot have input or output arguments with the struct data type.

HDL Coder™ opens an untitled Simulink model that contains a MATLAB Function block representing the MATLAB design. The Aggressive Dataflow Conversion parameter value in the Workflow Advisor affects the elements in the generated model. When you enable Aggressive Dataflow Conversion and Generate Simulink Model parameters, HDL Coder represents the MATLAB design using Simulink blocks instead of only a MATLAB Function block.

You can use the generated model for simulation, incorporate it into a larger Simulink design, or generate HDL code from the model.

Limitations

Simulink model generation is not supported if you disable the Aggressive Dataflow Conversion parameter and enable the Enable frame to sample conversion to automatically convert frame-based inputs to samples parameter in the Workflow Advisor.

See Also

Tools

Blocks

Topics