Documentation

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.
CDo not use Lookup Table blocks using cubic spline interpolation or extrapolation methods.
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.
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.

Choose Simulink Help > Simulink > Block Data Types & Code Generation Support > All Tables 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, DImprove quality and MISRA C:2012 compliance of the generated code.
Model Advisor Checks

To check model for conditions A,B,C, D, E, and F:

  • By Task > Modeling Guidelines for MISRA C:2012 > Check for blocks not recommended for MISRA C:2012

  • By Task > Modeling Standards for DO-178C/DO-331 > High-Integrity Systems > Code > Check for blocks not recommended for MISRA C:2012

  • By Task > Modeling Standards for IEC 61508 > High-Integrity Systems > Code > Check for blocks not recommended for MISRA C:2012

  • By Task > Modeling Standards for IEC 62304 > High-Integrity Systems > Code > Check for blocks not recommended for MISRA C:2012

  • By Task > Modeling Standards for EN 50128 > High-Integrity Systems > Code > Check for blocks not recommended for MISRA C:2012

  • By Task > Modeling Standards for ISO 26262 > High-Integrity Systems > Code > Check for blocks not recommended for MISRA C:2012

For Modeling Guidelines for MISRA C:2012, see Check for blocks not recommended for MISRA C:2012

For DO-178C/DO-331 check details, see Check for blocks not recommended for MISRA C:2012.

For IEC 61508, IEC 62304, EN 50128, and ISO 26262 check details, see Check for blocks not recommended for MISRA C:2012.

To check model for conditions A and B:

  • By Task > Modeling Guidelines for MISRA C:2012 > Check for blocks not recommended for C/C++ production code deployment

  • By Task > Modeling Standards for DO-178C/DO-331 > High-Integrity Systems > Simulink > Check for blocks not recommended for C/C++ production code deployment

  • By Task > Modeling Standards for IEC 61508 > High-Integrity Systems > Simulink > Check for blocks not recommended for C/C++ production code deployment

  • By Task > Modeling Standards for IEC 62304 > High-Integrity Systems > Simulink > Check for blocks not recommended for C/C++ production code deployment

  • By Task > Modeling Standards for EN 50128 > High-Integrity Systems > Simulink > Check for blocks not recommended for C/C++ production code deployment

  • By Task > Modeling Standards for ISO 26262 > High-Integrity Systems > Simulink > Check for blocks not recommended for C/C++ production code deployment

For Modeling Guidelines for MISRA C:2012, see Check for blocks not recommended for C/C++ production code deployment

For DO-178C/DO-331 check details, see Check for blocks not recommended for C/C++ production code deployment.

For IEC 61508, IEC 62304, EN 50128, and ISO 26262 check details, see Check for blocks not recommended for C/C++ production code deployment.

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 ChangedR2017b

hisl_0101: Avoid invariant comparison operations to improve MISRA C:2012 compliance

ID: Titlehisl_0101: Avoid invariant comparison operations to improve MISRA C:2012 compliance
Description

To improve MISRA C:2012 compliance of generated code, avoid comparison operations with invariant results. Comparison operations are performed by the following blocks:

  • If

  • Logic

  • Relational Operator

  • Switch

  • Switch Case

  • Compare to Constant

RationaleImprove MISRA C:2012 compliance of the generated code.
References
  • MISRA C:2012, Rule 14.3

  • MISRA C:2012, Rule 2.1

Last ChangedR2015b
Example

Invariant comparisons can occur in simple or compound comparison operations. In compound comparison operations, the individual components can be variable when the full calculation is invariant.

Simple: A uint8 is always greater than or equal to 0.

Simple: A uint8 cannot have a value greater than 256

Compound: The comparison operations are mutually exclusive

Stateflow®:

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 and while loops constructed in Stateflow and MATLAB®.

  • While Iterator and For Iterator blocks.

RationaleImprove MISRA C:2012 compliance of the generated code.
References
  • MISRA C:2012, Rule 14.1

Last ChangedR2015b
Was this topic helpful?