Main Content

Debug Enhanced Modified Condition and Decision Coverage (MCDC) using Model Slicer

This example shows how to find the Simulink Design Verifier (SLDV) generated objectives related to a specific model object using Model Slicer. Once the objectives are identified, Model Slicer highlights the slice at the step when the objective is observable.

This example uses the following products to demonstrate debugging enhanced MCDC:

  • Simulink Design Verifier

  • Model Slicer

Enhanced MCDC analyzes the detectability of each objective in the model and generates non-masking test cases for each objective. It coordinates the effect of downstream blocks to avoid masking effects. It also calculates detection sites for each detectable objective where the effect of the objective can be observed. This data is available in the sldvdemo_cruise_control_sldvdata.mat file generated by the analysis. These detection sites can be added to the equivalence criteria of back-to-back testing.

This example uses the following slicer configuration:

  • Starting point is set as the model object to be observed.

  • Exclusion point is set as the detection point relavent to the objective generated by SLDV.

  • Signal propagation is set to downstream (forward slice).

Step 1: Prepare the model

1. Open the model.

model = 'sldvdemo_cruise_control';
open_system(model);

2. Load the data file generated by SLDV (sldvData) for test generation using Enhanced MCDC.

load('sldvdemo_cruise_control_sldvdata.mat');

3. Choose the model object for which the objective must be highlighted and find it's SID .

modelObjIdentifier = 'sldvdemo_cruise_control/Controller/Switch3';
modelobjSID = Simulink.ID.getSID(modelObjIdentifier);

Step 2: Setting up Model Slicer

1. Enable FastRestart for the model.

set_param(model,'FastRestart','on');

Enabling FastRestart will simulate the model and collect the simulation data at various time stamps. This will allow us to use Step Back and Step Forward options.

2. Create and activate Model Slicer object.

slicerObject = slslicer(model);
activate(slicerObject);

3. Set the signal propogation to downstream.

slicerObject.Configuration.SignalPropagation = 'downstream';

Step 3: Find Objectives Related to the Model Object

1. Access sldvData with an object of SldvDataExplorer class.

sldvObj = Sldv.enhancedMCDC.SldvDataExplorer(sldvData);

2. Find all objectives related to the model object and the details of the objectives.

[objectives, tableOfObjectives] = sldvObj.getObjectivesForModelObj(modelobjSID);
disp(tableOfObjectives);
    ObjectiveNum       Type                                Description                             Detectability      Status       TestCaseId
    ____________    __________    _____________________________________________________________    _____________    ___________    __________

         1          "Decision"    "logical trigger input false (output is from 3rd input port)"    "Detectable"     "Satisfied"        1     
         2          "Decision"    "logical trigger input true (output is from 1st input port)"     "Detectable"     "Satisfied"        1     

The follwing details of the objectives are saved in tableOfObjectives table:

  • ObjectiveNum - Objective number.

  • Type - MCDC/Decision/Condition.

  • Description - Description of the objective as generated by SLDV.

  • Detectability - The detectability status of an objective.

  • Status - The status of an objective.

  • TestCaseId - Integer that represents the index of a test case or counterexample that addresses an objective.

Step 4: Highlighting the objectives

For this example, we will highlight the first objective from the table.

1. Obtain the simulation input object with the input values set according to the test case that corresponds to the objective.

[simIn, atStep, ~] = sldvObj.getSimInObjForObjective(objectives(1));

2. Allow rollback in the model so it is possible to step backwards in the model and set the number of simulation rollback steps to 1.

simIn = simIn.setModelParameter('EnableRollBack','on');
simIn = simIn.setModelParameter('NumberOfSteps', 1);

3. Apply simulink input object to model.

slicerObject.applySimInToModel(simIn);

4. Find all the detection sites for the selected objective.

objectDetectionSites = sldvObj.getObjectDetectionSites(objectives(1));

5. Add all detection sites as exclusion points.

for n = 1:length(objectDetectionSites)
    detectionSite = objectDetectionSites(n).modelObj;
    slicerObject.addExclusionPoint(detectionSite);   
end

6. Add the model object as an starting point.

slicerObject.addStartingPoint(modelobjSID);

7. Step to the point in the testcase where the objective is observable.

for q = 1:atStep 
    slicerObject.stepForward();
end

Now you can observe that the slice is highlighted.

Cleanup

Perform the following actions to cleanup the model:

1. Clear the slicer object.

2. Clear the simulink input object.

clear slicerObject simIn

3. Reset the FastRestart parameter of the model.

set_param(model,'FastRestart','off');