Generate Incremental HDL Code for Referenced Models - MATLAB & Simulink (original) (raw)

Main Content

A model reference is a reference to another model using a Model block. You can use any model as a model reference, and you can continue to use the referenced model as a separate model. During simulation and code generation, the blocks in a referenced model execute together as a unit. The model that contains a referenced model is the parent model, and a collection of parents and referenced models constitutes a model hierarchy.

When HDL Coder Generates Incremental Code for Model References

HDL Coderâ„¢ generates the incremental code only if the referenced models have changed since the previous code generation. When generating code, the software compares structural checksums of referenced model files to the generated code files. HDL Coder generates incremental code for the model reference in the DUT subsystem when you set the Rebuild parameter in the Configuration Parameters dialog box under the Model Referencing pane to If changes detected or If changes in known dependencies detected. HDL Coder treats these two settings the same way. For both settings, model reference targets rebuild when:

Additionally, the model reference targets rebuild whenRebuild is If changes detected and the structural checksum has changed.

A structural checksum is a computation used to detect changes in the model that can affect simulation results. Changes that change the structural checksum include:

Examples of model changes that do not affect the structural checksum include:

For more information about structural checksums, see Simulink.BlockDiagram.getChecksum.

Generate Incremental Code for Referenced Models

This example shows how to generate incremental code for referenced models. For more information on converting an existing model to a referenced models using Model block, see Reference Existing Models

Open Model

In the mreference model, the DUT subsystem contains the parent models mparent1, mparent2, and mparent3. mparent1 references mchild1, mparent2 references mchild2, and mparent3 references mchild3. In this model, the Rebuild configuration parameter is If changes detected.

load_system('mreferencetop'); open_system('mreferencetop/DUT');

mreference/DUT Simulink model

Generate HDL Code

Generate the HDL code for the mreferencetop model by using the makehdl function. The code generation report shows that the code generator generated HDL code for the referenced models.

makehdl('mreferencetop/DUT');

Working on the model mreferencetop

Generating HDL for mreferencetop/DUT

Using the config set for model mreferencetop for HDL code generation parameters.

Running HDL checks on the model 'mreferencetop'.

Begin compilation of the model 'mreferencetop'...

Working on the model 'mchild1'...

Working on the model 'mchild2'...

Working on the model 'mchild3'...

Working on the model 'mreferencetop'...

Working on... GenerateModel

Begin model generation 'gm_mchild1'...

Model generation complete.

Generated model saved at hdlsrc\mreferencetop\mchild1\gm_mchild1.slx

Begin model generation 'gm_mchild2'...

Model generation complete.

Generated model saved at hdlsrc\mreferencetop\mchild2\gm_mchild2.slx

Begin model generation 'gm_mchild3'...

Model generation complete.

Generated model saved at hdlsrc\mreferencetop\mchild3\gm_mchild3.slx

Begin model generation 'gm_mreferencetop'...

Model generation complete.

Generated model saved at hdlsrc\mreferencetop\gm_mreferencetop.slx

Begin VHDL Code Generation for 'mchild1'.

Begin VHDL Code Generation for 'mchild2'.

Begin VHDL Code Generation for 'mchild3'.

Begin VHDL Code Generation for 'mreferencetop'.

Working on mchild1 as hdlsrc\mreferencetop\mchild1\mchild1_mchild1.vhd.

Code Generation for 'mchild1' completed.

Generating HTML files for code generation report at index.html

Working on mchild2 as hdlsrc\mreferencetop\mchild2\mchild2_mchild2.vhd.

Generating package file hdlsrc\mreferencetop\mchild2\mchild2_mchild2_pkg.vhd.

Code Generation for 'mchild2' completed.

Generating HTML files for code generation report at index.html

Working on mchild3 as hdlsrc\mreferencetop\mchild3\mchild3_mchild3.vhd.

Generating package file hdlsrc\mreferencetop\mchild3\mchild3_mchild3_pkg.vhd.

Code Generation for 'mchild3' completed.

Generating HTML files for code generation report at index.html

Working on mreferencetop/DUT as hdlsrc\mreferencetop\DUT.vhd.

Code Generation for 'mreferencetop' completed.

Generating HTML files for code generation report at index.html

Creating HDL Code Generation Check Report mchild1_report.html

HDL check for 'mchild1' complete with 0 errors, 0 warnings, and 0 messages.

Creating HDL Code Generation Check Report mchild2_report.html

HDL check for 'mchild2' complete with 0 errors, 0 warnings, and 0 messages.

Creating HDL Code Generation Check Report mchild3_report.html

HDL check for 'mchild3' complete with 0 errors, 0 warnings, and 0 messages.

Creating HDL Code Generation Check Report DUT_report.html

HDL check for 'mreferencetop' complete with 0 errors, 0 warnings, and 0 messages.

HDL code generation complete.

Modify the Model Reference

Change the DelayLength HDL block parameter of the Delay block in the mchild3 model to a value of 5.

open_system('mchild3'); set_param('mchild3/Delay','DelayLength','5'); save_system('mchild3');

Generate HDL code for the mparent model. The code generation report shows that the code generator generated HDL code only for the mchild3 referenced model. Because there are no changes in the other models, it does not generate HDL code for them.

makehdl('mreferencetop/DUT');

Working on the model mreferencetop

Generating HDL for mreferencetop/DUT

Using the config set for model mreferencetop for HDL code generation parameters.

Running HDL checks on the model 'mreferencetop'.

Begin compilation of the model 'mreferencetop'...

Working on the model 'mchild1'...

Working on the model 'mchild2'...

Working on the model 'mchild3'...

Working on the model 'mreferencetop'...

Working on... GenerateModel

Begin model generation 'gm_mchild3'...

Model generation complete.

Generated model saved at hdlsrc\mreferencetop\mchild3\gm_mchild3.slx

Begin model generation 'gm_mreferencetop'...

Model generation complete.

Generated model saved at hdlsrc\mreferencetop\gm_mreferencetop.slx

Begin VHDL Code Generation for 'mchild1'.

Begin VHDL Code Generation for 'mchild2'.

Begin VHDL Code Generation for 'mchild3'.

Begin VHDL Code Generation for 'mreferencetop'.

Did not generate code for mchild1, because no functional changes were found or the Rebuild parameter on the Model Referencing pane of the Configuration Parameters dialog box was set to Never.

mchild1_mchild1.vhd

Generating HTML files for code generation report at index.html

Did not generate code for mchild2, because no functional changes were found or the Rebuild parameter on the Model Referencing pane of the Configuration Parameters dialog box was set to Never.

mchild2_mchild2_pkg.vhd

mchild2_mchild2.vhd

Generating HTML files for code generation report at index.html

Working on mchild3 as hdlsrc\mreferencetop\mchild3\mchild3_mchild3.vhd.

Generating package file hdlsrc\mreferencetop\mchild3\mchild3_mchild3_pkg.vhd.

Code Generation for 'mchild3' completed.

Generating HTML files for code generation report at index.html

Working on mreferencetop/DUT as hdlsrc\mreferencetop\DUT.vhd.

Code Generation for 'mreferencetop' completed.

Generating HTML files for code generation report at index.html

Creating HDL Code Generation Check Report mchild1_report.html

HDL check for 'mchild1' complete with 0 errors, 0 warnings, and 0 messages.

Creating HDL Code Generation Check Report mchild2_report.html

HDL check for 'mchild2' complete with 0 errors, 0 warnings, and 0 messages.

Creating HDL Code Generation Check Report mchild3_report.html

HDL check for 'mchild3' complete with 0 errors, 0 warnings, and 0 messages.

Creating HDL Code Generation Check Report DUT_report.html

HDL check for 'mreferencetop' complete with 0 errors, 0 warnings, and 0 messages.

HDL code generation complete.

See Also

Rebuild

Topics