Specify Code Coverage Options
Simulink® Coverage™ provides three modes of code coverage analysis.
For general coverage options, see Specify Coverage Options.
Models with Custom C/C++ Code Blocks
You can collect code coverage for custom code blocks in your model, such as S-Functions and C Caller blocks. Simulink Coverage reports custom C/C++ code blocks in a code coverage report, even if you run your model in normal simulation mode.
You need to configure an S-Function block for coverage. For more information, see Coverage for Custom C/C++ Code in Simulink Models.
Models with Software-in-the-Loop and Processor-in-the-Loop Mode Blocks
You can collect code coverage for a model or model reference when you set the
Simulation mode parameter to
Software in the
Loop (SIL). There are a few configuration parameters that you must
set to allow coverage analysis of the generated code from your model:
In the Modeling tab, click Model Settings to open the Configuration Parameters dialog box.
In the Code Generation pane set the System target file in the Target selection section to
In the left pane, expand the Code Generation node. Select Verification.
In the Code coverage for SIL or PIL section, set Third-party tool to:
None (use Simulink Coverage)
LDRAcover or LDRA tool suite
BullseyeCoverage and the LDRA tool suite are third-party tools supported by Embedded Coder®. For more information about third-party code coverage tool support,
see Code Coverage Tool Support (Embedded Coder). To set code
coverage options, click Configure. If you set
Third-party tool to
None (use Simulink
Coverage), then clicking Configure opens
the Coverage pane.
Using Simulink Coverage for code coverage means that you can analyze coverage results, justify missing coverage, and generate test cases from within the Simulink environment.
Models with MATLAB Function Blocks
When you record coverage for models containing MATLAB® Function blocks, the model coverage report includes the MATLAB code inside a MATLAB function block, but a separate code coverage report reports the external MATLAB files called by the MATLAB Function block.
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, click Coverage. Under Include in analysis, select MATLAB files.