Create, Edit, and View Coverage Filter Rules

Create and Edit Coverage Filter Rules

Create a Coverage Filter Rule

To create a coverage filter rule:

  1. In the Coverage Settings dialog box, enable model coverage.

  2. In the model window, right-click a model object and select Coverage > Exclude.

The following table lists the Exclude menu options. Depending on which option you select, the Type field is automatically set for the coverage filter rule you selected; you cannot override the value in the Type field.

If you select Coverage > ...The rule type is ...

Exclude this block

by block path

Exclude all blocks with type <block_type>

by block type

Exclude all blocks with type MATLAB Function

by block type

Exclude all blocks with type Truth Table

by block type

Exclude subsystem with all dependents

by subsystem

Exclude referenced library: <library_name>

by library reference

Exclude subsystem with all descendants

by subsystem

Exclude chart with all descendants

by chart

Exclude mask type <mask name>

by mask type

Exclude state with all descendants

by state

Exclude this transition

by transition

Exclude temporal event <event_name>

by temporal event

Add Rationale to a Coverage Filter Rule

Optionally, you can add text that describes why you want to exclude that object or objects from coverage recording, and might be useful to others who review the coverage for your model. When you add a new coverage filter rule, the Coverage Filter Viewer opens. To add the rationale:

  1. Double-click the Rationale field for the rule.

  2. Delete the existing text.

  3. Add the rationale for excluding this object.

The following graphic shows examples of text in the Rationale field.

    Note:   The Rationale field is the only coverage filter rule field that you can edit in the Coverage Filter Viewer.

Create Additional Coverage Filter Rules

From the Coverage Filter Viewer, you can navigate back to the model to create as many coverage filter rules as you need. To return to the model window, click Add new rule by right-clicking in the model.

For each rule that you add, the Coverage Filter Viewer opens so that you can specify a rationale for excluding that object from coverage.

Save Coverage Filter to File

After you define the coverage filter rules, save the rules to a file so that you can reuse them with this model or with other models. By default, coverage filter files are named <model_name>_covfilter.cvf.

In the Coverage Filter Viewer:

  1. In the File name field, specify a file name for the filter file or accept the default file name.

  2. Click Apply to save the coverage filter rules to that file.

If you make multiple changes to the coverage filter rules, apply the changes to the coverage filter file each time.

Attach Coverage Filter File to Model

Attach a coverage filter file to your model so that each time you open the model, the coverage filter rules apply when you simulate your model.

In the Coverage Filter Viewer:

  1. Select Attach file to model.

  2. Click Apply.

    Note:   You can also attach a coverage filter file to your model in the Coverage Settings dialog box, on the Filter tab.

You can have only one coverage filter file attached to a model at a time. If you attach a different coverage filter file, the newly attached file replaces the previously attached file.

Two or more models can have the same coverage filter file attached. If a model has an attached filter file that contains coverage filter rules for specific objects in a different model, those rules are ignored during coverage recording.

View Coverage Filter Rules in Your Model

Whenever you define a coverage filter rule or remove an existing coverage filter rule, the Coverage Filter Viewer opens. This dialog box lists all the coverage filter rules for your model. For more information, see Coverage Filter Viewer.

To open the Coverage Filter Viewer, right-click anywhere in the model window and select Coverage > Open Filter Viewer.

If you are inside a subsystem, you can view any coverage filter rule attached to the subsystem. To open the Coverage Filter Viewer, right-click any object inside the subsystem and select Coverage > Show filter parent.

Remove Coverage Filter Rules

Remove a Coverage Filter Rule

To remove a model object from coverage filtering, in the Simulink® Editor, right-click the object and select Coverage > Remove. The Coverage Filter Viewer opens. The coverage filter rule for the selected model object is no longer on the list of rules.

Remove Multiple Coverage Filter Rules

Use the Coverage Filter Viewer to remove multiple coverage filter rules at once:

  1. To open the Coverage Filter Viewer, right-click anywhere in the model and select Coverage > Open Filter Viewer.

  2. Select all the rules that you want to remove.

  3. Click Remove rule.

Was this topic helpful?