Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Creating and Using Coverage Filters

This example shows how to use Simulink® Verification and Validation™ model coverage filters to exclude model items from coverage recording and justify missing coverage in reports.

Coverage Filters

In the verification process, a model can contain several constructs that prevent full model coverage, such as a subsystem that contains some driver for a controller that is not tested and is not relevant to the validation process. Filtering these constructs from coverage recording and reporting allows you to focus on other aspects of missing coverage that can and should be tested.

Coverage filters are stored in .cvf files. Filter files can span multiple models. Each filter consists of rules that define model objects that will be excluded or justified in the coverage results. You can filter any model object that receives coverage or contains other items, such as a subsystem.

Coverage filters can be created and applied either before or after simulating a model. Both workflows are described in this example.

Open Model

This example makes use of the model slvnvdemo_covfilt. The model shows some common patterns that might need to be filtered from coverage recording and reporting.

Open the model to begin.

Filter a Specific Block Before Simulation

In the slvnvdemo_covfilt model, the Saturation block has a lower limit of 0 and an upper limit of 200. The input to this block is the rate signal, which can never be less than or equal to 0. This will lead to missing coverage, as the lower limit of the Saturation block is not fully exercised. As such, exclude the Saturation block from coverage.

In the Simulink Editor, right-click the Saturation block and select Coverage > Exclude this block.

The list of current filter rules shows in the Coverage Results Explorer. Click in the Rationale field for this new rule and enter text describing why this block is excluded, such as "Input never <= lower limit (0)". Click Apply when finished.

Filter Based on Library Reference

The library block slvnvdemo_covfilt_lib/protected division is a protection against division by zero and might be irrelevant in the coverage report. The right-click context menu on this block provides options for filtering the specific instance of the library or all references to this library. Select Exclude referenced library: slvnvdemo_covfilt_lib/protected division.

Under the Filter tab of the Coverage Results Explorer, enter the Rationale for this rule, such as "division by zero protection". Click Apply when finished.

Filter an Event in Stateflow®

Generally, filter rules eliminate an entire block or Stateflow® object from coverage recording. Stateflow® events are an exception where you can eliminate coverage for part of the transition and record coverage for the remainder of the transition.

In this example, there is a transition that defines the temporal event tick that is never false, preventing full condition and MCDC coverage.

To exclude temporal event tick, select Coverage > Exclude temporal event 'tick' in the right-click context menu of this transition.

Under the Filter tab of the Coverage Results Explorer, enter the Rationale for this rule, such as "tick". Click Apply when finished.

Simulate and Review Filtered Coverage Results

Simulate the model. The Coverage Results Explorer will open when the simulation completes. Click the Generate report link to create and open a coverage report for this run.

The coverage report shows a section titled Objects Filtered from Coverage Analysis listing each of the excluded elements and their corresponding rationales. The coverage results exclude these elements.

Filter a Subsystem After Simulation

In certain cases, you may have an expectation that certain items in a model will not achieve full coverage. You therefore filter these items before simulating for coverage, as was done in the previous sections of this example. You can also create and apply a filter to coverage results after simulation. This allows you to review coverage results, create or adjust a filter as desired, and generate a new coverage report using this filter without having to rerun the simulation.

Consider, for example, the subsystem Switchable config. Using constant values to drive subsystem enable ports for changing model configurations is a common pattern in designs; however, the enable logic and subsystem contents might lead to missing coverage. This configuration is not used in this model, so add the Switchable config subsystem to the coverage filter.

In the Simulink Editor, right-click the Switchable config subsystem and select Coverage > Exclude subsystem with all descendants.

Under the Filter tab of the Coverage Results Explorer, enter the Rationale for this rule, such as "unused config". Click Apply when finished.

Filter a Stateflow® Transition from the Coverage Report

In the coverage report, navigate to the detailed results for Stateflow® Transition "[!on]" from Junction #0 to "off" under the chart Mode Logic. This transition is never false because it only evaluates when Transition "[on]" from Junction #0 to "on" is false.

As an alternative to navigating back to the model and filtering this transition via the right-click context menu, you can filter this item directly from the report.

Click the Justify or Exclude link under the detailed results for this transition.

The Filter tab of the Coverage Results Explorer opens, and the rule filtering this transition is added.

Change the filtering Mode for this rule to Justified and enter a description for the Rationale, such as "expression can't be false". Click Apply when finished.

Justify Individual Objective Outcome from the Coverage Report

In the previous examples, all of the objectives associated with the specified model objects were filtered. You can also justify individual coverage objective outcomes directly from the report. This allows for more granularity in defining justification rules.

In the coverage report, navigate to the detailed results for Stateflow® Transition "[high]" from Junction #3 to Junction #4 under the chart Mode Logic. This transition is currently never executed, and therefore neither the false nor the true decision coverage objective outcomes are satisfied.

Click the Add justification rule icon next to the false outcome to justify this individual objective outcome.

The Filter tab of the Coverage Results Explorer opens, and the rule filtering this objective outcome is added.

Enter a description for the Rationale, such as "justify false outcome only". Click Apply when finished.

Generate Updated Coverage Report

After clicking Apply, the Generate report link shows at the bottom of the dialog. Click this link to regenerate the report with the updated coverage filter.

The new coverage report lists all of the excluded and justified elements under Objects Filtered from Coverage Analysis, including those elements that were filtered after simulation. The links in the Rationale column navigate to the corresponding rules in the Filter tab of the Coverage Results Explorer. Additionally, the justified model objects are preceded by an identifier (for example, J6 and J7 in the report below), each of which links to the detailed results for the justified model object or objective outcome.

The justified objectives are colored in light blue and are treated as satisfied when reporting coverage percentages.

The detailed results for Transition "[!on]" from Junction #0 to "off" show that missing coverage for this transition has been justified. Note that the link Justified J6 navigates to the corresponding justification rule in the Objects Filtered from Coverage Analysis section of the report.

Similarly, the detailed results for Transition "[high]" from Junction #3 to Junction #4 show that missing coverage for the false decision outcome has been justified. However, because a justification rule was created only for this individual outcome, the true decision outcome is still reported as unsatisfied. Note that the link J7 shown next to the false decision outcome navigates to the corresponding justification rule in the Objects Filtered from Coverage Analysis section of the report.

Clean Up

To complete the example, close the model.

Was this topic helpful?