Code Generation

hisl_0051: Configuration Parameters > Code Generation > Optimization > Loop unrolling threshold

ID: Titlehisl_0051: Configuration Parameters > Code Generation > Optimization > Loop unrolling threshold
Description

To set the minimum signal or parameter width for generating a for loop, set configuration parameter Loop unrolling threshold to 2 or greater.

Notes

Loop unrolling threshold specifies the array size at which the code generator begins to use a for loop, instead of separate assignment statements, to assign values to the elements of a signal or parameter array. The default value is 5.

RationaleSupport unambiguous generated code.
Model Advisor ChecksCheck safety-related optimization settings for Loop unrolling threshold (Simulink Check)
References
  • DO-331 Section MB.6.3.4.e—Source code is traceable to low-level requirements.

    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'
    ISO 26262-6, Table 1 (1d) 'Use of defensive implementation techniques'

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

  • MISRA C:2012, Rule 6.1

See Also

Loop unrolling threshold (Simulink Coder) in the Simulink® documentation

Last ChangedR2018a

hisl_0052: Configuration Parameters > Code Generation > Optimization > Data initialization

ID: Titlehisl_0052: Configuration Parameters > Code Generation > Optimization > Data initialization
Description

To support complete definition of data and initialize internal and external data to zero, clear these configuration parameters:

ARemove root level I/O zero initialization.
BRemove internal data zero initialization.
Note

Explicitly initialize all variables. If the run-time environment of the target system provides mechanisms to initialize all I/O and state variables, consider using the initialization of the target as an alternative to the suggested settings.

These configuration parameters are applicable only when the System target file is an ERT-based target.

RationaleA, BSupport fully defined data in generated code.
Model Advisor ChecksCheck safety-related optimization settings for data initialization (Simulink Check)
References
  • DO-331, Section MB.6.3.3.b 'Software architecture is consistent’

  • IEC 61508-3, Table A.4 (3) 'Defensive Programming’

  • IEC 62304, 5.5.3 - Software Unit acceptance criteria

  • ISO 26262-6, Table 1 (1d) 'Use of defensive implementation techniques'

  • EN 50128, Table A.3 (1) 'Defensive Programming'

See Also

Information about the following parameters in the Simulink documentation:

Last ChangedR2018b

hisl_0053: Configuration Parameters > Code Generation > Optimization > Remove code from floating-point to integer conversions that wraps out-of-range values

ID: Titlehisl_0053: Configuration Parameters > Code Generation > Optimization > Remove code from floating-point to integer conversions that wraps out-of-range values
Description

To support verifiable code, select configuration parameter Remove code from floating-point to integer conversions that wraps out-of-range values

Notes

Avoid overflows as opposed to handling them with wrapper code.

For blocks whose Saturate on integer overflow configuration parameter is cleared, deselecting Remove code from floating-point to integer conversions that wraps out-of-range values can add code that wraps out of range values, resulting in unreachable code that cannot be tested.

RationaleSupport generation of code that can be verified.
Model Advisor ChecksCheck safety-related optimization settings for data type conversions (Simulink Check)
References
  • DO-331, Section MB.6.3.1.g 'Algorithms are accurate’
    DO-331, Section MB.6.3.2.g 'Algorithms are accurate’

  • IEC 61508-3, Table A.4 (3) 'Defensive Programming’

  • IEC 62304, 5.5.3 - Software Unit acceptance criteria

  • ISO 26262-6, Table 1 (1d) 'Use of defensive implementation techniques'

  • EN 50128, Table A.3 (1) 'Defensive Programming'

  • MISRA C:2012, Rule 2.1

See AlsoRemove code from floating-point to integer conversions that wraps out-of-range values (Simulink Coder) in the Simulink documentation
Last ChangedR2018b

hisl_0054: Configuration Parameters > Code Generation > Optimization > Remove code that protects against division arithmetic exceptions

ID: Titlehisl_0054: Configuration Parameters > Code Generation > Optimization > Remove code that protects against division arithmetic exceptions
Description

To support the robustness of the operations, clear configuration parameter Remove code that protects against division arithmetic exceptions.

Note

Avoid division-by-zero exceptions. If you clear Remove code that protects against division arithmetic exceptions, the code generator produces code that guards against division by zero for fixed-point data.

This configuration parameter is applicable only when the System target file is an ERT-based target.

RationaleProtect against divide-by-zero exceptions for fixed-point code.
Model Advisor ChecksCheck safety-related optimization settings for division arithmetic exceptions (Simulink Check)
References
  • DO-331, Section MB.6.3.1.g 'Algorithms are accurate’
    DO-331, Section MB.6.3.2.g 'Algorithms are accurate’

  • IEC 61508-3, Table A.3 (3) 'Language Subset’
    IEC 61508-3 Table A.4 (3) 'Defensive Programming’

  • IEC 62304, 5.5.3 - Software Unit acceptance criteria

  • ISO 26262-6, Table 1(b) 'Use of language subsets'
    ISO 26262-6, Table 1(d) 'Use of defensive implementation techniques'

  • EN 50128, Table A.4 (11) 'Language Subset'
    EN 50128, Table A.3 (1) 'Defensive Programming'

  • MISRA C:2012, Dir 4.1

See AlsoRemove code that protects against division arithmetic exceptions (Embedded Coder) in the Simulink documentation
Last ChangedR2018b

hisl_0056: Configuration Parameters > Code Generation > Optimization > Optimize using the specified minimum and maximum values

ID: Titlehisl_0056: Configuration Parameters > Code Generation > Optimization > Optimize using the specified minimum and maximum values
DescriptionTo support verifiable code, clear configuration parameter Optimize using the specified minimum and maximum values.
NotesSelecting Optimize using the specified minimum and maximum values can result in requirements without associated code and violates traceability objectives.
RationaleSupport traceability between a model and generated code.
Model Advisor ChecksCheck safety-related optimization settings for specified minimum and maximum values (Simulink Check)
References
  • DO-331 Section MB.MB.6.3.4.e 'Source code is traceable to low-level requirements’'

  • IEC 61508-3, Table A.4 (3) 'Defensive Programming’

  • IEC 62304, 5.5.3 - Software Unit acceptance criteria

  • ISO 26262-6, Table 1 (1d) 'Use of defensive implementation techniques

  • EN 50128, Table A.3 (1) 'Defensive Programming'

See also
Last ChangedR2018b

hisl_0038: Configuration Parameters > Code Generation > Comments

ID: Titlehisl_0038: Configuration Parameters > Code Generation > Comments
Description

In the Configuration Parameters dialog box, on the Code Generation > Comments pane, select these parameters:

A

Include comments.

B

Simulink block comments.

C

Show eliminated blocks.

D

Verbose comments for 'Model default' storage class.

E

Requirements in block comments.

RationaleA

Including comments provides good traceability between the code and the model.

B

Including comments that describe the code for blocks provides good traceability between the code and the model.

C

Including comments that describe the code for blocks eliminated from a model provides good traceability between the code and the model.

D

Including the names of parameter variables and source blocks as comments in the model parameter structure declaration in model_prm.h provides good traceability between the code and the model.

E

Including requirement descriptions assigned to Simulink blocks as comments provides good traceability between the code and the model.

Model Advisor ChecksCheck safety-related code generation settings for comments (Simulink Check)
References
  • DO-331, Section MB.6.3.4.e 'Source code is traceable to low-level requirements‘

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

  • IEC 62304, 5.5.3 - Software Unit acceptance criteria

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

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

Last ChangedR2017b

hisl_0039: Configuration Parameters > Code Generation > Interface

ID: Titlehisl_0039: Configuration Parameters > Code Generation > Interface
Description

For models used to develop high-integrity systems, in the Configuration Parameters dialog box, on the Code Generation > Interface pane, set the Software environment, Code interface, and Data exchange interface parameters as follows:

A

Clear Support: non-finite numbers.

B

Clear Support: absolute time.

C

Clear Support: continuous time.

D

Clear Support: non-inlined S-functions.

E

Clear Classic call interface.

F

Select Single output / update function.

G

Clear Terminate function required.

H

Select Remove error status field in real-time model data structure.

I

Clear MAT-file logging.

RationaleA

Support for non-finite numbers is not recommended for real-time safety-related systems.

B

Support for absolute time is not recommended for real-time safety-related systems.

C

Support for continuous time is not recommended for real-time safety-related systems.

D

Support for non-inlined S-functions requires support of non-finite numbers, which is not recommended for real-time safety-related systems.

E

To eliminate model function calls compatible with the main program module of the pre-2012a GRT target that is not recommended for real-time safety-related systems; use an ERT based target instead.

F

To simplify the interface to the real-time operating system (RTOS) and simplify verification of the generated code by creating a single call to both the output and update functions.

G

To eliminate model_terminate function, which is not recommended for real-time safety-related systems.

H

To eliminate extra code for logging and monitoring error status that might not be reachable for testing.

I

To eliminate extra code for logging test points to a MAT file that is not supported by embedded targets.

Model Advisor ChecksCheck safety-related code generation interface settings (Simulink Check)
References
  • DO-331, Section MB.6.3.1.c 'High-level requirements are compatible with target computer’
    DO-331, Section MB.6.3.2.c ‘Low-level requirements are compatible with target computer

  • 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'

Last ChangedR2018b

hisl_0047: Configuration Parameters > Code Generation > Code Style

ID: Titlehisl_0047: Configuration Parameters > Code Generation > Code Style
Description

In the Configuration Parameters dialog box, on the Code Generation > Code Style pane, set these parameters:

A

Set Parentheses level (Embedded Coder) to Maximum (Specify precedence with parentheses).

B

Select Preserve operand order in expression (Embedded Coder).

NoteThese configuration parameters are available when configuration parameter System target file (Simulink Coder) is set to ert.tlc.
RationaleA

To prevent unexpected results.

B

To improve traceability of the generated code.

Model Advisor ChecksCheck safety-related code generation settings for code style (Simulink Check)
References
  • DO-331, Section MB.6.3.1.c 'High-level requirements are compatible with target computer’
    DO-331, Section MB.6.3.2.c ‘Low-level requirements are compatible with target computer
    DO-331, Section MB.6.3.4.e ‘Source code is traceable to low-level requirements’

  • 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, Rule 12.1

See AlsoModel Configuration Parameters: Code Style (Embedded Coder)
Last ChangedR2019b

hisl_0049: Configuration Parameters > Code Generation > Identifiers

ID: Titlehisl_0049: Configuration Parameters > Code Generation > Identifiers
DescriptionTo minimize the likelihood that parameter and signal names will change during code generation when the model changes, set configuration parameter Minimum mangle length to 4 or greater.
Rationale

Decrease the effort to perform code review.

Model Advisor ChecksCheck safety-related code generation identifier settings (Simulink Check)
References
  • DO-331, Section MB.6.3.4.e ‘Source code is traceable to low-level requirements’

  • 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'

Last ChangedR2019a