hisl_0001: Usage of Abs block
R2026bAvoid unsupported data types and protect against integer overflow for the Abs block
Usage: High-Integrity System Modeling
Guideline ID: hisl_0001
Rules
| hisl_0001: Usage of Abs block | |
|---|---|
| A | To support robustness of generated code, when using the Abs block, avoid Boolean and unsigned data types as inputs to the Abs block. Rationale Support generation of traceable code. Verification Check usage of Abs blocks (Simulink Check) Example — Correct Signed integer input to the Abs block.
Example — Incorrect Unsigned integer input to the Abs block.
|
| B | To support robustness of generated code, when using the Abs block, select block parameter Saturate on integer overflow. Rationale Achieve consistent and expected behavior of model simulation and generated code. Verification Check usage of Abs blocks (Simulink Check) |
Tips
The Abs block does not support Boolean data types. Specifying an unsigned input data type, might optimize the Abs block out of the generated code, resulting in a block you cannot trace to the generated code.
For signed data types, Simulink® does not represent the absolute value of the most negative value. When you select Saturate on integer overflow, the absolute value of the data type saturates to the most positive representable value. When you clear Saturate on integer overflow, absolute value calculations in the simulation and generated code might not be consistent or expected.
Industry Standards
IEC 61508-3, Table A.3 (3) 'Language subset'
IEC 61508-3, Table A.4 (3) 'Defensive programming'
IEC 61508-3, Table A.3 (2) 'Strongly typed programming language'
IEC 61508-3, Table B.8 (3) 'Control Flow Analysis'IEC 62304, 5.5.3 - Software Unit acceptance criteria
ISO 26262-6, Table 1 (1b) 'Use of language subsets'
ISO 26262-6, Table 1 (1d) 'Use of defensive implementation techniques'
ISO 26262-6, Table 7 (1f) 'Control flow analysis'EN 50128, Table A.4 (11) 'Language Subset'
EN 50128, Table A.3 (1) 'Defensive Programming'
EN 50128, Table A.4 (8) 'Strongly Typed Programming Language'
EN 50128 Table A.19 (3) 'Control Flow Analysis'EN 50657, Table A.4 (11) 'Language Subset'
EN 50657, Table A.3 (1) 'Defensive Programming'
EN 50657, Table A.4 (8) 'Strongly Typed Programming Language'
EN 50657 Table A.19 (3) 'Control Flow Analysis'EN 50716, Table A.3 (1) 'Defensive Programming'
EN 50716, Table A.19 (1) 'Control Flow Analysis'DO-331, Section MB.6.3.2.d 'Low-level requirements are verifiable'
DO-331, Section MB.6.3.2.g – 'Algorithms are accurate'MISRA C:2012, Dir 4.1
MISRA C:2023, Dir 4.1
INT32-C. Ensure that operations on signed integers do not result in overflow

