Code Coverage for Models in Software-in-the-Loop (SIL) Mode and Processor-in-the-Loop (PIL) Mode

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.

Enable SIL or PIL Code Coverage for a Model

To record SIL or PIL code coverage for a model:

  1. In the Configuration Parameters dialog box, on the left pane, click Code Generation. From the list, select Verification.

  2. Under Code profiling, from the Measure function execution times list, select Off.

  3. Under Code coverage for SIL or PIL, for the Third-party tool select None (use Simulink Coverage).

Simulink Coverage Code Coverage Measurement Workflows

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 RecordCoverage. Simulink Coverage also measures code coverage for referenced models, depending on CovModelRefEnable.

  • The top model is in Normal mode and contains at least one reference model in SIL or PIL mode. Simulink Coverage measures code coverage for the referenced model if CovModelRefEnable is 'on', 'all', or 'filtered' and RecordCoverage is 'off'.

Review the Coverage Results for Models in SIL or PIL Mode

Code Coverage Report

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.

Code View

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:

Related Topics