Main Content

Block Usage

hisl_0020: Blocks not recommended for MISRA C:2012 compliance

ID: Titlehisl_0020: Blocks not recommended for MISRA C:2012 compliance
Description

To improve MISRA C:2012 compliance of the generated code:

A

Use only blocks that support code generation, as documented in the Simulink® Block Support Table.

BDo not use blocks that are listed as “Not recommended for production code” in the Simulink Block Support Table.
C

Do not use Lookup Table blocks using cubic spline interpolation or extrapolation methods. Specific blocks are:

DDo not use deprecated Lookup Table blocks. The deprecated Lookup Table blocks are Lookup and Lookup2D.
EDo not use S-Function Builder blocks in the model or subsystem.
FDo not use From Workspace blocks in the model or subsystem.
G

Do not use these String blocks in the model or subsystem:

Notes

If you follow this and other modeling guidelines, you can eliminate model constructs that are not suitable for C/C++ production code generation, at the same time, increase the likelihood of generating code that complies with the MISRA C:2012 standard.

Use the Block Support Table block to view the Block Support Table. Blocks with the footnote (4) in the Block Support Table are classified as "Not recommended for production code".

RationaleA, B, C, D, E, F, GImprove quality and MISRA C:2012 compliance of the generated code.
Model Advisor Checks

For A,B,C, D, E, F, and G: Check for blocks not recommended for MISRA C:2012 (Simulink Check)

For A and B: Check for blocks not recommended for C/C++ production code deployment (Simulink Check)

References
  • DO-331, Section MB.6.3.2.b ‘Low-level requirements are accurate and consistent’
    DO-331, Section MB.6.3.2.e ‘Low-level requirements conform to standards’
    DO-331, Section MB.6.3.4.d ‘Source code conforms to standards’

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

  • IEC 62304, 5.5.3 - Software Unit acceptance criteria

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

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

  • MISRA C: 2012

Last ChangedR2018b

hisl_0101: Prevent operations that result in dead logic to improve code compliance

ID: Titlehisl_0101: Prevent operations that result in dead logic to improve code compliance
Description

To improve the compliance of generated code, avoid operations that result in dead code or unreachable code.

RationaleEnhance clarity and prevention of dead code.
Model Advisor ChecksCheck for unreachable and dead code (Simulink Check)
References
  • DO-331, Section MB.6.3.2.b – ‘Low-level requirements are accurate and consistent’

  • DO-331, Section MB.6.3.2.d – ‘Low-level requirements are verifiable’

  • ISO 26262-6, Table 1 (1e) – Use of well-trusted design principles

  • ISO 26262-6, Table 6 (1h) – No hidden data flow or control flow

  • MISRA C:2012, Rule 14.3

    MISRA C:2012, Rule 2.1

Last ChangedR2022a
Example

Not Recommended:

The following examples displays operations that result in dead code or unreachable code.

Stateflow:

MATLAB function:

Simulink:

hisl_0102: Data type of loop control variables to improve MISRA C:2012 compliance

ID: Titlehisl_0102: Data type of loop control variables to improve MISRA C:2012 compliance
Description

To improve MISRA C:2012 compliance of generated code, use integer data type for variables that are used as loop control counter variables in:

  • For loops constructed in Stateflow® and MATLAB®.

  • For Iterator blocks.

RationaleImprove MISRA C:2012 compliance of the generated code.
Model Advisor ChecksCheck data type of loop control variables (Simulink Check)
References
  • ISO 26262-6, Table 1 (1c) - Enforcement of strong typing

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

  • MISRA C:2012, Rule 14.1

Last ChangedR2018a