Main Content

getCoverageInfo

Retrieve coverage information for Simulink Design Verifier blocks from cvdata object

Description

[covInfo,description] = getCoverageInfo(cvdo,modelObject) collects Simulink® Design Verifier™ coverage for object, based on coverage results in cvdo. object is a handle to a block, subsystem, or Stateflow® chart. getCoverageData returns coverage data only for Simulink Design Verifier library blocks in object's hierarchy.

[covInfo,description] = getCoverageInfo(cvdo,modelObject,metric) returns coverage data for the block type specified in metric. If object does not match the block type, getCoverageInfo does not return data.

[covInfo,description] = getCoverageInfo(cvdo,modelObject,metric,ignore_descendants) returns coverage data about object, omitting coverage data for its descendant objects if ignore_descendants equals 1.

Examples

collapse all

Get coverage for all Proof Objective blocks in Verification Subsystem1

mdl = 'sldvdemo_powerwindow_vs';
open_system(mdl)
set_param(mdl, 'StopTime', '10')
testObj = cvtest(mdl);
testObj.settings.designverifier = 1;
data = cvsim(testObj);
verifSubsys = [mdl '/Verification Subsystem1'];
covProof = getCoverageInfo(data, verifSubsys, cvmetric.Sldv.proof)

covProof is a two-element vector of the form [covered_outcomestotal_outcomes] showing 1 covered outcome out of 1 total proof objective outcome.

Get coverage for a specific Test Objective block in Verification Subsystem1

mdl = 'sldvdemo_powerwindow_vs';
open_system(mdl)
set_param(mdl, 'StopTime', '10')
testObj = cvtest(mdl);
testObj.settings.designverifier = 1;
data = cvsim(testObj);
verifSubsys = [mdl '/Verification Subsystem1'];
testObjBlock = [verifSubsys '/Test Objective2'];
covTest = getCoverageInfo(data, testObjBlock)

covTest is a two-element vector of the form [covered_outcomes total_outcomes] showing 0 covered outcomes out of 1 total test objective outcome.

Get coverage data and descriptions for all available metrics recorded in Verification Subsystem1

mdl = 'sldvdemo_powerwindow_vs';
open_system(mdl)
set_param(mdl, 'StopTime', '10')
testObj = cvtest(mdl);
testObj.settings.designverifier = 1;
data = cvsim(testObj);
verifSubsys = [mdl '/Verification Subsystem1'];
[covAll, descrAll] = getCoverageInfo(data, verifSubsys, ...
{cvmetric.Sldv.proof, cvmetric.Sldv.test})

covAll is a cell array with cells corresponding to the objective outcomes for each metric. descrAll is a cell array with cells corresponding to descriptions of each metric.

covAll{1} 
covAll{2} 

covAll{1} is a two-element vector of the form [covered_outcomes total_outcomes] showing 1 covered outcomes out of 1 total proof objective outcomes. covAll{2} is a two-element vector of the form [covered_outcomes total_outcomes] showing 0 covered outcomes out of 1 total test objective outcomes.

descrAll{1}
descrAll{2}

descrAll{1} is a structure array containing descriptions of each proof objective, and descriptions and execution counts for each outcome. descrAll{2} is a structure array containing descriptions of each test objective, and descriptions and execution counts for each outcome.

Input Arguments

collapse all

Coverage data, specified as a cvdata object.

Data Types: cvdata

Model object, specified as a character array, string array, Simulink handle, Stateflow ID, or cell array.

To specify a model object, for example a block or a Stateflow chart, use one of the following formats:

Object SpecificationDescription

BlockPath

Full path to a model or block

BlockHandle

Handle to a model or block

slObj

Handle to a Simulink API object

sfID

Stateflow ID

sfObj

Handle to a Stateflow API object from a singly instantiated Stateflow chart

{BlockPath, sfID}

Cell array with the path to a Stateflow chart or atomic subchart and the ID of an object contained in that chart or subchart

{BlockPath, sfObj}

Cell array with the path to a Stateflow chart or subchart and a Stateflow object API handle contained in that chart or subchart

{BlockHandle, sfID}

Cell array with a handle to a Stateflow chart or atomic subchart and the ID of an object contained in that chart or subchart

To specify an S-Function block or its contents, use one of the following formats:

Object SpecificationDescription

{BlockPath, fName}

Cell array with the path to an S-Function block and the name of a source file

{BlockHandle, fName}

Cell array with an S-Function block handle and the name of a source file

{BlockPath, fName, funName}

Cell array with the path to an S-Function block, the name of a source file, and a function name

{BlockHandle, fName, funName}

Cell array with an S-Function block handle, the name of a source file an a function name

To specify a code coverage result, for example coverage data collected during software-in-the-loop (SIL) or processor-in-the-loop (PIL) analysis, use one of the following formats:

Object SpecificationDescription

{fileName, funName}

Cell array with the name of a source file and a function name

{Model, fileName}

Cell array with a model name or model handle and the name of a source file

{Model, fileName, funName}

Cell array with a model name or model handle, the name of a source file, and a function name

Data Types: char | string | cell | Stateflow.State | Stateflow.Transition

Coverage metric to retrieve, specified as a cvmetric.Sldv enumeration, or a cell array of enumerations, with values that correspond to Simulink Design Verifier library blocks. If you do not specify a metric, getCoverageInfo returns coverage information for all available metrics for the specified modelObject.

test

Test Objective (Simulink Design Verifier) block

proof

Proof Objective (Simulink Design Verifier) block

condition

Test Condition (Simulink Design Verifier) block

assumption

Proof Assumption (Simulink Design Verifier) block

Data Types: cvmetric.Sldv

Whether to ignore descendants in coverage results, specified as 0 or 1, where:

  • 0 includes coverage results of descendant objects.

  • 1 ignores coverage results of descendant objects.

Data Types: single | double

Output Arguments

collapse all

Coverage information, returned as a two-element array of the form [covered_outcomes,total_outcomes] if cvdo contains decision coverage data, or an empty array if it does not. If modelObject receives coverage for more than one metric, covInfo returns a cell array of two-element arrays where each cell corresponds to one metric.

covered_outcomesNumber of decision outcomes satisfied for modelObject
total_outcomesTotal number of decision outcomes for modelObject

Data Types: double

Coverage description, returned as a structure array with the following fields:

Note

If modelObject receives coverage for more than one metric, description returns a cell array of structures where each cell contains a description structure for one metric.

Block exclusion flag, returned as 1 if the block is excluded and 0 if it is not.

Data Types: double

Block coverage filter rationale, returned as a character array.

Data Types: char

Number of justified coverage objective outcomes, returned as a scalar double.

Data Types: double

Block justification flag, returned as 1 if the block is justified or 0 if it is not.

Data Types: double

Test objective information, returned as a structure with the following fields:

Text, returned as the character array 'T'.

Data Types: char

Number of time steps the objective is true, returned as a scalar double.

Data Types: double

Data Types: struct

Data Types: struct

Alternatives

Use the coverage settings to collect and display coverage results for Simulink Design Verifier library blocks:

  1. Open the model.

  2. In the Model Editor, select Model Settings on the Modeling tab.

  3. On the Coverage pane of the Configuration Parameters dialog box, select Enable coverage analysis.

  4. Under Coverage metrics, select Objectives and constraints.

  5. Click OK to close the Configuration Parameters dialog box and save your changes.

  6. Simulate the model and review the results.

Version History

Introduced in R2009b