メインコンテンツ

hisl_0034: Usage of Signal Routing blocks

R2026b

Avoid the ~= operator on floating-point data types in Switch blocks to improve model robustness

Usage: High-Integrity System Modeling

Guideline ID: hisl_0034

Rules

hisl_0034: Usage of Signal Routing blocks

When using Switch blocks, avoid comparisons using the ~= operator on floating-point data types.

Rationale

Improve model robustness.

Verification

Check usage of Signal Routing blocks (Simulink Check)

Example — Correct

The control input of the Switch block uses a boolean data type with the ~= 0 operator.

Simulink Switch block with uint8 inputs ON1 and OFF1 and a boolean control input using the ~= 0 operator.

Example — Incorrect

The control input of the Switch block uses a single (floating-point) data type with the ~= 0 operator.

Simulink Switch block with uint8 inputs ON and OFF and a single floating-point control input using the ~= 0 operator.

Tips

  • Due to floating-point precision issues, do not test floating-point expressions for inequality (~=).

  • When the model contains a Switch block computing a relational operator with the ~= operator, the inputs to the block must not be single, double, or any custom storage class that is a floating-point type. Change the data type of the input signals, or rework the model to eliminate using the ~= operator within Switch blocks.

Industry Standards

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

  • 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 (1b) - 'Use of language subsets'

    ISO 26262-6, Table 1 (1d) - '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'

  • MISRA C:2012, Dir 1.1

  • MISRA C:2023, Dir 1.1

Version History

Introduced in R2016b

expand all