Main Content

overflowsaturationinfo

R2026b

Retrieve saturation on integer overflow coverage from cvdata object

Description

coverage = overflowsaturationinfo(covdata,modelObject) returns saturation on integer overflow coverage results from the cvdata object covdata for the model object specified by object and its descendants.

example

coverage = overflowsaturationinfo(covdata,modelObject,ignoreDescendants) returns saturation on integer overflow coverage results from the cvdata object covdata for the model object specified by object and, depending on the value of ignoreDescendants, descendant objects.

[coverage, description] = overflowsaturationinfo(covdata,modelObject) returns the saturation on integer overflow coverage results and textual descriptions of each coverage outcome in modelObject in description. The textual descriptions exclude descendants.

example

Examples

collapse all

This example shows how to use overflowsaturationinfo to extract saturation on integer overflow data for a MinMax block from a cvdata object.

Download the example files.

openExample("sldemo_fuelsys");

Open the model and set coverage settings.

load_system("sldemo_fuelsys");

Create a Simulink.SimulationInput object to change configuration parameters without modifying the model.

covSet = Simulink.SimulationInput("sldemo_fuelsys");

Turn on coverage analysis and configure Simulink® to save the coverage data in a separate cvdata object in the workspace.

covSet = covSet.setModelParameter("CovEnable","on");
covSet = covSet.setModelParameter("CovSaveSingleToWorkspaceVar","on");
covSet = covSet.setModelParameter("CovSaveName","covData");
covSet = covSet.setModelParameter("CovScope","EntireSystem");

Enable collection of saturation on integer overflow Coverage and simulate the model by calling sim with the SimulationInput object as the input.

covSet = covSet.setModelParameter(...
         "CovMetricSaturateOnIntegerOverflow","on");
simOut = sim(covSet);

Get the block handle to the MinMax block using get_param and then get the saturation on integer overflow results.

blockHandle = get_param("sldemo_fuelsys/" + ...
    "Engine Gas Dynamics/Mixing & Combustion/MinMax","Handle");
saturationResults = overflowsaturationinfo(covData,blockHandle)
percentSaturationCoverage = ...
               100 * saturationResults(1)/saturationResults(2)
saturationResults =

     1     2


percentSaturationCoverage =

    50

One out of two saturation on integer overflow decision outcomes were satisfied for the MinMax block in the Mixing & Combustion subsystem, so it received 50% saturation on integer overflow coverage.

This example shows how to use overflowsaturationinfo to determine whether or not integer overflow occurs for a block in a model.

Generate coverage data

Load the slvnvdemo_saturation_on_overflow_coverage example model.

load_system('slvnvdemo_saturation_on_overflow_coverage');

Set coverage setting using a Simulink.SimulationInput object. Turn coverage on and configure Simulink® to output a cvdata object into the workspace.

covSet = Simulink.SimulationInput('slvnvdemo_saturation_on_overflow_coverage');
covSet = covSet.setModelParameter('CovEnable','on');
covSet = covSet.setModelParameter('CovSaveSingleToWorkspaceVar','on');
covSet = covSet.setModelParameter('CovSaveName','covData');
covSet = covSet.setModelParameter('CovScope','EntireSystem');

Extract saturation on integer overflow results

Retrieve saturation on integer overflow coverage results and description for the Sum block in the Controller subsystem of the Test Unit subsystem.

covSet = covSet.setModelParameter('CovMetricSaturateOnIntegerOverflow','on');
simOut = sim(covSet);
[covResults, covDesc] = overflowsaturationinfo(covData, ...
		['slvnvdemo_saturation_on_overflow_coverage/Test Unit /' ...
		'Controller/Sum'])
percentSaturation = 100 * covResults(1)/covResults(2)
covResults =

     1     2


covDesc = 

  struct with fields:

           isFiltered: 0
          isJustified: 0
    justifiedCoverage: 0
      filterRationale: ''
             decision: [1×1 struct]


percentSaturation =

    50

One out of two saturation on integer overflow decision outcomes were satisfied for the Sum block, so it received 50% saturation on integer overflow coverage.

Review the number of times the Sum block evaluated to each saturation on integer overflow outcome during simulation.

outcome1 = covDesc.decision.outcome(1)
outcome2 = covDesc.decision.outcome(2)
outcome1 = 

  struct with fields:

          execCount: 3
     executionCount: 3
               text: 'false'
         isFiltered: 0
        isJustified: 0
    filterRationale: ''
         executedIn: []


outcome2 = 

  struct with fields:

          execCount: 0
     executionCount: 0
               text: 'true'
         isFiltered: 0
        isJustified: 0
    filterRationale: ''
         executedIn: []

During simulation, integer overflow did not occur in the Sum block because the 'true' outcome has an execution count of 0.

If integer overflow is not possible for a block in your model, consider clearing the Saturate on integer overflow block parameter to optimize efficiency of your generated code.

Input Arguments

collapse all

Coverage results data, specified as a cvdata object.

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

To specify a model object, such as a block or a Stateflow chart, use one of these 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

Option to ignore descendants in coverage results, specified as one of these values:

  • 0 or false – includes coverage results of descendant objects.

  • 1 or true – ignores coverage results of descendant objects.

Data Types: single | double | logical

Output Arguments

collapse all

Saturation on overflow coverage results for modelObject and its descendants, returned as an array of the form [covered_outcomes total_outcomes].

covered_outcomesNumber of saturation on integer overflow outcomes satisfied plus number of justified outcomes for modelObject.
total_outcomesNumber of total saturation on integer overflow outcomes minus number of excluded outcomes for modelObject.

To exclude descendants from coverage, use the ignoreDescendants input argument.

Data Types: double

Textual description of coverage outcomes for modelObject, excluding its descendants, returned as a structure array. Depending on the types of model coverage collected, the structure array can have different fields. If only saturation on overflow coverage is collected, the structure array contains these fields:

isFiltered

0 if the model component specified by object is not excluded from coverage recording. 1 if the model component specified by object is excluded from coverage recording. For more information about excluding objects from coverage, see Coverage Filtering.

decision.text'Saturate on integer overflow'
decision.outcome

Structure array containing two fields for each coverage outcome:

executionCountNumber of times saturation on integer overflow for object evaluated to the outcome described by text.
text'true' or 'false'

Saturation on integer overflow has two possible outcomes, 'true' and 'false'.

decision.isFiltered

0 if the model component specified by object is not excluded from coverage recording. 1 if the model component specified by object is excluded from coverage recording. For more information about excluding objects from coverage, see Coverage Filtering.

decision.filterRationale

Rationale for filtering the model component specified by object, if object is excluded from coverage and a rationale is specified. For more information about excluding objects from coverage, see Coverage Filtering.

Data Types: struct

Version History

Introduced in R2013a