Specify Model Coverage Options

Before starting a model coverage analysis, you must specify several model coverage recording and reporting options. In the Simulink® Editor, select Analysis > Coverage > Settings. The Coverage Settings dialog box opens, with the Coverage tab displayed.

The following sections describe the settings for each tab in the Coverage Settings dialog box.

Coverage Tab

On the Coverage tab, select the model coverages calculated during simulation.

Coverage for this model

Instructs the software to gather and report the model coverages that you specify during simulation. When you select the Coverage for this model option, the Select Subsystem button and the Coverage metrics section of the Coverage pane become available.

Select Subsystem

Specifies the subsystem for which the software gathers and reports coverage data. When you select the Coverage for this model option, the software, by default, generates coverage data for the entire model.

To restrict coverage reporting to a particular subsystem:

  1. On the Coverage tab, click Select Subsystem.

    The Subsystem Selection dialog box opens.

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

Coverage for referenced models

Causes the software to record and report the model coverages that you specify for referenced models during simulation. When you select the Coverage for referenced models option, the Select Models button and the Coverage metrics section of the Coverage tab become available.

Select Models

Click to specify the referenced models for which the Simulink Verification and Validation™ software records and reports coverage data. When you select Coverage for referenced models, the software, by default, generates coverage data for all referenced models where the simulation mode of the Model block is set to Normal.

To enable coverage reporting for particular referenced models:

  1. On the Coverage pane, click Select Models.

  2. In the Select Models for Coverage Analysis dialog box, select the referenced models for which you want to record coverage.

    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.

    If you have multiple Model blocks that reference the same model and whose simulation mode is set to Normal, selecting or clearing one check box for that model causes the check boxes for all Normal mode instances of that model to be selected or cleared.

  3. Click OK to close the Select Models for Coverage Analysis dialog box and return to the Coverage Settings dialog box.

Coverage for MATLAB files

Enables coverage for any external functions called by MATLAB® functions in your model. The MATLAB functions may be defined in a MATLAB Function block or in a Stateflow® chart.

You must select either Coverage for this model or Coverage for referenced models to select the Coverage for MATLAB files option.

Coverage metrics

Select the 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 you specify.

Results Tab

On the Results tab, select the destination for model coverage results.

Enable cumulative data collection

Accumulates model coverage results from successive simulations. Select this and Save cumulative results in workspace variable to collect model coverage results for multiple simulations in one cvdata object. For more information, see Cumulative Coverage Data.

Clear data

Removes existing internal cumulative coverage data. If cumulative coverage data is saved in a workspace variable, rename that workspace variable to avoid overwriting it in future simulations.

Save cumulative results in workspace variable

Accumulates and saves the results of successive simulations in a cvdata object in the workspace. Specify the workspace variable name in the cvdata object name field. For more information, see Cumulative Coverage Data.

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 the cvdata object name field.

Increment variable name with each simulation

Increments the name of the coverage data object variable that saves the coverage data from each last simulation run. Therefore the current simulation run does not overwrite the results of the previous run.

Update results on pause

Records results up to the point at which you pause the simulation for the first time. When you resume simulation and later pause or stop, the model coverage report reappears, with coverage results up to the current pause or stop time.

Display coverage results using model coloring

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

Reporting Tab

On the Reporting tab, specify whether the model coverage tool generates an HTML report and what data the report includes.

Generate report

Creates an HTML report containing the coverage data collected from simulation. Click the Settings button to select various reporting options.

Show report

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

Settings

On the Reporting tab, for Detailed Report, click Settings to open the Settings dialog box. In the Settings dialog box, choose model coverage report options.

OptionDescription

Include each test in the model summary

At the top of the HTML report, the model hierarchy table includes columns listing the coverage metrics for each test. If you do not select this option, the model summary reports only the total coverage.

Produce bar graphs in the model summary

Causes the model summary to include a bar graph for each coverage result for a visual representation of the coverage.

Use two color bar graphs (red, blue)

Red and blue bar graphs are displayed in the report instead of black and white bar graphs.

Do not report fully covered model objects

The coverage report includes only model objects that the simulation does not cover fully, useful when developing tests, because it reduces the size of the generated reports.

Display hit/count ratio in the model summary

Reports coverage numbers as both a percentage and a ratio, for example, 67% (8/12).

Include cyclomatic complexity numbers in summary

Includes the cyclomatic complexity (see Types of Model Coverage) of the model and its top-level subsystems and charts in the report summary. A cyclomatic complexity number shown in boldface indicates that the analysis considered the subsystem itself to be an object when computing its complexity. This occurs for atomic and conditionally executed subsystems, as well as for Stateflow Chart blocks.

Include cyclomatic complexity numbers in block details

Includes the cyclomatic complexity metric in the block details section of the report.

Filter Stateflow events from report

Excludes coverage data on Stateflow events.

Cumulative data

Include model coverage results from successive simulations in the report. For more information, see Cumulative Coverage Data.

Last run

Include in the report only the results of the most recent simulation run.

Additional data to include in report

Specify names of coverage data objects from previous runs to include in the current report along with the current coverage data. Each entry creates a new set of columns in the report.

Options Tab

On the Options tab, select options for model coverage reports.

Treat Simulink logic blocks as short-circuited

The Treat Simulink logic blocks as short-circuited option 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's 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.

If you enable this feature and logic blocks are short-circuited while collecting model coverage, you may not be able to achieve 100% coverage for that block.

To generate code from a model, select this option. Also 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:   A test case that does not achieve full MCDC coverage for non-short-circuited logic expressions might achieve full coverage for short-circuited expressions.

Warn when unsupported blocks exist in model

Select this option to warn you at the end of the simulation that the model contains blocks that require coverage analysis but are not currently covered by the tool.

Force block reduction off

To achieve faster execution during model simulation and in generated code, in the Configuration Parameters dialog box, on the Optimization pane, enable 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 enable the Block reduction parameter and do not set Force block reduction off, the coverage report lists the reduced blocks that would have collected coverage.

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, check 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.

Boundary Tolerance — Absolute

Specify the value of absolute tolerance for relational boundary coverage of floating point inputs. For more information, see Relational Boundary Coverage.

Boundary Tolerance — Relative

Specify the value of relative tolerance for relational boundary coverage of floating point inputs. For more information, see Relational Boundary Coverage.

Filter Tab

On the Filter tab, enter the file name that specifies the model objects to be excluded from model coverage collection. You can use the same filter file for multiple models.

Filename

If you enable coverage for this model, you can create a filter file or open an existing filter file. In this filter file, you can then specify objects that you want to exclude from model coverage collection during simulation.

In the Filename field, enter the full path to the file that specifies the model objects to be excluded from model coverage collection. You can also click Browse to navigate to the file. You can only open files that have the valid .cvf filter file format.

If the current model has a filter file already associated with it, the file name appears in the Filename field, and the Open in Filter Viewer link is displayed. To edit the coverage filter settings, click this link.

If the Open in Filter Viewer link is unavailable, go to the Coverage tab. Select Coverage for this model to enable coverage for the current model. You can then enter the filter file name and edit the file.

For more information on coverage filtering, see Coverage Filter Rules and Files and the example Filter Model Objects to Refine Coverage Results.

Was this topic helpful?