This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Logic and Bit Operations

hisl_0016: Usage of blocks that compute relational operators

ID: Titlehisl_0016: Usage of blocks that compute relational operators
Description

To support the robustness of the operations, when using blocks that compute relational operators, including Relational Operator, Compare To Constant, Compare To Zero, Detect Change, and If blocks:

AAvoid comparisons using the == or ~= operator on floating-point data types.
Notes

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

When the model contains a block computing a relational operator with the == or ~= operators, 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 == or ~= operators within blocks that compute relational operators.

RationaleAImprove model robustness.
Model Advisor Checks
  • By Task > Modeling Standards for DO-178C/DO-331 > High-Integrity Systems > Simulink > Check for Relational Operator blocks that equate floating-point types

  • By Task > Modeling Standards for IEC 61508 > High-Integrity Systems > Simulink > Check for Relational Operator blocks that equate floating-point types

  • By Task > Modeling Standards for IEC 62304 > High-Integrity Systems > Simulink > Check for Relational Operator blocks that equate floating-point types

  • By Task > Modeling Standards for ISO 26262 > High-Integrity Systems > Simulink > Check for Relational Operator blocks that equate floating-point types

  • By Task > Modeling Standards for EN 50128 > High-Integrity Systems > Simulink > Check for Relational Operator blocks that equate floating-point types

For check details, see Check for Relational Operator blocks that equate floating-point types.

References
  • IEC 61508-3, Table A.3 (2) 'Strongly typed programming language’
    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 (1c) 'Enforcement of strong typing'

  • EN 50128, Table A.4 (11) 'Language Subset'
    EN 50128, Table A.4 (8) 'Strongly Typed Programming Language'
    EN 50128, Table A.3 (1) 'Defensive Programming'

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

  • MISRA C:2012, Dir 1.1

See Alsohisl_0017: Usage of blocks that compute relational operators (2)
Last ChangedR2018a
Examples

Positive Pattern: To test whether two floating-point variables or expressions are equal, compare the difference of the two variables against a threshold that takes into account the floating-point relative accuracy (eps) and the magnitude of the numbers.

The following pattern shows how to test two double-precision input signals, In1 and In2, for equality.

hisl_0017: Usage of blocks that compute relational operators (2)

ID: Titlehisl_0017: Usage of blocks that compute relational operators (2)
Description

To support unambiguous behavior in the generated code, when using blocks that compute relational operators, including Relational Operator, Compare To Constant, Compare to Zero, and Detect Change

ASet the block Output data type parameter to Boolean.
BFor Relational Operator blocks, ensure that all input signals are of the same data type.
RationaleA, BSupport generation of code that produces unambiguous behavior.
Model Advisor Checks
  • By Task > Modeling Standards for DO-178C/DO-331 > High-Integrity Systems > Simulink > Check usage of Relational Operator blocks

  • By Task > Modeling Standards for IEC 61508 > High-Integrity Systems > Simulink > Check usage of Relational Operator blocks

  • By Task > Modeling Standards for IEC 62304 > High-Integrity Systems > Simulink > Check usage of Relational Operator blocks

  • By Task > Modeling Standards for ISO 26262 > High-Integrity Systems > Simulink > Check usage of Relational Operator blocks

  • By Task > Modeling Standards for EN 50128 > High-Integrity Systems > Simulink > Check usage of Relational Operator blocks

For check details, see Check usage of Relational Operator blocks.

References
  • IEC 61508-3, Table A.3 (2) 'Strongly typed programming language’
    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 (1c) 'Enforcement of strong typing'

  • EN 50128, Table A.4 (11) 'Language Subset'
    EN 50128, Table A.4 (8) 'Strongly Typed Programming Language'
    EN 50128, Table A.3 (1) 'Defensive Programming'

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

  • MISRA C:2012, Rule 10.1

See Alsohisl_0016: Usage of blocks that compute relational operators
Last ChangedR2018a

hisl_0018: Usage of Logical Operator block

ID: Titlehisl_0018: Usage of Logical Operator block
Description

To support unambiguous behavior of generated code, when using the Logical Operator block,

A

Set the Output data type block parameter to Boolean.

B

Ensure all input signals are of type Boolean.

Prerequisites

hisl_0045: Configuration Parameters > Math and Data Types > Implement logic signals as Boolean data (vs. double)

RationaleA, BAvoid ambiguous behavior of generated code.
Model Advisor Checks
  • By Task > Modeling Standards for DO-178C/DO-331 > High-Integrity Systems > Simulink > Check usage of Logical Operator blocks

  • By Task > Modeling Standards for IEC 61508 > High-Integrity Systems > Simulink > Check usage of Logical Operator blocks

  • By Task > Modeling Standards for IEC 62304 > High-Integrity Systems > Simulink > Check usage of Logical Operator blocks

  • By Task > Modeling Standards for ISO 26262 > High-Integrity Systems > Simulink > Check usage of Logical Operator blocks

  • By Task > Modeling Standards for EN 50128 > High-Integrity Systems > Simulink > Check usage of Logical Operator blocks

For check details, see Check usage of Logical Operator blocks.

References
  • DO-331, Section MB.6.3.1.e—High-level requirements conform to standards
    DO-331, Section MB.6.3.2.e—Low-level requirements conform to standards
    DO-331, Section MB.6.3.1.g 'Algorithms are accurate'
    DO-331, Section MB.6.3.2.g 'Algorithms are accurate'
    DO-331, Section MB.6.3.4.e—Source code is traceable to low-level requirements.
    DO-331, Section MB.6.3.3.b—Software architecture is consistent.

  • IEC 61508-3, Table A.3 (2) 'Strongly typed programming language’
    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 (1c) 'Enforcement of strong typing'

  • EN 50128, Table A.4 (11) 'Language Subset'
    EN 50128, Table A.4 (8) 'Strongly Typed Programming Language'
    EN 50128, Table A.3 (1) 'Defensive Programming'

  • MISRA C:2012, Directive 1.1

Last ChangedR2017b

hisl_0019: Usage of bitwise operations

ID: Titlehisl_0019: Usage of bitwise operations
Description

To support unambiguous behavior, when using bitwise operations in Simulink blocks,

A

Avoid signed data types as input to the block.

Notes

Bitwise operations on signed data types are not meaningful. If a shift operation moves a signed bit into a numeric bit, or a numeric bit into a signed bit, unpredictable and unwanted behavior can result.

Bitwise blocks include:

RationaleASupport unambiguous behavior of generated code.
Model Advisor Checks
  • By Task > Modeling Standards for DO-178C/DO-331 > High-Integrity Systems > Simulink > Check for bitwise operations in Simulink blocks

  • By Task > Modeling Standards for IEC 61508 > High-Integrity Systems > Simulink > Check for bitwise operations in Simulink blocks

  • By Task > Modeling Standards for IEC 62304 > High-Integrity Systems > Simulink > Check for bitwise operations in Simulink blocks

  • By Task > Modeling Standards for EN 50128 > High-Integrity Systems > Simulink > Check for bitwise operations in Simulink blocks

  • By Task > Modeling Standards for ISO 26262 > High-Integrity Systems > Simulink > Check for bitwise operations in Simulink blocks

For check details, see Check for bitwise operations in Simulink blocks.

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

  • IEC 61508-3, Table A.3 (3) 'Language subset’
    IEC 61508-3, Table A.3 (2) 'Strongly typed programming language’

  • IEC 62304, 5.5.3 - Software Unit acceptance criteria

  • ISO 26262-6, Table 1 (1b) 'Use of language subsets'
    ISO 26262-6, Table 1 (1c) 'Enforcement of strong typing'
    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 50128, Table A.4 (8) 'Strongly Typed Programming Language'

  • MISRA C:2012, Rule 10.1

See Alsohisf_0003: Usage of bitwise operations
Last ChangedR2019a