Main Content

Detect Integer Overflow Errors

This example shows how to detect integer overflow errors in a model by using design error detection analysis. Simulink® Design Verifier™ identifies the model constructs that may result in integer overflows and then either proves that the integer overflow cannot occur during simulation or generates test cases that demonstrates the integer overflow error.

In this example, you will perform design error detection analysis on a model, then generate a report that shows which integer overflow objectives were valid and which objectives resulted in errors.

Step 1: Open the Model

At the command prompt, enter:

open_system('sldvdemo_design_error_detection');

Step 2: Perform Design Error Detection Analysis

The model is preconfigured with theInteger overflowoption enabled in the Configuration Parameters dialog box, on theDesign Verifier>Design Error Detectionpane.

On theDesign Verifiertab, clickDetect Design Errors.

The software analyzes the model for integer overflow errors. After the analysis completes, the Results Summary window reports that five objectives are valid and two objectives are falsified.

Step 3: Review Analysis Results

To highlight the analysis results on the model, in the Results Summary window, clickHighlight analysis results on model. The valid objectives are highlighted in green and the falsified objectives are highlighted in red.

Double-click theControllersubsystem. Click the Sum block that is highlighted in red. The Results Inspector window displays the integer overflow objectives.

To view the test case that results in the error, clickView test case. The harness model opens and the Signal Builder block displays the test case that results in the error.

Step 4: Fix the Integer Overflow Error

For both the Sum blocks that generated the integer overflow, enable theSaturate on integer overflowoption. Alternatively, you can double-click theToggle Saturation on overflowbutton in the Simulink Editor.

To confirm that the integer overflow error was resolved, on theDesign Verifiertab, clickDetect Design Errors. After the analysis completes, the software reports that all the objectives are valid.

Related Topics