Model Configuration Parameters: Comments

The Code Generation > Comments category includes parameters for configuring the comments in the generated code. These parameters require a Simulink® Coder™ license. Additional parameters available with an ERT-based target require an Embedded Coder® license.

Code Comments are generated automatically or you can add them to the code.

Code comments have the following uses:

  • Enhance the readability and traceability of code

  • Convey information among users

  • Enhance code search in code base

Code Comments can be classified into Auto generated and Custom comments. Auto generated comments are automatically generated by the software during code generation and the user adds Custom comments.

On the Configuration Parameters dialog box, the following configuration parameters are on the Code Generation > Comments pane.

Auto generated comments

ParameterDescription

Include comments (Simulink Coder)

Specify which comments are in generated files.

Simulink block comments (Simulink Coder)

Specify whether to insert Simulink block comments.

Trace to model using

Specify format of comments for Simulink blocks, Stateflow® elements and MATLAB® function blocks.

Stateflow object comments (Simulink Coder)

Specify whether to insert Stateflow object comments.

MATLAB source code as comments (Simulink Coder)

Specify whether to insert MATLAB source code as comments.

Show eliminated blocks (Simulink Coder)

Specify whether to insert eliminated block's comments.

Verbose comments for 'Model default' storage class (Simulink Coder)

Reduce code size or improve code traceability by controlling the generation of comments.

Operator annotations

Specify whether to include operator annotations for Polyspace® in the generated code as comments.

Custom comments

ParameterDescription

Simulink block descriptions

Specify whether to insert descriptions of blocks into generated code as comments.

Stateflow object descriptions

Specify whether to insert descriptions of Stateflow objects into generated code as comments.

Simulink data object descriptions

Specify whether to insert descriptions of Simulinkdata objects into generated code as comments.

Requirements in block comments

Specify whether to include requirement descriptions assigned to Simulink blocks in generated code as comments.

Custom comments (MPT objects only)

Specify whether to include custom comments for module packaging tool (MPT) signal and parameter data objects in generated code.

MATLAB user comments

Specify whether to include MATLAB user comments as comments.

Custom comments function

Specify a file that contains comments to be included in generated code for module packing tool (MPT) signal and parameter data objects.

The following configuration parameters are under the Advanced parameters.

ParameterDescription

Comment style

Specify a multi-line or single-line comment style for generated C or C++ code.

Insert Polyspace comments

Specify whether to insert code comments for Polyspace block annotations.

  • The code generation software automatically inserts comments into the generated code for custom blocks. Therefore, you do not need to include block comments in the associated TLC file for a custom block.

    Note

    If you have existing TLC files with manually inserted comments for block descriptions, the code generation process emits these comments instead of the automatically generated comments. Consider removing existing block comments from your TLC files. Manually inserted comments might be poorly formatted in the generated code and code-to-model traceability might not work.

  • For virtual blocks or blocks that have been removed due to block reduction, comments are not generated.

  • When you configure the code generator to produce code that includes comments, the code generator includes text for model parameters, block names, signal names, and Stateflow object names in the generated code comments. If the text includes characters that are unrepresented in the character set encoding for the model, the code generator replaces the characters with XML escape sequences. For example, the code generator replaces the Japanese full-width Katakana letter ア with the escape sequence ア. For more information, see Internationalization and Code Generation (Simulink Coder).

Related Topics