Simulink Verification and Validation
This example shows how to use Simulink® Verification and Validation™ model coverage filters to exclude model items from coverage recording and reporting.
In the verification process, a model can contain several constructs that prevent full model coverage, e.g., a subsystem contains some driver for a controller that is not tested and not interesting in a validation process. Filtering these constructs from coverage recording 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 from coverage. Rules are created from the context menu on the model object to which they apply. You can filter any model object that receives coverage or contains other items such as a subsystem. Coverage filter files are associated with a model through the model's coverage settings or as an attribute of a
The Filter Viewer opens, where you can add a rationale to the filtered object.
Filtering Events 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. In this example, there is a transition that defines the temporal event
tick that is never false, preventing full condition and MCDC coverage. You can addadd this condition to the filter, and as a result all the conditions and MCDC metrics will be eliminated from the coverage report. To exclude temporal event
tick select Coverage > Exclude temporal event 'tick' in the right-click context menu of this transition. You will see this item is added to the filter editor with a rationale.
Filtering Based on Library Reference
In this example, you also add the library
slvnvdemo_covfilt_lib/protected division to the filter, which is a protection against division by zero and might be irrelevant in the coverage report. The right-click context menu on
slvnvdemo_covfilt/protected division block provides options for filtering the specific instance of the library or all references to this library. You will pick the latter.
Using constant values to drive subsystem enable ports for changing model configurations is another common pattern in designs. The enable logic and subsystem contents might cause missing coverage. Add the
Switchable config subsystem to the filter because this configuration is not used in this model. In this design, the rate signal can never be less than or equal to the saturation lower limit of 0 in the
Saturation block. This leads to missing coverage. Let's addadd all these elements to the filter.
Saving and Attaching the Filter File
When you are finished building the filter, make sure that you are in writable folder then savesave and attach the filter file to the model. You can also access the attached filter file name from Filter tab of Coverage Settings.
Coverage Report of Filtered Elements
After simulatingsimulating the model, the coverage report shows a section containing all the filtered elements along with their rationale. The coverage numbers exclude the filtered elements. Notice that the transition with the temporal event was filtered entirely because filtering the
tick event reduced the condition numbers to one, so this object no longer has condition and MCDC coverage, but it has decision coverage.