Enabling Optimizations in HDL Coder
R2026bYou can use optimizations to impact the speed and area of your generated HDL code. You can apply optimizations to MATLAB® code or Simulink® models. In Simulink, you can apply optimizations to an entire model, a subsystem, or an individual block.
For more information about optimizations, see Introduction to Optimizations in HDL Coder.
Enable HDL Code Generation Optimizations in MATLAB
To enable optimizations on your MATLAB code:
On the MATLAB Toolstrip, from the Apps tab, select HDL Coder.
Select the MATLAB design and test bench files and click Workflow Advisor.
On the HDL Code Generation task, in the Optimization tab, enable the optimizations you want to use.
For more information on setting up and using the HDL Workflow Advisor with MATLAB designs, see Set Up HDL Workflow Advisor in MATLAB.
Enable HDL Code Generation Optimizations in Simulink
You can enable optimizations for the entire model, a subsystem, or for an individual block.
To enable optimizations for the entire Simulink model, use one of these approaches:
In the Configuration Parameters dialog box, in the HDL Code Generation > Optimization pane, select the optimizations that you want to apply.
At the command line, use the
makehdlorhdlset_paramfunction and specify the optimizations you want to enable.In the Simulink HDL Workflow Advisor, on the Set HDL Options task, use the HDL Code Generation Settings to open the Configuration Parameters dialog box. You can then navigate to the HDL Code Generation > Optimization pane.
You can also enable optimizations for an individual subsystem. When you enable an optimization for a subsystem:
The subsystem inherits the model-level optimization settings. You can override these settings in the HDL Block Properties dialog box or by using the
hdlset_paramfunction.If the subsystem has a parent subsystem, the subsystem inherits the optimization settings from the parent subsystem.
This table illustrates which optimizations are available at each level of model hierarchy.
| Optimization | Available at Model Level | Available at Subsystem Level |
|---|---|---|
| RAM mapping | Yes | No |
| Adaptive pipelining | Yes | Yes |
| Clock-rate pipelining | Yes | Yes |
| Delay balancing | No | Yes |
| Distributed pipelining | Yes | Yes |
| Resource sharing | Yes At the model level, you specify the type of resources you want to share, such as adders and multipliers. | Yes At the block or subsystem level, you specify the SharingFactor HDL block property. |
| Streaming | No | Yes |