Main Content

Analyze Code Replacements in Generated Code

When you select the check box Summarize which blocks triggered code replacements for an ERT-based model, a Code Replacements Report section is automatically included in the generated HTML report. The Code Replacements Report section documents the SIMD instruction sets and code replacement library (CRL) functions that were used for code replacements during code generation, providing a mapping between each replacement instance and the Simulink® block that triggered the replacement. To enable display of the Simulink block information, select the Code Generation > Comments check box Include comments. On the same pane, select either the Simulink block comments checkbox or the Simulink block descriptions check box if present, or both.

You can use the report to:

  • Determine which replacement functions were used in the generated code.

  • Trace each replacement instance back to the block that triggered the replacement.

The figure below shows a Code Replacements Report generated for the CRL model CRLAdditionSubtraction. To open the model and generate the report, in the MATLAB® Command Window, enter:

openExample("CRLAdditionSubtraction");
set_param(bdroot,GenerateReport="on");
slbuild(bdroot);
In the Content section on the left, select Code Replacement Report. Each replacement function used is listed with a link to the block that triggered the replacement.

Code replacements report for CRLAdditionSubtraction model.

If you click a block path in the report, the block that triggered the replacement is highlighted in the model diagram. If the replacement was triggered by a Stateflow® chart or a MATLAB function, a window opens to display the chart or function.

For more information, see Verify Code Replacement Library.