Main Content

hisl_0032: Model element names

R2026b

Naming conventions for model elements that produce valid identifiers in generated code

Usage: High-Integrity System Modeling

Guideline ID: hisl_0032

Rules

hisl_0032: Model element names

For these types of model elements:

  • Signal labels

  • Parameters

  • Blocks

  • Named Stateflow® objects (states, boxes, Simulink® functions, graphical functions, truth tables)

And, these types of architecture model objects:

  • Components

  • Ports

  • Connectors

  • Interfaces

  • Stereotypes

Use:

  • These characters: a-z, A-Z, 0-9, and the underscore (_).

  • Strings with less than 32 characters or another character limit set by Maximum identifier length (Simulink Coder).

Do not:

  • Start the name with a number.

  • Use underscores at the beginning or end of a string.

  • Use more than one consecutive underscore.

  • Use reserved identifiers.

Rationale

The code generator might remove or mangle invalid characters when producing an identifier in generated code.

Verification

Check model object names (Simulink Check)

Example — Correct

  • Block name: My_Controller

  • Signal name: a_b

Example — Incorrect

  • Block name: My Controller

  • Signal name: 12a__b

Tips

  • Reserved names:

    • MATLAB® keywords

    • Reserved keywords for C, C++, and code generation. For complete list, see Reserved Keywords (Simulink Coder).

    • int8, uint8

    • int16, uint16

    • int32, uint32

    • int64, uint64

    • inf, Inf

    • NaN, nan

    • eps

    • intmin, intmax

    • realmin, realmax

    • pi

    • infinity

    • Nil

  • The MATLAB limit for the number of characters you can use in model element names is 2048.

Industry Standards

  • MISRA C:2012, Rule 5.1

  • MISRA C:2023, Rule 5.1

  • MISRA C:2012, Rule 21.2

  • MISRA C:2023, Rule 21.2

  • ISO 26262-6, Table 1 (1h) 'Use of naming conventions'

  • DO-331, Section MB.6.3.2.e – 'Low-level requirements conform to standards'

    DO-331, MB.6.3.3.e 'Software architecture conforms to standards'

  • DCL37-C. Do not declare or define a reserved identifier

Version History

Introduced in R2016a

expand all