Verify generated code
The SIL/PIL Manager simplifies verification of code that you generate from a model.
You can:
With one click, test numeric equivalence between the model and generated code by running back-to-back model simulations and software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulations.
Configure SIL or PIL simulations to produce code coverage and execution-time profiling metrics.
Enable your debugger for SIL simulations.
Export automatically generated test cases for Simulink® Test™.
On the Simulink toolstrip Apps tab, click SIL/PIL Manager. Or, on the Embedded Coder app C Code tab, click Verify Code > SIL/PIL Manager.
In the Command Window, enter rtwdemo_sil_topmodel
.
To open the SIL/PIL Manager, on the Apps tab, click SIL/PIL Manager.
On the SIL/PIL tab, use the supplied settings.
In the Run Automated Verification section, click Run Verification.
The SIL/PIL Manager runs these simulations back-to-back:
rtwdemo_sil_topmodel
in normal mode
rtwdemo_sil_topmodel
in SIL mode. As the Coverage
Collection and Profile Code controls are
enabled, the SIL simulation also performs code coverage analysis and code
execution profiling. For code coverage, you require Simulink
Coverage™.
You can monitor simulation progress through the Diagnostic Viewer.
At the end of the second simulation:
The Simulation Data Inspector compares results from the model against results from generated code.
To view execution-time metrics, in the model view, click the blue region.
The Simulink Editor displays the Coverage tab. To display code coverage analysis results, in the Review Results section, click Coverage Details. To view coverage metrics for a specific block, in the model view, click the block, which is colored red.
If you have Simulink Test, you can export a numeric equivalence test case:
In the Command Window, enter rtwdemo_sil_modelblock
.
To open the SIL/PIL Manager, on the Apps tab, click SIL/PIL Manager.
On the SIL/PIL tab, use the supplied settings.
Open the Results gallery. In the Results section, click either Compare Runs or Data Inspector.
Under Simulink Test, click Export to Test Manager.
In the Export SIL/PIL Test Cases dialog box, use the default settings, and click OK.
The SIL/PIL Manager:
Creates the test case in rtwdemo_sil_topmodel_TestFile.mldatx
,
which you can find in the current working folder.
Opens the test file that contains the test case.
For information about running test cases in Simulink Test, see Import Test Cases for Equivalence Testing (Simulink Test).