Main Content

Detect Defects Using Optimized Checks

The Defect Checker is designed to identify defects in a model during the development phase. It employs an optimized strategy to find defects efficiently, focusing on identifying potential issues rather than proving their absence.

Defect Checker is most effective when applied to the specific component you are working on, ensuring you only address defects relevant to your current focus and avoid issues in unrelated components. This helps you to know what the defects are in the model and fix them before you integrate the component into a larger model. Defect Checker helps you to check the models throughout the development phase for common and critical design errors such as division by zero, integer overflow, dead logic, and array out of bounds.

Identify and Correct Common Design Errors Using Defect Checker

This example shows you how to use Defect Checker to identify and correct common errors in your model throughout the development phase. Consider the model PIController_Defective. Before integrating the model to the full system, sldvExDefectChecker_Defective, run Defect Checker to find common bugs and remove them before analyzing the full system.

Configure Defect Checker Options

Open the model.

open_system("PIController_Defective");

model.png

On the Design Verifier tab, you can see the Defect Checker button on the toolstrip. Defect Checker is enabled by default. Click the button on the toolstrip and enable, if it is 'off'.

You can also enable Defect Checker by following this:

Click Error Detection Settings. In the Configuration Parameters dialog box, on the Design Verifier tab > Design Error Detection pane, select Defect Checker.

defect_checker.png

You can also enable Defect Checker programmatically:

Defect Checker is 'on' by default if the options are generated by using:

opts = sldvoptions;

To check if the Defect Checker option is 'on' for a model:

opts = sldvoptions(model);

If Defect Checker is 'off', enable by using:

opts.DefectChecker = 'on';

Note: Defect Checker automatically invokes dead logic, out of bound array access, division by zero, integer overflow, and specified minimum and maximum value violations checks. To specify checks, set Defect Checker to ‘off’.

Run Defect Checker

To perform analysis by using Defect Checker, on the Design Verifier tab, click Detect Design Errors.

The software analyzes the model for the defects and displays the number of defects found during the analysis, in the Results window.

defective_analysis.png

Review Analysis Results

PI_Defective.png

  1. Use the highlighting to navigate to the source of the defect, the Sum block. The Sum block is highlighted in red to help you locate the defects.PI_Defective.png

  2. The informer provides debugging information and links for further investigation. Comparing inport and outport ranges, you can see the outport data type has insufficient range to incorporate a sum. Another possibility for debugging is to click the Debug option to debug the defects by using Model Slicer.

  3. Adjust the output data type of the Sum block to accommodate a wider range. This avoids the overflow.

Rerun Defect Checker on the Fixed Component Model

The erroneous behavior exhibited by the counterexample is fixed in the sldvExDefectChecker_Fixed model.

open_system('PIController_Fixed');

When you rerun the analysis on this fixed component, you can see that defect checker no longer finds any defects.

fixed_analysis.png

Note: Only falsified and dead logic objectives are reported.

Integrate Model into Overall System

The erroneous behavior exhibited by the counterexample is fixed in the sldvExDefectChecker_Fixed model.

open_system('sldvExDefectChecker_Fixed');

fixed_model.png

Rerun Defect Checker to check for defects. After the analysis completes, the Results Summary window reports that there are no further defects at the model and the component level.

No_defects.png

Related links