SIL/PIL Manager - Verify generated code - MATLAB (original) (raw)
Description
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, execution-time, and stack usage metrics.
- Enable your debugger for SIL simulations.
- Export automatically generated test cases for SimulinkĀ® Testā¢.
Open the SIL/PIL Manager App
On the Simulink toolstrip Apps tab, click SIL/PIL Manager. Or, on the Embedded Coder app C Code tab, click > .
Examples
- In the Command Window, enter:
openExample('ecoder/SILPILVerificationExample', ...
supportingFile='SILTopModel.slx')
The model opens in the Simulink Editor, with the SIL/PIL tab displayed. 2. SIL and PIL simulations do not support both code execution time profiling and code coverage analysis. For this example, disable code coverage:
In the Prepare section, clickSettings.
Under Coverage, click the Coverage Collection button off.
In the Run Automated Verification section, click Run Verification.
The SIL/PIL Manager runs these simulations back-to-back:SILTopModel
in normal modeSILTopModel
in SIL mode. As the Time Profiling controls are enabled, the SIL simulation also performs code execution profiling.
You can monitor simulation progress through the Diagnostic Viewer.
At the end of the second simulation:- The SIL/PIL Manager displays generated code in the Code view, which enables you to analyze generated code, see code metrics, and trace between model elements and generated code.
- 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.
To view the results in detail, open the Code Profile Analyzer by clicking the link.
In the Command Window, enter:
openExample('ecoder/SILPILVerificationExample', ...
supportingFile='SILTopModel.slx')
The model opens in the Simulink Editor, with the SIL/PIL tab displayed. 2. For this example, disable code execution time profiling and code coverage:
In the Prepare section, clickSettings.
Under Time Profiling, click the Task Profiling button and the Functions button off.
Under Coverage, click the Coverage Collection button off.
At the end of the second simulation:
- Check that the results from the model and generated code are numerically equivalent. In the Results gallery, under Numerical Equivalence Results, click Compare Runs orData Inspector.
- Export a test case for Simulink Test. Under Simulink Test, click Export to Test Manager. Then, in the Export SIL/PIL Test Cases dialog box, use the default settings, and click OK.
The SIL/PIL Manager:
* Creates the test case inSILTopModel_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).
In the Command Window, enter:
openExample('ecoder/SILPILVerificationExample', ...
supportingFile='SILTopModel.slx')
The model opens in the Simulink Editor, with the SIL/PIL tab displayed. 2. In the Mode section, select SIL/PIL Simulation Only. 3. In the Prepare section, open the Settings gallery:
- Under Time Profiling, click the Task Profiling button and Functions button off.
- Under Coverage, click the Coverage Collection button off.
- Under Stack Profiling, click the Stack Profiling button on.
- In the Run section, click Run SIL/PIL.
The SIL simulation streams stack usage data to the Simulation Data Inspector. When the simulation is complete, the SIL/PIL Manager opens a code stack profiling report for the model. - To examine the results in detail, use the Code Profile Analyzer. In theResults gallery, under Stack Profiling Results, click the Code Profile Analyzer button.
Related Examples
- SIL/PIL Manager Verification Workflow
- Choose a SIL or PIL Approach
- View and Compare Code Execution Times
- Code Coverage for Models in Software-in-the-Loop (SIL) Mode and Processor-in-the-Loop (PIL) Mode
- View and Compare Stack Usage Metrics
Version History
Introduced in R2019b