Documentation

Specify Model Coverage Options

Before starting a model coverage analysis, you specify several model coverage recording options. In the Simulink® Editor, select Analysis > Coverage > Settings.

Coverage Pane

On the Coverage pane in the Configuration Parameters dialog box, set the options for the model coverage calculated during simulation.

Enable coverage analysis

Gather specified coverage results during simulation and report the model coverage. When you select Enable coverage analysis, these sections become available:

Scope of analysis

Specifies the systems for which the software gathers and reports coverage data. The options are:

You must select Enable coverage analysis to specify the scope of analysis.

Entire System

By default, generates coverage data for the entire system. The coverage results include the top-level model and all supported subsystems and model references.

Referenced Models

Coverage analysis records the model coverages for the referenced models that you select. By default, generates coverage data for all referenced models where the simulation mode of the Model block is set to Normal, Software-in-the-loop (SIL), or Processor-in-the-loop (PIL).

To specify the referenced models for which the Simulink Verification and Validation™ software records coverage data:

  1. In the Configuration Parameters dialog box, on the Coverage pane, select Enable coverage analysis.

  2. Click Select Models.

  3. In the Select Models for Coverage Analysis dialog box, select the referenced models for which you want to record coverage. You can also select the top-level model.

    The icon next to the model name indicates the simulation mode for that referenced model. You can select only referenced models whose simulation mode is set to Normal, SIL, or PIL.

    If you have multiple Model blocks that reference the same model and whose simulation modes are the same, selecting the check box for that model selects the check boxes for all instances of that model with the same simulation mode.

  4. To close the Select Models for Coverage Analysis dialog box and return to the Configuration Parameters dialog box, click OK.

Subsystem

Coverage analysis records model coverage during simulation for the subsystem that you select. By default, generates coverage data for the entire model. To restrict coverage reporting to a particular subsystem:

  1. In the Configuration Parameters dialog box, on the Coverage pane, select Enable coverage analysis.

  2. Click Select Subsystem.

  3. In the Subsystem Selection dialog box, select the subsystem for which you want to enable coverage reporting and click OK.

Include in analysis

The Include in analysis section contains two options:

  • MATLAB files enables coverage for any external functions called by MATLAB® functions in your model. You can define MATLAB functions in MATLAB Function blocks or in Stateflow® charts.

    To select the Coverage for MATLAB files option, you must select Enable coverage analysis.

  • C/C++ S-functions enables coverage for C/C++ S-Function blocks in your model. Coverage metrics are reported for the S-Function blocks and the C/C++ code in those blocks. For more information, see Generate Coverage Report for S-Function.

    You must select Enable coverage analysis to select the Coverage for S-Functions option.

Coverage metrics

Select the structural coverage level and other types of test case coverage analysis that you want the tool to perform (see Types of Model Coverage). The Simulink Verification and Validation software gathers and reports those types of coverage for the subsystems, models, and referenced models that you specify.

The structural coverage levels are listed in order of strictness of test case coverage analysis:

Coverage metrics also includes Other metrics:

You must select Enable coverage analysis to select the coverage metrics.

Advanced options

Advanced options for model coverage collection:

Treat Simulink logic blocks as short-circuited

Applies only to condition and MCDC coverage. If you select this option, coverage analysis treats Simulink logic blocks as if the block ignores remaining inputs when the previous inputs alone determine the block output. For example, if the first input to a Logical Operator block whose Operator parameter specifies AND is false, MCDC coverage analysis ignores the values of the other inputs when determining MCDC coverage for a test case.

    Note:   If you disable this option, Simulink Verification and Validation does not combine logic block cascades for MCDC coverage. Instead, Simulink Verification and Validation analyses each block individually for MCDC coverage. For more information, see Analyzing MCDC for Cascaded Logic Blocks.

If you select this option and logic blocks are short-circuited while collecting model coverage, it is possible that you are not able to achieve 100% coverage for that block.

Select this option for where you want the MCDC coverage analysis to approximate the degree of coverage that your test cases achieve for the generated code (most high-level languages short-circuit logic expressions).

    Note:   Some test cases that do not achieve full MCDC coverage for non-short-circuited logic expressions do achieve full coverage for short-circuited expressions.

Warn when unsupported blocks exist in model

If the model contains blocks that require coverage analysis but are not currently covered by the tool, provides a warning at the end of the simulation.

Force block reduction off

To achieve faster execution during model simulation and in generated code, in the Configuration Parameters dialog box, on the All Parameters tab, select the Block reduction parameter. The Simulink software collapses certain groups of blocks into a single, more efficient block, or removes them entirely.

One of the model coverage options, Force block reduction off, allows you to ignore the Block reduction parameter when collecting model coverage.

If you do not enable the Block reduction parameter, or if you select Force block reduction off, the Simulink Verification and Validation software provides coverage data for every block in the model that collects coverage.

If you select the Block reduction parameter and do not set Force block reduction off, the coverage report lists the reduced blocks that do not receive coverage analysis.

The model coverage report identifies any reduced blocks. For an example of a reduced blocks report, see Block Reduction.

Restrict recording to interval

To record model coverage only inside a specified simulation time interval, select Restrict recording to interval and define a Start time and Stop time. Model coverage is not recorded for simulation times outside Start time and Stop time. If your simulation starts at a time greater than or equal to Stop time, model coverage is not recorded.

For example, you might want to restrict model coverage recording if your model has transient effects early in simulation, or if you need model coverage reported only for a particular model operation.

Results Pane

On the Coverage > Results pane in the Configuration Parameters dialog box, select the destination for model coverage results. You must select Enable coverage analysis on the Coverage pane to set the Coverage > Results pane options.

Show Results Explorer

After simulation, shows the results explorer.

Display coverage results using model coloring

After simulation, colors model objects according to their level of coverage. Objects highlighted in light green receive full coverage during testing. Objects highlighted in light red receive incomplete coverage. See View Coverage Results in a Model.

Generate report automatically after analysis

Specifies whether to open a generated HTML coverage report in a MATLAB browser window at the end of model simulation.

Save last run in workspace variable

Saves the results of the last simulation run in a cvdata object in the workspace. Specify the workspace variable name in cvdata object name.

cvdata object name

Name of the workspace variable where the results of the last simulation run are saved. You must select Save last run in workspace variable to specify the cvdata object name.

Increment variable name with each simulation (var1, var2, ...)

Appends numerals to the workspace variable names for each new result so that earlier results are not overwritten. You must select Save last run in workspace variable to enable this option.

Autosave data file name

Name of file to which coverage data results are saved. The default name is $ModelName$_cvdata. $ModelName$ is the name of the model.

Output directory

The folder where the coverage data is saved. The default location is slcov_output/$ModelName$ in the current folder. $ModelName$ is the name of the model.

Related Examples

Was this topic helpful?