If you have Embedded Coder® and Simulink® Coverage™, you can analyze coverage for generated code during a software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation.
To record SIL or PIL code coverage for a model:
In the Configuration Parameters dialog box, on the left pane, click Code Generation. From the list, select Verification.
Under Code profiling, from the Measure function
execution times list, select
Under Code coverage for SIL or PIL, for the
Third-party tool select
None (use Simulink
To measure code coverage, use either of these workflows:
The top model is in SIL mode or PIL mode. Simulink
Coverage measures code coverage for the top model, depending on
Coverage also measures code coverage for referenced models, depending on
The top model is in Normal mode and contains at least one reference model in SIL or PIL mode.
Coverage measures code coverage for the referenced model if
In the code coverage report, each hyperlink opens a report with more details on the coverage analysis for the model. The code coverage results in these reports are similar to the coverage results for C/C++ code in S-function blocks, as described in View Coverage Results for Custom C/C++ Code in S-Function Blocks. You can navigate from code coverage results to the associated model blocks by using the links within the detailed code coverage reports.
Each detailed code coverage report also contains syntax highlighted code with coverage information.
To view the code coverage information in the Code view, from the drop-down list to the right of the search box, select Show code coverage. If the option is disabled, then on the Coverage tab, click Coverage Highlighting. The code displays highlighting and annotations that show code coverage information. You can navigate from the code to the associated model blocks by using the links in the line numbers, code elements, and comments.
At the bottom of the Code view, the coverage section shows a summary of the code coverage report.
Coverage for models in SIL and PIL mode has these limitations:
The model must meet the requirements listed in Enable SIL or PIL Code Coverage for a Model.
Code coverage results must not include external C/C++ files in read-only folders.