Main Content

Specify Code Coverage Options

Simulink® Coverage™ provides three modes of code coverage analysis. For general coverage options, see Specify Coverage Options.

Models with S-Function Blocks

Configure an S-Function block for coverage based on how you created it. For more information, see Coverage for Custom C/C++ Code in Simulink Models.

Note

If you have software-in-the-loop or processor-in-the-loop blocks in your model, set the options described in Models with Software-in-the-Loop and Processor-in-the-Loop Mode Blocks.

Models with Software-in-the-Loop and Processor-in-the-Loop Mode Blocks

  1. Open the Configuration Parameters. In the Modeling tab, click Model Settings.

  2. Before setting code coverage options, on the Code Generation pane in the Configuration Parameters dialog box, set the System target file in the Target selection menu to ert.tlc.

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

  4. Select the code coverage tool from the Code coverage for SIL or PIL tab.

You can measure code coverage using these tools:

  • Simulink Coverage code coverage tool

  • BullseyeCoverage

  • LDRA TestBed

BullseyeCoverage and LDRA TestBed are third-party tools supported by Embedded Coder®. For more information on third-party code coverage tool support, see Code Coverage Tool Support (Embedded Coder). To set code coverage options, click Configure. If you select None (use Simulink Coverage) as the code coverage tool, the software opens the Coverage pane when you click Configure.

Using Simulink Coverage for code coverage means that you can analyze coverage results, justify missing coverage, and generate more test cases from within the Simulink environment.

Models with MATLAB Function Blocks

When you record coverage for models containing MATLAB® Function blocks, code coverage is recorded for the code within the MATLAB Function blocks. To include MATLAB Function blocks in your analysis:

  1. In the Simulink Editor, select Model Settings on the Modeling tab.

  2. In the Configuration Parameters dialog box, on the Coverage pane, under Include in analysis, select MATLAB files.

Related Topics