Main Content

代码覆盖率模型的Software-in-the-Loop (SIL) Mode and Processor-in-the-Loop (PIL) Mode

If you have Embedded Coder®and金宝app®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. Ensure you have a supported compiler installed. For a list of supported compilers, seeSupported and Compatible Compilers.

  2. In the Configuration Parameters dialog box, on the left pane, clickCode Generation. From the list, selectVerification.

  3. UnderCode profiling, setMeasure function execution timestoOff.

  4. UnderCode coverage for SIL or PIL, setThird-party tooltoNone (useSimulink Coverage).

  5. Enable coverage for a model in SIL or PIL mode or a reference model in SIL or PIL mode. For more information about enabling coverage, seeSpecify Coverage Options.

  6. Run a SIL or PIL simulation.

    Note

    TheCoverage (Run)button in the Coverage toolstrip forces a Normal mode simulation for the top-level model and does not yield SIL or PIL code coverage.

    To run a SIL or PIL simulation:

    1. In the Simulink window, clickAppsand then clickSIL/PIL Manager.

    2. In theSIL/PILtab, clickAutomated Verification > SIL/PIL Simulation Only.

    3. ClickRun SIL/PIL.

Review the Coverage Results for Models in SIL or PIL Mode

To view the code coverage information in the Code view, from the drop-down list to the right of the search box, selectShow code coverage. If the option is disabled, then on theCoveragetab, clickCoverage 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.

Code view showing generated code with coverage annotations. Labels point to coverage annotations, links to model elements, and a tooltip with coverage results.

At the bottom of the Code view, the coverage section shows a summary of the code coverage report.

Code coverage summary section of the Code view. Labels show the summary section and a tooltip with coverage details.

Limitations

Coverage for models in SIL and PIL mode has these limitations:

  • The model must meet the requirements listed inEnable SIL or PIL Code Coverage for a Model.

  • Code coverage results must not include external C/C++ files in read-only folders.

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

Related Topics