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金宝app®Test™.
On the Simulink toolstripAppstab, clickSIL/PIL Manager. Or, on the Embedded Coder appC Codetab, clickVerify Code>SIL/PIL Manager.
In the Command Window, enterrtwdemo_sil_topmodel
.
To open the SIL/PIL Manager, on theAppstab, clickSIL/PIL Manager.
On theSIL/PILtab, use the supplied settings.
In theRun Automated Verification部分中,点击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 theCoverage CollectionandProfile Codecontrols are enabled, the SIL simulation also performs code coverage analysis and code execution profiling. For code coverage, you requireSimulink 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 theCoveragetab. To display code coverage analysis results, in theReview Results部分中,点击Coverage Details. To view coverage metrics for a specific block, in the model view, click the block, which is colored red.
If you haveSimulink Test, you can export a numeric equivalence test case:
In the Command Window, enterrtwdemo_sil_modelblock
.
To open the SIL/PIL Manager, on theAppstab, clickSIL/PIL Manager.
On theSIL/PILtab, use the supplied settings.
Open theResultsgallery. In theResults部分中,点击eitherCompare RunsorData Inspector.
UnderSimulink Test, clickExport to Test Manager.
In the Export SIL/PIL Test Cases dialog box, use the default settings, and clickOK.
The SIL/PIL Manager:
Creates the test case inrtwdemo_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 inSimulink Test, seeImport Test Cases for Equivalence Testing(Simulink Test).