Main Content

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, set Measure function execution times to Off.

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

  4. Enable coverage for a model in SIL or PIL mode or a reference model in SIL or PIL mode.

  5. Run a SIL or PIL simulation.

    Note

    The Coverage (Run) button in the Coverage toolstrip forces a Normal simulation and will not yield SIL or PIL code coverage.

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 (Simulink Coverage). 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.

Limitations

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.

  • The Coverage (Run) button in the Coverage toolstrip forces a Normal simulation and will not yield SIL or PIL code coverage.

Related Topics