Real-Time Workshop | ![]() ![]() |
General Code Appearance Options
The General code appearance options
control formatting of source code and construction of identifiers. This interface is shown below.
Maximium Identifier Length Option
The Maximium identifier length field allows you to limit the number of characters in function, typedef, and variable names. The default is 31 characters, but Real-Time Workshop imposes no upper limit.You may choose to increase this length for models with deep hierarchical structure, as well as when exercising some of the mnemonic identifier options described below.
Include Data Type Acronym in Identifier Option
Selecting Include data type acronym in identifier enables you to prepend acronyms such as i32
(for long integers) to signal and work vector identifiers to make code more readable. The default is not to include datatype acronyms in identifiers. For example, with this option selected, Real-Time Workshop identifies a scalar double signal from a discrete pulse generator as follows:
{ /* local block i/o variables */ real_T rtb_r64_A_Pulse; . . . rtY.Out1 = (rtP.A_Gain_Gain * rtb_r64_A_Pulse); }
Include System Hierarchy Number in Identifiers Option
When this option is selected, Real-Time Workshop inserts identification tags in the generated code (in addition to tags included in comments). The tags are designed to help you identify the nesting level, within your source model, of the block that generated a given line of code.
When this option is ON
, the tag format is either
root_
for root-level blocks; or
sN_
where N
is a unique system number assigned by Simulink, for blocks at the subsystem level.
By default, Include system hierarchy number in identifiers is OFF
, in order to generate more compact code.
As an example, consider hier.mdl
, the model in this picture.
The subsystem within hier.mdl
is shown in the picture below.
With Include system hierarchy number in identifiers on, the following code is generated for the Out1 block of hier.mdl
. The code includes the tag s1_ in the symbols generated for the subsystem, and the tag root_ in the symbol generated for the root-level Out1 block.
/* Outport: <Root>/Out1 incorporates: * Gain: <S1>/A_Gain * * Regarding <S1>/A_Gain: * Gain value: hier_P.s1_A_Gain_Gain */ hier_Y.root_Out1 = (hier_P.s1_A_Gain_Gain * rtb_s1_A_Pulse);
This code, generated with Include system hierarchy number in identifiers off, does not contain a subsystem tag in the generated symbols.
/* Outport: <Root>/Out1 incorporates: * Gain: <S1>/A_Gain * * Regarding <S1>/A_Gain: * Gain value: hier_P.A_Gain_Gain */ hier_Y.Out1 = (hier_P.A_Gain_Gain * rtb_A_Pulse);
See Tracing Generated Code Back to Your Simulink Model for further information on using system and block identification tags.
Prefix Model Name to Global Identifiers Option
When this option is selected, subsystem function names are prefixed with the name of the model (model
_
) for all code formats. In addition, when appropriate to the code format, the model name is also prefixed to the names of functions and data structures at the model level. This is useful when you need to compile and link code from two or more models into a single executable, as it avoids potential name clashes. Prefix model name to global identifiers is ON
by default.
Generate Scalar Inlined Parameters as Option
When the Inline Parameters Option is selected and signals are scalars having constant sample time, this pull-down menu enables you to control how parameters are expressed in the code. There are two choices for this option:
Literals
-- parameters are expressed as numeric constants
Macros
-- parameters are expressed as variables (via #define
macros)
The default is Literals
. This provides backward compatibility to prior versions of Real-Time Workshop, which lacked this option. It also may help in debugging TLC code, as it makes the values of parameters easy to search for. The Macros
option, on the other hand, may make code more readable.
By default, Generate comments is ON
. If this option is OFF
, generation of comments in the code is completely suppressed. The Show eliminated statements and Force generation of parameter comments options in the General code generation
category enable the inclusion of those specific types of comments.
![]() | General Code Generation Options | Target-specific Code Generation Options | ![]() |