主要内容

hisl_0028: Usage of Reciprocal Square Root blocks

R2026b

Protect inputs of the Reciprocal Square Root block to avoid undesirable results in generated code

Usage: High-Integrity System Modeling

Guideline ID: hisl_0028

Rules

hisl_0028: Usage of Reciprocal Square Root blocks
A

To support robustness of generated code, when using the Reciprocal Square Root block, protect the input from going negative.

Rationale

Avoid undesirable results in generated code.

Verification

Check usage of Reciprocal Sqrt blocks (Simulink Check)

Example — Correct

Two Simulink models: one uses an Abs block to protect a negative input before a Reciprocal Square Root block; the other uses a Compare To Zero block and Multiport Switch to substitute eps when the input is zero before the Reciprocal Square Root block.

B

To support robustness of generated code, when using the Reciprocal Square Root block, protect the input from going to zero.

Rationale

Avoid undesirable results in generated code.

Verification

Check usage of Reciprocal Sqrt blocks (Simulink Check)

Tips

  • You can get a divide-by-zero operation, resulting in an (Inf) output value for the reciprocal function. To avoid overflows or undefined values, protect the corresponding input from going to zero.

Industry Standards

  • IEC 61508-3, Table A.3 (3) 'Language subset'

    IEC 61508-3, Table A.4 (3) 'Defensive programming'

  • IEC 62304, 5.5.3 - Software Unit acceptance criteria

  • ISO 26262-6, Table 1(b) 'Use of language subsets'

    ISO 26262-6, Table 1(d) 'Use of defensive implementation techniques'

  • EN 50128, Table A.4 (11) 'Language Subset'

    EN 50128, Table A.3 (1) 'Defensive Programming'

  • EN 50657, Table A.4 (11) 'Language Subset'

    EN 50657, Table A.3 (1) 'Defensive Programming'

  • EN 50716, Table A.3 (1) 'Defensive Programming'

  • DO-331, Section MB.6.3.2.g 'Algorithms are accurate'

  • MISRA C:2012, Dir 4.1

  • MISRA C:2023, Dir 4.1

  • INT33-C. Ensure that division and remainder operations do not result in divide-by-zero errors

Version History

Introduced in R2013b

expand all