debug integer overflow design error detection using model slicer -凯发k8网页登录
this example shows how to use model slicer to debug integer overflow design errors in a simulink® model.
prerequisites
this example uses the following products to demonstrate debugging the design error detection violations:
simulink design verifier™
simulink check™ (model slicer)
example
1. open model sldvdemo_design_error_detection
.
open_system('sldvdemo_design_error_detection');
2. open simulink design verifier by clicking on apps > design verifier.
3. in the design verifier tab, click detect design errors. simulink design verifier analyzes the model and displays the results in results summary window.
the model highlights the subsystem where the failed objectives are located.
4. open controller
subsystem and select either of the blocks that are highlighted in red.
5. in the results window, click debug to debug the violation using model slicer. alternatively, in the design verifier tab, click review results > debug using slicer to debug the violation using model slicer.
on clicking either of the entry points for debugging, the following setup is done on the model:
the selected block with a failed objective is added as a starting point for model slicer.
the model is highlighted with the slice responsible for the failing objective.
the design model is simulated and paused at the time of violation.
6. debug and analyze the model by inspecting the port labels.
tip: click on the output signal line of the sum block to enable the port value label for the block.
you can observe that the sum of the input variables should result in a non-zero number.
7. investigate the input and output data types of the sum block.
here, the datatype conversion results in the integer overflow. the datatype for inputs is ufix16_en8
, which have a maximum value of 255.9961, whereas the datatype for output block is sfix16_en8
, which has a maximum of 127.9961. in the counterexample the value is between these two values. the overflow happens when the sum block (without saturation) first casts the input values down to its output type and then does the arithmetic operation.
verification
to confirm that the integer overflow error was resolved, on the design verifier tab, click detect design errors. after the analysis completes, the software reports that all the objectives are valid.
additional capabilities
you can use the workflow demostrated in this example to debug the other design error detection violations using model slicer. following are the design errors supported:
division by zero
integer overflow
non-finate and nan (not a number) floating-point values
specified minimum and maximum value violations
datastore access violations
specified block input range violations