Main Content

Use Distributed Pipelining Optimization in Models with MATLAB Function Blocks

This example shows how to optimize the generated HDL code for MATLAB Function blocks by using the distributed pipelining optimization. Distributed pipelining is an HDL Coder™ optimization that improves the generated HDL code from MATLAB Function blocks, Simulink® models, or Stateflow® charts. By using distributed pipelining, your design achieves higher clock rates on the FPGA device. For more information, seeDistributed Pipelining

Open Multiplier Chain Model

This example shows how to distribute pipeline registers in a model that chains five multiplications.

TheHDL_DUTsubsystem is the DUT for which you want to generate HDL code. The subsystem drives a MATLAB Function blockmult_chain

To see the chain of multiplications, open the MATLAB Function block. The block contains this MATLAB code:

functiony = fcn(x1,x2,x3,x4,x5,x6,x7,x8)% A chained multiplication:% y = (x1*x2)*(x3*x4)*(x5*x6)*(x7*x8)
y1 = x1 * x2; y2 = x3 * x4; y3 = x5 * x6; y4 = x7 * x8;
y5 = y1 * y2; y6 = y3 * y4;
y = y5 * y6;

Apply Distributed Pipelining Optimization

1. Specify generation of two pipeline stages for the MATLAB Function block. Right-click themult_chainMATLAB Function block. SelectHDL Code>HDL Block Properties.In the HDL Properties window, setOutputPipelineto2

2. SetArchitecturetoMATLAB Datapath.这种架构将鼓风机的MATLAB函数ck like a regular subsystem. You can then apply various HDL Coder optimizations on MATLAB Function blocks along with other blocks in your Simulink model.

3. To enable the distributed pipelining optimization across hierarchies in your model, in the Configuration Parameters dialog box, clickHDL Code Generation>Optimization.Click thePipeliningtab, then select the model configuration parameterDistributed pipelining

4. To see the results of the optimization in the code generation report, clickHDL Code Generation>Report.Then, enable the parameterGenerate optimization report

5. Optionally, when you use the MATLAB datapath architecture for a MATLAB Function block, you can enable synthesis timing estimates for distributed pipelining. Synthesis timing estimates calculate the propagation delays of the components in your design for distributed pipelining. Using this parameter, you can more accurately reflect how components function on hardware to better distribute pipelines in your design and maximize the clock frequency for your specific target device. For more information, seeDistributed Pipelining Using Synthesis Timing Estimates

To enable synthesis timing estimates, clickHDL Code Generation>Optimization, then select thePipeliningtab. Enable theUse synthesis estimates for distributed pipeliningparameter.

6. Generate HDL Code for theHDL_DUTsubsystem. In theAppstab, clickHDL Coder.In theHDL Codetab, clickGenerate HDL Code

By default, HDL Coder generates VHDL code in thehdlsrcfolder.

Analyze Results of Optimization

In the Code Generation Report window, in theDistributed Pipeliningsection, you see that the code generator moved the pipeline registers. To see the effects of the optimization, open the generated modelgm_hdlcoder_distpipe_multiplier_chainand navigate to theHDL_DUTsubsystem.

The MATLAB datapath architecture replaces the MATLAB Function block with a subsystem. The optimization can then distribute the pipeline registers and the unit delay inside the subsystem to optimize the multiplier chain and improve timing. Open themult_chainsubsystem to view this optimization.

See Also

||

Related Topics