Main Content

Enabling Optimizations in HDL Coder

You can use optimizations to impact the speed and area of your generated HDL code. You can apply optimizations to MATLAB® code or Simulink® models. Additionally, in Simulink, you can apply optimizations to an entire model, a subsystem, or an individual block.

For more information about the optimizations available in HDL Coder, see Introduction to Optimizations in HDL Coder.

Enable HDL Code Generation Optimizations in MATLAB

To enable optimizations on your MATLAB code:

  1. On the MATLAB toolstrip, from the Apps tab, select the HDL Coder app.

  2. Select the MATLAB design and test bench files and click the Workflow Advisor button.

  3. On the HDL Code Generation task, in the Optimization tab, enable the optimizations you want to use.

Enable HDL Code Generation Optimizations in Simulink

You can enable optimizations for the entire model, a subsystem, or for an individual block.

You enable optimizations for an entire Simulink model from these locations:

  • In the Configuration Parameters dialog box, in the HDL Code Generation > Optimization pane.

  • At the command line by using the makehdl or hdlset_param function.

  • In the Simulink HDL Workflow Advisor, on the Set HDL Options task. The HDL Code Generation Settings button opens 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 subsystems inherits the model-level optimization settings. You can override these in the HDL Block Properties dialog box for the subsystem or by using the hdlset_param function.

  • 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.

OptimizationAvailable at Model LevelAvailable at Subsystem Level
RAM mappingYesNo
Adaptive pipeliningYesYes
Clock-rate pipeliningYesYes
Delay balancingNoYes
Distributed pipeliningYesYes
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.

StreamingNoYes

Some optimizations are applicable for individual blocks, such as adding pipelines at input or output ports.

Balance Pipeline Delays and Design Delays

Some block architectures and some optimizations introduce latency when you generate HDL code. Latencies introduced when you generate code are also known as pipeline delays. Pipeline delays introduced along the critical path in the generated model or in the generated HDL code can cause numerical calculation mismatches compared to original model during certain time steps because equivalent delays are not introduced on other, parallel signal paths. To match the numerical calculations at each time step between the original model and the generated model or HDL code, you can balance the introduced pipeline delays by inserting matching delays in parallel paths.

The delays that you add to your model by either manually adding Delay blocks or by using the Delay Balancing optimization are known as design delays. For more information on implementing design delays manually or by using the Delay Balancing optimization, see Understand Delay Balancing in HDL Coder.

See Also

Topics