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.
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, and D:

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

  • To check model for conditions A and B: By Task > Modeling Standards for DO-178C/DO-331 > Simulink > Check for blocks not recommended for C/C++ production code deployment

For check details, see Check for blocks not recommended for MISRA C:2012 and 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'

  • MISRA C:2012

Last ChangedR2016b

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 then 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?