Main Content

Lookup Table Blocks

hisl_0033: Usage of Lookup Table blocks

ID: Titlehisl_0033: Usage of Lookup Table blocks
Description

To support robustness of generated code, when using the 1-D Lookup Table, 2-D Lookup Table, n-D Lookup Table, Prelookup, and Interpolation Using Prelookup blocks:

A

Clear block parameter Remove protection against out-of-range input in generated code in each 1-D Lookup Table, 2-D Lookup Table, n-D Lookup Table, or Prelookup block.

B

Clear block parameter Remove protection against out-of-range index in generated code in each Interpolation Using Prelookup block.

Note

If the lookup table inputs are not guaranteed to fall within the range of valid breakpoint values, exclusion of range-checking code may produce unexpected results.

RationaleA,B

Protect against out-of-range inputs or indices.

Model Advisor ChecksCheck usage of lookup table blocks (Simulink Check)
References
  • 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.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'

See Also

1-D Lookup Table

2-D Lookup Table

n-D Lookup Table

Prelookup

Last ChangedR2021a

hisl_0016: Usage of blocks that compute relational operators

ID: Titlehisl_0016: Usage of blocks that compute relational operators
DescriptionTo support the robustness of the operations, avoid using the equality and inequality operators on floating-point data types.
NotesDue to floating-point precision issues, do not test floating-point expressions for equality (==) or inequality (~=, !=).
RationaleImprove model robustness and prevent unexpected results.
Model Advisor ChecksCheck relational comparisons on floating-point signals (Simulink Check)
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 AlsoRelational Operations
Last ChangedR2021b
Examples

Ex: 1

Example — Correct

  • myDouble > 0.99 && myDouble < 1.01; % test range

Example — Incorrect

  • myDouble == 1.0

  • mySingle ~= 15.0

Ex: 2

Example — Correct

Equality comparison operators are not used in floating-point operands.

Example — Incorrect

Equality comparison operator == is used in floating-point operands.

Example — Correct

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.

Example — InCorrect

Equality comparison operator == is used in floating-point operands

hisl_0072: Usage of tunable parameters for referenced models

ID: Titlehisl_0072: Usage of tunable parameters for referenced models
Description

Use the Simulink.Parameter object to define tunable parameters. This applies to all tunable parameters that are meant to be shared via either the base workspace or Simulink data dictionaries. It does not apply to model arguments.

Notes

Simulink® ignores the storage class settings of parameters that are configured by using the Model Parameter Configuration dialog box for referenced models.

This guideline is applicable only when configuration parameter Default parameter behavior is set to Inlined.

RationalePrevent unintended loss of parameter tunability.
Model Advisor ChecksCheck for parameter tunability information ignored for referenced models
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.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.3 (1) 'Defensive Programming'

See Also

Create Tunable Calibration Parameter in the Generated Code (Simulink Coder)

Last ChangedR2021b

hisl_0073: Usage of bit-shift operations

ID: Titlehisl_0073: Usage of bit-shift operations
Description

For bit-shifting operations (e.g. a >> b or a << b), do not perform:

Shift operations that are greater than or equal to the bit-width (b must not be equal or greater than the bit width of a).

RationaleGeneration of code with shift operations can result in violation of coding standards
Model Advisor ChecksCheck usage of bit-shift operations (Simulink Check)
References
  • DO-331 Section MB.6.3.1.b 'High-level requirements are accurate and consistent'

    DO-331 Section MB.6.3.2.b 'Low-level requirements are accurate and consistent'

  • IEC 61508–3, Table A.3 (2) Strongly typed programming language

    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

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

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

    EN 50128, Table A.4 (8) Strongly Typed Programming Language

  • MISRA C:2012, Rule 12.2

  • INT34-C. Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand

See Also

Create Tunable Calibration Parameter in the Generated Code (Simulink Coder)

Last ChangedR2021b