Simulink® Coverage™ provides three modes of code coverage analysis. For general coverage options, see Specify Coverage Options.
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.
Open the Configuration Parameters. In the Modeling tab, click Model Settings.
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
.
In the Configuration Parameters dialog box, on the left pane, click Code Generation. From the list, select Verification.
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.
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:
In the Simulink Editor, select Model Settings on the Modeling tab.
In the Configuration Parameters dialog box, on the Coverage pane, under Include in analysis, select MATLAB files.