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
Notes

If you follow this and other modeling guidelines, you increase the likelihood of generating code that complies with the MISRA C:2012 standard.

Choose Simulink Help > Block Support Table > Simulink 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,BImprove MISRA C:2012 compliance of the generated code.
Model Advisor Checks

By Product > Embedded Coder > Check for blocks not recommended for MISRA C:2012

For details, see Check for blocks not recommended for MISRA C:2012Configure a Model for Code GenerationConfigure a Model for Code Generation.

References

MISRA C:2012

Last ChangedR2015b

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?