rtw_ref
rtw_ref
rtw_ref
Reference
R2017a
How to Contact MathWorks
Phone: 508-647-7000
The bug reports are an integral part of the documentation for each release. Examine
periodically all bug reports for a release, as such reports may identify inconsistencies
between the actual behavior of a release you are using and the behavior described in this
documentation.
In addition to reviewing bug reports, you should implement a verification and validation
strategy to identify potential bugs in your design, code, and tools.
Contents
Alphabetical List
2
vii
Browse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Tip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
Tool/Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 4-16
viii Contents
Custom compiler optimization flags . . . . . . . . . . . . . . . . . . . 4-20
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 4-20
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
ix
Set Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-31
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-31
Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-31
x Contents
Code Generation Parameters: Report
5
Model Configuration Parameters: Code Generation Report 5-2
xi
Code Generation Parameters: Comments
6
Model Configuration Parameters: Code Generation
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
xii Contents
Operator annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15
Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 6-15
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16
xiii
Requirements in block comments . . . . . . . . . . . . . . . . . . . . . 6-27
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27
Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-28
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 6-28
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-28
xiv Contents
Field name of global types . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 7-12
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
xv
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-23
Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 7-24
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-25
xvi Contents
Signal naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-41
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-41
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-41
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-41
Limitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-42
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 7-42
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-42
M-function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43
Tip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-44
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-44
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 7-44
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-44
M-function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47
Tip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-48
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-48
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 7-48
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-48
M-function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-51
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-51
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-51
Tip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-52
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-52
xvii
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 7-52
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-52
xviii Contents
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16
Limitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16
Tip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 8-16
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16
Defines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 8-18
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
xix
Code Generation Parameters: Interface
9
Model Configuration Parameters: Code Generation
Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
xx Contents
Support: absolute time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-17
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-17
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-17
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-17
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 9-17
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-18
xxi
Remove error status field in real-time model data
structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-32
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-32
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-32
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-32
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 9-32
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-33
xxii Contents
Generate C API for: parameters . . . . . . . . . . . . . . . . . . . . . . 9-44
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-44
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-44
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . . 9-44
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-44
xxiii
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-57
xxiv Contents
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-12
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . 10-12
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-12
Code-to-model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . 10-14
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-15
Model-to-code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-16
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-16
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-16
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-16
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . 10-17
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17
Configure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18
Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18
xxv
Traceable MATLAB functions . . . . . . . . . . . . . . . . . . . . . . . 10-25
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . 10-25
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25
xxvi Contents
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . 10-36
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-36
xxvii
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-48
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-48
Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-49
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . 10-49
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-49
xxviii Contents
Verbose build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-62
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-62
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-62
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . 10-62
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-62
xxix
Command-Line Information . . . . . . . . . . . . . . . . . . . . . . . 10-74
Recommended Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-74
xxx Contents
Code Generation Pane: Tornado Target . . . . . . . . . . . . . . . 11-14
Code Generation: Tornado Target Tab Overview . . . . . . . . 11-16
Standard math library . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
Code replacement library . . . . . . . . . . . . . . . . . . . . . . . . . 11-19
Shared code placement . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-21
MAT-file logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23
MAT-file variable name modifier . . . . . . . . . . . . . . . . . . . . 11-25
Code Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
StethoScope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27
Download to VxWorks target . . . . . . . . . . . . . . . . . . . . . . . 11-29
Base task priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-31
Task stack size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-32
External mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-33
Transport layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-35
MEX-file arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-36
Static memory allocation . . . . . . . . . . . . . . . . . . . . . . . . . . 11-37
Static memory buffer size . . . . . . . . . . . . . . . . . . . . . . . . . 11-39
xxxi
I2C0 and I2C1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-75
Timer/PWM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-77
UART0, UART1, and UART2 . . . . . . . . . . . . . . . . . . . . . . 11-78
PIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-80
External mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-81
xxxii Contents
Identify blocks using one-based indexing . . . . . . . . . . . . . . . 12-4
Check solver for code generation . . . . . . . . . . . . . . . . . . . . . 12-5
Check for blocks not supported by code generation . . . . . . . 12-7
Check and update model to use toolchain approach to build
generated code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-8
Check and update embedded target model to use ert.tlc system
target file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-11
Check and update models that are using targets that
have changed significantly across different releases of
MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-13
Check for blocks that have constraints on tunable
parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-15
Check for model reference configuration mismatch . . . . . . 12-17
Check sample times and tasking mode . . . . . . . . . . . . . . . 12-18
Check for code generation identifier formats used for model
reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-18
Available Checks for Code Generation Objectives . . . . . . . 12-20
Identify questionable blocks within the specified system . . 12-26
Check model configuration settings against code generation
objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-27
xxxiii
Tools — Alphabetical List
14
xxxiv Contents
1
1-2
2
Alphabetical List
2 Alphabetical List
addCompileFlags
Add compiler options to model build information
Syntax
addCompileFlags(buildinfo, options, groups)
groups is optional.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
options
A character array or cell array of character arrays that specifies the compiler options
to be added to the build information. The function adds each option to the end of a
compiler option vector. If you specify multiple options within a single character array,
for example '-Zi -Wall', the function adds the options to the vector as a single
element. For example, if you add '-Zi -Wall' and then '-O3', the vector consists
of two elements, as shown below.
2-2
addCompileFlags
Note:
Description
The addCompileFlags function adds specified compiler options to the model build
information. The code generator stores the compiler options in a vector. The function
adds options to the end of the vector based on the order in which you specify them.
In addition to the required buildinfo and options arguments, you can use an optional
groups argument to group your options.
2-3
2 Alphabetical List
Examples
• Add the compiler option -O3 to build information myModelBuildInfo and place the
option in the group OPTS.
myModelBuildInfo = RTW.BuildInfo;
addCompileFlags(myModelBuildInfo, '-O3', 'OPTS');
• Add the compiler options -Zi and -Wall to build information myModelBuildInfo
and place the options in the group OPT_OPTS.
myModelBuildInfo = RTW.BuildInfo;
addCompileFlags(myModelBuildInfo, '-Zi -Wall', 'OPT_OPTS');
• For a non-makefile build environment, add the compiler options -Zi, -Wall, and -
O3 to build information myModelBuildInfo. Place the options -Zi and -Wall in the
group Debug and the option -O3 in the group MemOpt.
myModelBuildInfo = RTW.BuildInfo;
addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'}, ...
{'Debug' 'MemOpt'});
See Also
addDefines | addLinkFlags | getCompileFlags
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-4
addDefines
addDefines
Add preprocessor macro definitions to model build information
Syntax
addDefines(buildinfo, macrodefs, groups)
groups is optional.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
macrodefs
A character array or cell array of character arrays that specifies the preprocessor
macro definitions to be added to the object. The function adds each definition to the
end of a compiler option vector. If you specify multiple definitions within a single
character array, for example '-DRT -DDEBUG', the function adds the options to the
vector as a single element. For example, if you add '-DPROTO -DDEBUG' and then
'-DPRODUCTION', the vector consists of two elements, as shown below.
2-5
2 Alphabetical List
Note: To specify macro definitions to be used in the standard code generator makefile
build process, specify groups as either 'OPTS' or 'OPT_OPTS'.
Description
The addDefines function adds specified preprocessor macro definitions to the model
build information. The code generator stores the definitions in a vector. The function
adds definitions to the end of the vector based on the order in which you specify them.
In addition to the required buildinfo and macrodefs arguments, you can use an
optional groups argument to group your options.
Examples
• Add the macro definition -DPRODUCTION to build information myModelBuildInfo
and place the definition in the group OPTS.
myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, '-DPRODUCTION', 'OPTS');
• Add the macro definitions -DPROTO and -DDEBUG to build information
myModelBuildInfo and place the definitions in the group OPT_OPTS.
myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, ...
'-DPROTO -DDEBUG', 'OPT_OPTS');
• For a non-makefile build environment, add the macro definitions -DPROTO, -DDEBUG,
and -DPRODUCTION to build information myModelBuildInfo. Place the definitions
-DPROTO and -DDEBUG in the group Debug and the definition -DPRODUCTION in the
group Release.
2-6
addDefines
myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, ...
{'-DPROTO -DDEBUG' '-DPRODUCTION'}, ...
{'Debug' 'Release'});
See Also
addCompileFlags | addLinkFlags | getDefines
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-7
2 Alphabetical List
addIncludeFiles
Add include files to model build information
Syntax
addIncludeFiles(buildinfo, filenames, paths, groups)
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
filenames
A character array or cell array of character arrays that specifies names of include
files to be added to the build information.
The filename text can include wildcard characters, provided that the dot delimiter (.)
is present. Examples are '*.*', '*.h', and '*.h*'.
The function adds the filenames to the end of a vector in the order that you specify
them.
2-8
addIncludeFiles
A character array or cell array of character arrays that groups specified include files.
You can use groups to
Description
The addIncludeFiles function adds specified include files to the model build
information. The code generator stores the include files in a vector. The function adds the
filenames to the end of the vector in the order that you specify them.
In addition to the required buildinfo and filenames arguments, you can specify
optional paths and groups arguments. You can specify each optional argument as a
character array or a cell array of character arrays.
If You Specify an Optional The Function...
Argument as a...
Character array Applies the character array to include files it adds to the build
information
Cell array of character arrays Pairs each character array with a specified include file. Thus,
the length of the cell array must match the length of the cell
array you specify for filenames.
If you choose to specify groups, but omit paths, specify a null character vector ('') for
paths.
2-9
2 Alphabetical List
Note: The packNGo function also can add include files to the model build information. If
you call the packNGo function to package model code, packNGo finds include files from
source and include paths recorded in the model build information and adds them to the
build information.
Examples
• Add the include file mytypes.h to build information myModelBuildInfo and place
the file in the group SysFiles.
myModelBuildInfo = RTW.BuildInfo;
addIncludeFiles(myModelBuildInfo, ...
'mytypes.h', '/proj/src', 'SysFiles');
• Add the include files etc.h and etc_private.h to build information
myModelBuildInfo and place the files in the group AppFiles.
myModelBuildInfo = RTW.BuildInfo;
addIncludeFiles(myModelBuildInfo, ...
{'etc.h' 'etc_private.h'}, ...
'/proj/src', 'AppFiles');
• Add the include files etc.h, etc_private.h, and mytypes.h to build information
myModelBuildInfo. Group the files etc.h and etc_private.h with the character
vector AppFiles and the file mytypes.h with the character vector SysFiles.
myModelBuildInfo = RTW.BuildInfo;
addIncludeFiles(myModelBuildInfo, ...
{'etc.h' 'etc_private.h' 'mytypes.h'}, ...
'/proj/src', ...
{'AppFiles' 'AppFiles' 'SysFiles'});
• Add the .h files in a specified folder to build information myModelBuildInfo and
place the files in the group HFiles.
myModelBuildInfo = RTW.BuildInfo;
addIncludeFiles(myModelBuildInfo, ...
'*.h', '/proj/src', 'HFiles');
See Also
addIncludePaths | addSourceFiles | addSourcePaths | findIncludeFiles |
getIncludeFiles | updateFilePathsAndExtensions | updateFileSeparator
2-10
addIncludeFiles
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-11
2 Alphabetical List
addIncludePaths
Add include paths to model build information
Syntax
addIncludePaths(buildinfo, paths, groups)
groups is optional.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
paths
A character array or cell array of character arrays that specifies include file paths to
be added to the build information. The function adds the paths to the end of a vector
in the order that you specify them.
2-12
addIncludePaths
Description
The addIncludePaths function adds specified include paths to the model build
information. The code generator stores the include paths in a vector. The function adds
the paths to the end of the vector in the order that you specify them.
In addition to the required buildinfo and paths arguments, you can specify an
optional groups argument. You can specify groups as a character array or a cell array
of character arrays.
Examples
• Add the include path /etcproj/etc/etc_build to build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addIncludePaths(myModelBuildInfo,...
2-13
2 Alphabetical List
'/etcproj/etc/etc_build');
• Add the include paths /etcproj/etclib and /etcproj/etc/etc_build to build
information myModelBuildInfo and place the files in the group etc.
myModelBuildInfo = RTW.BuildInfo;
addIncludePaths(myModelBuildInfo,...
{'/etcproj/etclib' '/etcproj/etc/etc_build'},'etc');
• Add the include paths /etcproj/etclib, /etcproj/etc/etc_build, and /
common/lib to build information myModelBuildInfo. Group the paths /etc/proj/
etclib and /etcproj/etc/etc_build with the character vector etc and the path
/common/lib with the character vector shared.
myModelBuildInfo = RTW.BuildInfo;
addIncludePaths(myModelBuildInfo,...
{'/etc/proj/etclib' '/etcproj/etc/etc_build'...
'/common/lib'}, {'etc' 'etc' 'shared'});
See Also
addIncludeFiles | addSourceFiles | addSourcePaths | getIncludePaths |
updateFilePathsAndExtensions | updateFileSeparator
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-14
addLinkFlags
addLinkFlags
Add link options to model build information
Syntax
addLinkFlags(buildinfo, options, groups)
groups is optional.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
options
A character array or cell array of character arrays that specifies the linker options
to be added to the build information. The function adds each option to the end of
a linker option vector. If you specify multiple options within a single character
array, for example '-MD -Gy', the function adds the string to the vector as a single
element. For example, if you add '-MD -Gy' and then '-T', the vector consists of
two elements, as shown below.
2-15
2 Alphabetical List
Note: To specify linker options to be used in the standard code generator makefile
build process, specify groups as either 'OPTS' or 'OPT_OPTS'.
Description
The addLinkFlags function adds specified linker options to the model build
information. The code generator stores the linker options in a vector. The function adds
options to the end of the vector based on the order in which you specify them.
In addition to the required buildinfo and options arguments, you can use an optional
groups argument to group your options.
Examples
• Add the linker -T option to build information myModelBuildInfo and place the
option in the group OPTS.
myModelBuildInfo = RTW.BuildInfo;
addLinkFlags(myModelBuildInfo, '-T', 'OPTS');
• Add the linker options -MD and -Gy to build information myModelBuildInfo and
place the options in the group OPT_OPTS.
myModelBuildInfo = RTW.BuildInfo;
addLinkFlags(myModelBuildInfo, '-MD -Gy', 'OPT_OPTS');
• For a non-makefile build environment, add the linker options -MD, -Gy, and -T to
build information myModelBuildInfo. Place the options -MD and-Gy in the group
Debug and the option -T in the groupTemp.
myModelBuildInfo = RTW.BuildInfo;
2-16
addLinkFlags
See Also
addCompileFlags | addDefines | getLinkFlags
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-17
2 Alphabetical List
addLinkObjects
Add link objects to model build information
Syntax
addLinkObjects(buildinfo, linkobjs, paths, priority, precompiled, linkonly, groups)
Arguments except buildinfo , linkobjs, and paths are optional. If you specify an
optional argument, you must specify the optional arguments preceding it.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
linkobjs
A character array or cell array of character arrays that specifies the filenames of
linkable objects to be added to the build information. The function adds the filenames
that you specify in the function call to a vector that stores the object filenames
in priority order. If you specify multiple objects that have the same priority (see
priority below), the function adds them to the vector based on the order in which
you specify the object filenames in the cell array.
2-18
addLinkObjects
A numeric value or vector of numeric values that indicates the relative priority of
each specified link object. Lower values have higher priority. The default priority is
1000.
precompiled (optional)
The logical value true or false, or a vector of logical values that indicates whether
each specified link object is precompiled.
Specify true if the link object has been prebuilt for faster compiling and linking and
exists in a specified location.
If precompiled is false (the default), the build process creates the link object in the
build folder.
Specify true if the build process should not build, nor generate rules in the makefile
for building, the specified link object, but should include it when linking the final
executable. For example, you can use this to incorporate link objects for which source
files are not available. If linkonly is true, the value of precompiled is ignored.
If linkonly is false (the default), rules for building the link objects are added
to the makefile. In this case, the value of precompiled determines which
subsection of the added rules is expanded, START_PRECOMP_LIBRARIES (true) or
START_EXPAND_LIBRARIES (false). The software performs the expansion of the
START_PRECOMP_LIBRARIES or START_EXPAND_LIBRARIES macro only if your code
generation target uses the template makefile approach for building code.
groups (optional)
A character array or cell array of character arrays that groups specified link objects.
You can use groups to
2-19
2 Alphabetical List
Description
The addLinkObjects function adds specified link objects to the model build
information. The code generator stores the link objects in a vector in relative priority
order. If multiple objects have the same priority or you do not specify priorities, the
function adds the objects to the vector based on the order in which you specify them.
In addition to the required buildinfo, linkobjs, and paths arguments, you can
specify the optional arguments priority, precompiled, linkonly, and groups. You
can specify paths and groups as a character array or a cell array of character arrays.
Similarly, you can specify priority, precompiled, and linkonly as a value or vector
of values.
2-20
addLinkObjects
If you choose to specify an optional argument, you must specify optional arguments
preceding it. For example, to specify that objects are precompiled using the
precompiled argument, you must specify the priority argument that precedes
precompiled. You could pass the default priority value 1000, as shown below.
addLinkObjects(myBuildInfo, 'test1', '/proj/lib/lib1', 1000, true);
Examples
• Add the linkable objects libobj1 and libobj2 to build information
myModelBuildInfo and set the priorities of the objects to 26 and 10, respectively.
Since libobj2 is assigned the lower numeric priority value, and thus has the higher
priority, the function orders the objects such that libobj2 precedes libobj1 in the
vector.
myModelBuildInfo = RTW.BuildInfo;
addLinkObjects(myModelBuildInfo, {'libobj1' 'libobj2'},...
{'/proj/lib/lib1' '/proj/lib/lib2'}, [26 10]);
• Add the linkable objects libobj1 and libobj2 to build information
myModelBuildInfo. Mark both objects as link-only. Since individual priorities are
not specified, the function adds the objects to the vector in the order specified.
myModelBuildInfo = RTW.BuildInfo;
addLinkObjects(myModelBuildInfo, {'libobj1' 'libobj2'},...
{'/proj/lib/lib1' '/proj/lib/lib2'}, 1000,...
false, true);
• Add the linkable objects libobj1 and libobj2 to build information
myModelBuildInfo. Set the priorities of the objects to 26 and 10, respectively. Mark
both objects as precompiled, and group them under the name MyTest.
myModelBuildInfo = RTW.BuildInfo;
addLinkObjects(myModelBuildInfo, {'libobj1' 'libobj2'},...
{'/proj/lib/lib1' '/proj/lib/lib2'}, [26 10],...
true, false, 'MyTest');
2-21
2 Alphabetical List
See Also
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-22
addNonBuildFiles
addNonBuildFiles
Add nonbuild-related files to model build information
Syntax
addNonBuildFiles(buildinfo, filenames, paths, groups)
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
filenames
A character array or cell array of character arrays that specifies names of nonbuild-
related files to be added to the build information.
The filename text can include wildcard characters, provided that the dot delimiter (.)
is present. Examples are '*.*', '*.DLL', and '*.D*'.
The function adds the filenames to the end of a vector in the order that you specify
them.
2-23
2 Alphabetical List
A character array or cell array of character arrays that groups specified nonbuild
files. You can use groups to
Description
The addNonBuildFiles function adds specified nonbuild-related files, such as DLL files
required for a final executable, or a README file, to the model build information. The
code generator stores the nonbuild files in a vector. The function adds the filenames to
the end of the vector in the order that you specify them.
In addition to the required buildinfo and filenames arguments, you can specify
optional paths and groups arguments. You can specify each optional argument as a
character array or a cell array of character arrays.
2-24
addNonBuildFiles
If you choose to specify groups, but omit paths, specify a null character vector ('') for
paths.
Examples
• Add the nonbuild file readme.txt to build information myModelBuildInfo and
place the file in the group DocFiles.
myModelBuildInfo = RTW.BuildInfo;
addNonBuildFiles(myModelBuildInfo, ...
'readme.txt', '/proj/docs', 'DocFiles');
• Add the nonbuild files myutility1.dll and myutility2.dll to build information
myModelBuildInfo and place the files in the group DLLFiles.
myModelBuildInfo = RTW.BuildInfo;
addNonBuildFiles(myModelBuildInfo, ...
{'myutility1.dll' 'myutility2.dll'}, ...
'/proj/dlls', 'DLLFiles');
• Add the DLL files in a specified folder to build information myModelBuildInfo and
place the files in the group DLLFiles.
myModelBuildInfo = RTW.BuildInfo;
addNonBuildFiles(myModelBuildInfo, ...
'*.dll', '/proj/dlls', 'DLLFiles');
See Also
getNonBuildFiles
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2008a
2-25
2 Alphabetical List
addSourceFiles
Add source files to model build information
Syntax
addSourceFiles(buildinfo, filenames, paths, groups)
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
filenames
A character array or cell array of character arrays that specifies names of the source
files to be added to the build information.
The filename text can include wildcard characters, provided that the dot delimiter (.)
is present. Examples are '*.*', '*.c', and '*.c*'.
The function adds the filenames to the end of a vector in the order that you specify
them.
2-26
addSourceFiles
groups (optional)
A character array or cell array of character arrays that groups specified source files.
You can use groups to
Description
The addSourceFiles function adds specified source files to the model build information.
The code generator stores the source files in a vector. The function adds the filenames to
the end of the vector in the order that you specify them.
In addition to the required buildinfo and filenames arguments, you can specify
optional paths and groups arguments. You can specify each optional argument as a
character array or a cell array of character arrays.
2-27
2 Alphabetical List
If you choose to specify groups, but omit paths, specify a null character vector ('') for
paths.
Examples
• Add the source file driver.c to build information myModelBuildInfo and place the
file in the group Drivers.
myModelBuildInfo = RTW.BuildInfo;
addSourceFiles(myModelBuildInfo, 'driver.c', ...
'/proj/src', 'Drivers');
• Add the source files test1.c and test2.c to build information myModelBuildInfo
and place the files in the group Tests.
myModelBuildInfo = RTW.BuildInfo;
addSourceFiles(myModelBuildInfo, ...
{'test1.c' 'test2.c'}, ...
'/proj/src', 'Tests');
• Add the source files test1.c, test2.c, and driver.c to build information
myModelBuildInfo. Group the files test1.c and test2.c with the character
vector Tests and the file driver.c with the character vector Drivers.
myModelBuildInfo = RTW.BuildInfo;
addSourceFiles(myModelBuildInfo, ...
{'test1.c' 'test2.c' 'driver.c'}, ...
'/proj/src', ...
{'Tests' 'Tests' 'Drivers'});
• Add the .c files in a specified folder to build information myModelBuildInfo and
place the files in the group CFiles.
myModelBuildInfo = RTW.BuildInfo;
addIncludeFiles(myModelBuildInfo, ...
'*.c', '/proj/src', 'CFiles');
2-28
addSourceFiles
See Also
addIncludeFiles | addIncludePaths | addSourcePaths | getSourceFiles |
updateFilePathsAndExtensions | updateFileSeparator
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-29
2 Alphabetical List
addSourcePaths
Add source paths to model build information
Syntax
addSourcePaths(buildinfo, paths, groups)
groups is optional.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
paths
A character array or cell array of character arrays that specifies source file paths to
be added to the build information. The function adds the paths to the end of a vector
in the order that you specify them.
Note: The code generator does not check whether a specified path is valid.
groups (optional)
A character array or cell array of character arrays that groups specified source paths.
You can use groups to
2-30
addSourcePaths
2-31
2 Alphabetical List
Description
The addSourcePaths function adds specified source paths to the model build
information. The code generator stores the source paths in a vector. The function adds
the paths to the end of the vector in the order that you specify them.
In addition to the required buildinfo and paths arguments, you can specify an
optional groups argument . You can specify groups as a character array or a cell array
of character arrays.
Note: The code generator does not check whether a specified path is valid.
2-32
addSourcePaths
Examples
• Add the source path /etcproj/etc/etc_build to build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo,...
'/etcproj/etc/etc_build');
• Add the source paths /etcproj/etclib and /etcproj/etc/etc_build to build
information myModelBuildInfo and place the files in the group etc.
myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo,...
{'/etcproj/etclib' '/etcproj/etc/etc_build'}, 'etc');
• Add the source paths /etcproj/etclib, /etcproj/etc/etc_build, and /
common/lib to build information myModelBuildInfo. Group the paths /etc/proj/
etclib and /etcproj/etc/etc_build with the character vector etc and the path
/common/lib with the character vector shared.
myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo,...
{'/etc/proj/etclib' '/etcproj/etc/etc_build'...
'/common/lib'}, {'etc' 'etc' 'shared'});
See Also
addIncludeFiles | addIncludePaths | addSourceFiles | getSourcePaths |
updateFilePathsAndExtensions | updateFileSeparator
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-33
2 Alphabetical List
addTMFTokens
Add template makefile (TMF) tokens that provide build-time information for makefile
generation
Syntax
addTMFTokens(buildinfo, tokennames, tokenvalues, groups)
groups is optional.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
tokennames
A character array or cell array of character arrays that specifies names of TMF
tokens (for example, '|>CUSTOM_OUTNAME<|') to be added to the build information.
The function adds the token names to the end of a vector in the order that you specify
them.
If you specify a token name that already exists in the vector, the first instance takes
precedence and its value is used for replacement.
tokenvalues
A character array or cell array of character arrays that specifies TMF token values
corresponding to the previously-specified TMF token names. The function adds the
token values to the end of a vector in the order that you specify them.
groups (optional)
A character array or cell array of character arrays that groups specified TMF tokens.
You can use groups to
2-34
addTMFTokens
Description
Call the addTMFTokens function inside a post code generation command to provide
build-time information to help customize makefile generation. The tokens specified
in the addTMFTokens function call must be handled in the template makefile (TMF)
for the target selected for your model. For example, if your post code generation
command calls addTMFTokens to add a TMF token named |>CUSTOM_OUTNAME<| that
specifies an output file name for the build, the TMF must take action with the value of |
>CUSTOM_OUTNAME<| to achieve the desired result. (See “Examples” on page 2-36.)
The addTMFTokens function adds specified TMF token names and values to the model
build information. The code generator stores the TMF tokens in a vector. The function
adds the tokens to the end of the vector in the order that you specify them.
2-35
2 Alphabetical List
Examples
Inside a post code generation command, add the TMF token |>CUSTOM_OUTNAME<| and
its value to build information myModelBuildInfo, and place the token in the group
LINK_INFO.
myModelBuildInfo = RTW.BuildInfo;
addTMFTokens(myModelBuildInfo, ...
'|>CUSTOM_OUTNAME<|', 'foo.exe', 'LINK_INFO');
In the TMF for the target selected for your model, code such as the following uses the
token value to achieve the desired result:
CUSTOM_OUTNAME = |>CUSTOM_OUTNAME<|
...
target:
$(LD) -o $(CUSTOM_OUTNAME) ...
See Also
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2009b
2-36
coder.report.close
coder.report.close
Close HTML code generation report
Syntax
coder.report.close()
Description
coder.report.close() closes the HTML code generation report.
Examples
Close code generation report for a model
After opening a code generation report for rtwdemo_counter, close the report.
coder.report.close()
See Also
See Also
coder.report.generate | coder.report.open
Topics
“Reports for Code Generation”
Introduced in R2012a
2-37
2 Alphabetical List
coder.report.generate
Generate HTML code generation report
Syntax
coder.report.generate(model)
coder.report.generate(subsystem)
coder.report.generate(model,Name,Value)
Description
coder.report.generate(model) generates a code generation report for the model.
The build folder for the model must be present in the current working folder.
Examples
Generate Code Generation Report for Model
open rtwdemo_counter
Build the model. The model is configured to create and open a code generation report.
rtwbuild('rtwdemo_counter');
2-38
coder.report.generate
coder.report.close;
coder.report.generate('rtwdemo_counter');
open rtwdemo_counter
Build the subsystem. The model is configured to create and open a code generation
report.
rtwbuild('rtwdemo_counter/Amplifier');
coder.report.close;
coder.report.generate('rtwdemo_counter/Amplifier');
Generate a code generation report to include a static code metrics report after the build
process, without modifying the model.
open rtwdemo_hyperlinks
Build the model. The model is configured to create and open a code generation report.
rtwbuild('rtwdemo_hyperlinks');
coder.report.close;
2-39
2 Alphabetical List
Generate a code generation report that includes the static code metrics report.
coder.report.generate('rtwdemo_hyperlinks',
'GenerateCodeMetricsReport','on');
The code generation report opens. In the left navigation pane, click Static Code Metrics
Report to view the report.
Input Arguments
model — Model name
character vector
2-40
coder.report.generate
Example: 'GenerateWebview','on','GenerateCodeMetricsReport','on'
includes a model Web view and static code metrics in the code generation report.
Navigation
'IncludeHyperlinkInReport' — Code-to-model hyperlinks
‘off’ | ‘on’
Model Web view, specified as ‘on’ or ‘off’. Specify ‘on’ to include the model Web view in
the code generation report. For more information, see “Generate model Web view” on
page 5-9.
Example: ‘'GenerateWebview','on'’
Data Types: char
2-41
2 Alphabetical List
Summary of eliminated and virtual blocks, specified as ‘on’ or ‘off’. Specify ‘on’ to
include a summary of eliminated and virtual blocks in the code generation report. For
more information, see “Eliminated / virtual blocks” on page 10-19.
Example: ‘'GenerateTraceReport','on'’
Data Types: char
Summary of the Simulink blocks and the corresponding code location, specified as ‘on’
or ‘off’. Specify ‘on’ to include a summary of the Simulink blocks and the corresponding
code location in the code generation report. For more information, see “Traceable
Simulink blocks” on page 10-21.
Example: ‘'GenerateTraceReportSl','on'’
Data Types: char
Summary of the Stateflow objects and the corresponding code location, specified as ‘on’ or
‘off’. Specify ‘on’ to include a summary of Stateflow objects and the corresponding code
location in the code generation report. For more information, see “Traceable Stateflow
objects” on page 10-23.
Example: ‘'GenerateTraceReportSf','on'’
Data Types: char
Summary of the MATLAB functions and the corresponding code location, specified as ‘on’
or ‘off’. Specify ‘on’ to include a summary of the MATLAB objects and the corresponding
code location in the code generation report. For more information, see “Traceable
MATLAB functions” on page 10-25.
Example: ‘'GenerateTraceReportEml','on'’
2-42
coder.report.generate
Metrics
'GenerateCodeMetricsReport' — Static code metrics
‘off’ | ‘on’
Static code metrics, specified as ‘on’ or ‘off’. Specify ‘on’ to include static code metrics
in the code generation report. For more information, see “Static code metrics” on page
5-11.
Example: ‘'GenerateCodeMetricsReport','on'’
Data Types: char
See Also
See Also
coder.report.close | coder.report.open
Topics
“Reports for Code Generation”
“Generate a Code Generation Report”
“Generate Code Generation Report After Build Process”
Introduced in R2012a
2-43
2 Alphabetical List
coder.report.open
Open existing HTML code generation report
Syntax
coder.report.open(model)
coder.report.open(subsystem)
Description
coder.report.open(model) opens a code generation report for the model. The build
folder for the model must be present in the current working folder.
Examples
Open code generation report for a model
After generating code for rtwdemo_counter, open a code generation report for the
model.
coder.report.open('rtwdemo_counter')
Input Arguments
model — Model name
character vector
2-44
coder.report.open
See Also
See Also
coder.report.close | coder.report.generate
Topics
“Reports for Code Generation”
“Open Code Generation Report”
Introduced in R2012a
2-45
2 Alphabetical List
findBuildArg
Search for a specific build argument in model build information
Syntax
[identifier, value] = findBuildArg(buildinfo, buildArgName)
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
buildArgName
A character array which specifies the name of the build argument that you want to
find.
Output Arguments
Build argument found in the model build information. The function returns the build
argument in two vectors.
Vector Description
identifier Name of the build argument that the function finds
value Value of the build argument
Description
The findBuildArg function searches for a build argument stored in the model build
information. If the build argument is present in the model build information, the function
returns the name and value.
Examples
• Find a build argument and its value stored in build information myModelBuildInfo.
2-46
findBuildArg
load buildInfo.mat
myModelBuildInfo = buildInfo;
myBuildArgExtmodeStaticAlloc = 'EXTMODE_STATIC_ALLOC';
[buildArgId buildArgValue]=findBuildArg(buildInfo,myBuildArgExtmodeStaticAlloc);
buildArgId =
EXTMODE_STATIC_ALLOC
>> buildArgValue
buildArgValue =
See Also
getBuildArgs
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2014a
2-47
2 Alphabetical List
findIncludeFiles
Find and add include (header) files to build information object
Syntax
findIncludeFiles(buildinfo, extPatterns)
extPatterns is optional.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
extPatterns (optional)
A cell array of character arrays that specify patterns of file name extensions for
which the function is to search. Each pattern
Description
The findIncludeFiles function
• Searches for include files, based on specified file name extension patterns, in source
and include paths recorded in the model build information object
• Adds the files found, along with their full paths, to the build information object
2-48
findIncludeFiles
Examples
Find include files with filename extension .h that are in build information object
myModelBuildInfo, and add the full paths for the files found to the object.
myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo, {fullfile(pwd,...
'mycustomheaders')}, 'myheaders');
findIncludeFiles(myModelBuildInfo);
headerfiles = getIncludeFiles(myModelBuildInfo, true, false);
headerfiles
headerfiles =
'W:\work\mycustomheaders\myheader.h'
See Also
addIncludeFiles | packNGo | getIncludeFiles
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006b
2-49
2 Alphabetical List
getBuildArgs
Build arguments from model build information
Syntax
[identifiers, values] = getBuildArgs(buildinfo, includeGroupIDs, excludeGroupIDs)
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
includeGroupIDs (optional)
A cell array which specifies group IDs of build arguments that you want the function
to return.
excludeGroupIDs (optional)
A cell array which specifies group IDs of build arguments that you do not want the
function to return.
Output Arguments
Build arguments stored in the model build information. The function returns the build
arguments in two vectors.
Vector Description
identifiers Names of the build arguments
values Values of the build arguments
Description
The getBuildArgs function returns build arguments stored in the model build
information. Using optional includeGroupIDs and excludeGroupIDs arguments,
2-50
getBuildArgs
you can selectively include or exclude groups from the build arguments returned by the
function.
Examples
• Get the build arguments stored in build information myModelBuildInfo.
load buildInfo.mat
myModelBuildInfo = buildInfo;
[buildArgIds buildArgValues]=getBuildArgs(myModelBuildInfo);
buildArgIds =
'GENERATE_ERT_S_FUNCTION'
'INCLUDE_MDL_TERMINATE_FCN'
'COMBINE_OUTPUT_UPDATE_FCNS'
'MAT_FILE'
'MULTI_INSTANCE_CODE'
'INTEGER_CODE'
'GENERATE_ASAP2'
'EXT_MODE'
'EXTMODE_STATIC_ALLOC'
'EXTMODE_STATIC_ALLOC_SIZE'
'EXTMODE_TRANSPORT'
'TMW_EXTMODE_TESTING'
'MODELLIB'
'SHARED_SRC'
'SHARED_SRC_DIR'
'SHARED_BIN_DIR'
'SHARED_LIB'
'MODELREF_LINK_LIBS'
'RELATIVE_PATH_TO_ANCHOR'
'MODELREF_TARGET_TYPE'
'ISPROTECTINGMODEL'
>> buildArgValues
2-51
2 Alphabetical List
buildArgValues =
'0'
'1'
'1'
'0'
'0'
'0'
'0'
'0'
'0'
'1000000'
'0'
'0'
'iirlib.lib'
''
''
''
''
''
'..'
'NONE'
'NOTPROTECTING'
See Also
findBuildArg
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2014a
2-52
getCompileFlags
getCompileFlags
Compiler options from model build information
Syntax
options = getCompileFlags(buildinfo, includeGroups, excludeGroups)
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of compiler
flags you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of compiler
flags you do not want the function to return.
Output Arguments
Compiler options stored in the model build information.
Description
The getCompileFlags function returns compiler options stored in the model build
information. Using optional includeGroups and excludeGroups arguments, you can
selectively include or exclude groups of options the function returns.
2-53
2 Alphabetical List
Examples
• Get the compiler options stored in build information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'}, ...
'OPTS');
compflags=getCompileFlags(myModelBuildInfo);
compflags
compflags =
myModelBuildInfo = RTW.BuildInfo;
addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'}, ...
{'Debug' 'MemOpt'});
compflags=getCompileFlags(myModelBuildInfo, 'Debug');
compflags
compflags =
'-Zi -Wall'
• Get the compiler options stored in build information myModelBuildInfo, except
those with the group name Debug.
myModelBuildInfo = RTW.BuildInfo;
addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'}, ...
{'Debug' 'MemOpt'});
compflags=getCompileFlags(myModelBuildInfo, '', 'Debug');
compflags
compflags =
'-O3'
See Also
addCompileFlags | getDefines | getLinkFlags
2-54
getCompileFlags
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-55
2 Alphabetical List
getDefines
Preprocessor macro definitions from model build information
Syntax
[macrodefs, identifiers, values] = getDefines(buildinfo, includeGroups, excludeGroups)
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of macro
definitions you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of macro
definitions you do not want the function to return.
Output Arguments
Preprocessor macro definitions stored in the model build information. The function
returns the macro definitions in three vectors.
Vector Description
macrodefs Complete macro definitions with -D prefix
identifiers Names of the macros
values Values assigned to the macros (anything specified to
the right of the first equals sign) ; the default is an
empty character vector ('')
2-56
getDefines
Description
The getDefines function returns preprocessor macro definitions stored in the model
build information. When the function returns a definition, it automatically
• Prepends a -D to the definition if the -D was not specified when the definition was
added to the build information
• Changes a lowercase -d to -D
Examples
• Get the preprocessor macro definitions stored in build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, ...
{'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'}, 'OPTS');
[defs names values]=getDefines(myModelBuildInfo);
defs
defs =
names
names =
'PROTO'
'DEBUG'
'test'
'PRODUCTION'
values
2-57
2 Alphabetical List
values =
'first'
''
''
''
• Get the preprocessor macro definitions stored with the group name Debug in build
information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, ...
{'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'}, ...
{'Debug' 'Debug' 'Debug' 'Release'});
[defs names values]=getDefines(myModelBuildInfo, 'Debug');
defs
defs =
myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, ...
{'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'}, ...
{'Debug' 'Debug' 'Debug' 'Release'});
[defs names values]=getDefines(myModelBuildInfo, '', 'Debug');
defs
defs =
'-DPRODUCTION'
See Also
addDefines | getCompileFlags | getLinkFlags
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-58
getFullFileList
getFullFileList
List of files from model build information
Syntax
[fPathNames, names] = getFullFileList(buildinfo, fcase)
fcase is optional.
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
fcase (optional)
The character vector 'source', 'include', or 'nonbuild'. If the argument is
omitted, the function returns files from the model build information.
Output Arguments
Fully-qualified file paths and file names for files stored in the model build information.
Note: It is not required to resolve the path of every file in the model build information,
because the makefile for the model build will resolve file locations based on source
paths and rules. Therefore, getFullFileList returns the path for each file only
if a path was explicitly associated with the file when it was added, or if you called
2-59
2 Alphabetical List
Description
The getFullFileList function returns the fully-qualified paths and names of all
files, or files of a selected type (source, include, or nonbuild), stored in the model build
information.
The packNGo function calls getFullFileList to return a list of files in the model build
information before processing files for packaging.
Examples
After building a model and loading the generated buildInfo.mat file, you can list the
files stored in a build information variable, myModelBuildInfo. This example returns
information for the current model and descendents (submodels).
myModelBuildInfo = RTW.BuildInfo;
[fPathNames, names] = getFullFileList(myModelBuildInfo);
If you use any of the fcase options, you limit the listing to the files stored in the
myModelBuildInfo variable for the current model. This example returns information
for the current model only (no descendents or submodels).
[fPathNames, names] = getFullFileList(myModelBuildInfo,'source');
See Also
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2008a
2-60
getIncludeFiles
getIncludeFiles
Include files from model build information
Syntax
files = getIncludeFiles(buildinfo, concatenatePaths, replaceMatlabroot, includeGroups,
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
concatenatePaths
The logical value true or false.
If You Specify... The Function...
true Concatenates and returns each filename with its
corresponding path.
false Returns only filenames.
Note: It is not required to resolve the path of every file in the model build
information, because the makefile for the model build will resolve file locations
based on source paths and rules. Therefore, specifying true for concatenatePaths
returns the path for each file only if a path was explicitly associated with the file
when it was added, or if you called updateFilePathsAndExtensions to resolve file
paths and extensions before calling getIncludeFiles.
replaceMatlabroot
The logical value true or false.
If You Specify... The Function...
true Replaces the token $(MATLAB_ROOT) with the absolute
path for your MATLAB installation folder.
2-61
2 Alphabetical List
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of include
files you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of include
files you do not want the function to return.
Output Arguments
Names of include files stored in the model build information. The names include files you
added using the addIncludeFiles function and, if you called the packNGo function,
files packNGo found and added while packaging model code.
Description
The getIncludeFiles function returns the names of include files stored in the model
build information. Use the concatenatePaths and replaceMatlabroot arguments
to control whether the function includes paths and your MATLAB root definition in the
output it returns. Using optional includeGroups and excludeGroups arguments, you
can selectively include or exclude groups of include files the function returns.
Examples
• Get the include paths and filenames stored in build information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addIncludeFiles(myModelBuildInfo, {'etc.h' 'etc_private.h'...
'mytypes.h'}, {'/etc/proj/etclib' '/etcproj/etc/etc_build'...
'/common/lib'}, {'etc' 'etc' 'shared'});
incfiles=getIncludeFiles(myModelBuildInfo, true, false);
incfiles
2-62
getIncludeFiles
incfiles =
• Get the names of include files in group etc that are stored in build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addIncludeFiles(myModelBuildInfo, {'etc.h' 'etc_private.h'...
'mytypes.h'}, {'/etc/proj/etclib' '/etcproj/etc/etc_build'...
'/common/lib'}, {'etc' 'etc' 'shared'});
incfiles=getIncludeFiles(myModelBuildInfo, false, false,...
'etc');
incfiles
incfiles =
'etc.h' 'etc_private.h'
See Also
addIncludeFiles | findIncludeFiles | getIncludePaths | getSourceFiles |
getSourcePaths | updateFilePathsAndExtensions
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-63
2 Alphabetical List
getIncludePaths
Include paths from model build information
Syntax
files=getIncludePaths(buildinfo, replaceMatlabroot, includeGroups, excludeGroups)
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
replaceMatlabroot
The logical value true or false.
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of include
paths you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of include
paths you do not want the function to return.
Output Arguments
Paths of include files stored in the model build information.
2-64
getIncludePaths
Description
The getIncludePaths function returns the names of include file paths stored in the
model build information. Use the replaceMatlabroot argument to control whether the
function includes your MATLAB root definition in the output it returns. Using optional
includeGroups and excludeGroups arguments, you can selectively include or exclude
groups of include file paths the function returns.
Examples
• Get the include paths stored in build information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addIncludePaths(myModelBuildInfo, {'/etc/proj/etclib'...
'/etcproj/etc/etc_build' '/common/lib'},...
{'etc' 'etc' 'shared'});
incpaths=getIncludePaths(myModelBuildInfo, false);
incpaths
incpaths =
myModelBuildInfo = RTW.BuildInfo;
addIncludePaths(myModelBuildInfo, {'/etc/proj/etclib'...
'/etcproj/etc/etc_build' '/common/lib'},...
{'etc' 'etc' 'shared'});
incpaths=getIncludePaths(myModelBuildInfo, false, 'shared');
incpaths
incpaths =
'\common\lib''
2-65
2 Alphabetical List
See Also
addIncludePaths | getIncludeFiles | getSourceFiles | getSourcePaths
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-66
getLinkFlags
getLinkFlags
Link options from model build information
Syntax
options=getLinkFlags(buildinfo, includeGroups, excludeGroups)
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
includeGroups (optional)
A character array or cell array that specifies groups of linker flags you want the
function to return.
excludeGroups (optional)
A character array or cell array that specifies groups of linker flags you do not want
the function to return. To exclude groups and not include specific groups, specify an
empty cell array ('') for includeGroups.
Output Arguments
Linker options stored in the model build information.
Description
The getLinkFlags function returns linker options stored in the model build
information. Using optional includeGroups and excludeGroups arguments, you can
selectively include or exclude groups of options the function returns.
2-67
2 Alphabetical List
Examples
• Get the linker options stored in build information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addLinkFlags(myModelBuildInfo, {'-MD -Gy' '-T'}, 'OPTS');
linkflags=getLinkFlags(myModelBuildInfo);
linkflags
linkflags =
myModelBuildInfo = RTW.BuildInfo;
addLinkFlags(myModelBuildInfo, {'-MD -Gy' '-T'}, ...
{'Debug' 'MemOpt'});
linkflags=getLinkFlags(myModelBuildInfo, {'Debug'});
linkflags
linkflags =
'-MD -Gy'
• Get the linker options stored in build information myModelBuildInfo, except those
with the group name Debug.
myModelBuildInfo = RTW.BuildInfo;
addLinkFlags(myModelBuildInfo, {'-MD -Gy' '-T'}, ...
{'Debug' 'MemOpt'});
linkflags=getLinkFlags(myModelBuildInfo, '', {'Debug'});
linkflags
linkflags =
'-T'
See Also
addLinkFlags | getCompileFlags | getDefines
2-68
getLinkFlags
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-69
2 Alphabetical List
getNonBuildFiles
Nonbuild-related files from model build information
Syntax
files=getNonBuildFiles(buildinfo, concatenatePaths, replaceMatlabroot, includeGroups, e
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
concatenatePaths
The logical value true or false.
Note: It is not required to resolve the path of every file in the model build
information, because the makefile for the model build will resolve file locations
based on source paths and rules. Therefore, specifying true for concatenatePaths
returns the path for each file only if a path was explicitly associated with the file
when it was added.
replaceMatlabroot
The logical value true or false.
2-70
getNonBuildFiles
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of nonbuild
files you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of nonbuild
files you do not want the function to return.
Output Arguments
Names of nonbuild files stored in the model build information.
Description
The getNonBuildFiles function returns the names of nonbuild-related files, such as
DLL files required for a final executable, or a README file, stored in the model build
information. Use the concatenatePaths and replaceMatlabroot arguments to
control whether the function includes paths and your MATLAB root definition in the
output it returns. Using optional includeGroups and excludeGroups arguments, you
can selectively include or exclude groups of nonbuild files the function returns.
Examples
Get the nonbuild filenames stored in build information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addNonBuildFiles(myModelBuildInfo, {'readme.txt' 'myutility1.dll'...
'myutility2.dll'});
nonbuildfiles=getNonBuildFiles(myModelBuildInfo, false, false);
nonbuildfiles
nonbuildfiles =
2-71
2 Alphabetical List
See Also
addNonBuildFiles
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2008a
2-72
getSourceFiles
getSourceFiles
Source files from model build information
Syntax
srcfiles=getSourceFiles(buildinfo, concatenatePaths, replaceMatlabroot,
includeGroups, excludeGroups)
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
concatenatePaths
The logical value true or false.
Note: It is not required to resolve the path of every file in the model build
information, because the makefile for the model build will resolve file locations
based on source paths and rules. Therefore, specifying true for concatenatePaths
returns the path for each file only if a path was explicitly associated with the file
when it was added, or if you called updateFilePathsAndExtensions to resolve file
paths and extensions before calling getSourceFiles.
replaceMatlabroot
The logical value true or false.
2-73
2 Alphabetical List
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of source files
you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of source files
you do not want the function to return.
Output Arguments
Names of source files stored in the model build information.
Description
The getSourceFiles function returns the names of source files stored in the model
build information. Use the concatenatePaths and replaceMatlabroot arguments to
control whether the function includes paths and expansions of path tokens in the output
it returns. Using optional includeGroups and excludeGroups arguments, you can
selectively include or exclude groups of source files the function returns.
Examples
• Get the source paths and filenames stored in build information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addSourceFiles(myModelBuildInfo,...
{'test1.c' 'test2.c' 'driver.c'}, '',...
{'Tests' 'Tests' 'Drivers'});
2-74
getSourceFiles
srcfiles =
myModelBuildInfo = RTW.BuildInfo;
addSourceFiles(myModelBuildInfo, {'test1.c' 'test2.c'...
'driver.c'}, {'/proj/test1' '/proj/test2'...
'/drivers/src'}, {'tests', 'tests', 'drivers'});
incfiles=getSourceFiles(myModelBuildInfo, false, false,...
'tests');
incfiles
incfiles =
'test1.c' 'test2.c'
See Also
addSourceFiles | getIncludeFiles | getIncludePaths | getSourcePaths |
updateFilePathsAndExtensions
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-75
2 Alphabetical List
getSourcePaths
Source paths from model build information
Syntax
files=getSourcePaths(buildinfo, replaceMatlabroot, includeGroups, excludeGroups)
Input Arguments
buildinfo
Build information returned by RTW.BuildInfo.
replaceMatlabroot
The logical value true or false.
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of source
paths you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of source
paths you do not want the function to return.
Output Arguments
Paths of source files stored in the model build information.
2-76
getSourcePaths
Description
The getSourcePaths function returns the names of source file paths stored in the
model build information. Use the replaceMatlabroot argument to control whether the
function includes your MATLAB root definition in the output it returns. Using optional
includeGroups and excludeGroups arguments, you can selectively include or exclude
groups of source file paths the function returns.
Examples
• Get the source paths stored in build information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo, {'/proj/test1'...
'/proj/test2' '/drivers/src'}, {'tests' 'tests'...
'drivers'});
srcpaths=getSourcePaths(myModelBuildInfo, false);
srcpaths
srcpaths =
myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo, {'/proj/test1'...
'/proj/test2' '/drivers/src'}, {'tests' 'tests'...
'drivers'});
srcpaths=getSourcePaths(myModelBuildInfo, true, 'tests');
srcpaths
srcpaths =
'\proj\test1' '\proj\test2'
• Get a path stored in build information myModelBuildInfo. First get the path
without replacing $(MATLAB_ROOT) with an absolute path, then get it with
2-77
2 Alphabetical List
myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo, fullfile(matlabroot,...
'rtw', 'c', 'src'));
srcpaths=getSourcePaths(myModelBuildInfo, false);
srcpaths{:}
ans =
$(MATLAB_ROOT)\rtw\c\src
srcpaths=getSourcePaths(myModelBuildInfo, true);
srcpaths{:}
ans =
\\myserver\myworkspace\matlab\rtw\c\src
See Also
addSourcePaths | getIncludeFiles | getIncludePaths | getSourceFiles
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-78
model_initialize
model_initialize
Initialization entry-point function in generated code for Simulink model
Syntax
void model_initialize(void)
Calling Interfaces
The calling interface generated for this function differs depending on the value of the
model parameter Code interface packaging on page 9-24:
• C++ class (default for C++ language) — Generated function is encapsulated into a C
++ class method. Required model data is encapsulated into C++ class attributes.
• Nonreusable function (default for C language) — Generated function passes
(void). Model data structures are statically allocated, global, and accessed directly
in the model code.
• Reusable function — Generated function passes the real-time model data
structure, by reference, as an input argument. The real-time model data structure is
exported with the model.h header file.
For an ERT-based model, you can use the Pass root-level I/O as parameter to
control how root-level input and output arguments are passed to the function.
They can be included in the real-time model data structure, passed as individual
arguments, or passed as references to an input structure and an output structure.
For a GRT-based model, the generated model.c source file contains an allocation
function that dynamically allocates model data for each instance of the model. For an
ERT-based model, you can use the Use dynamic memory allocation for model
initialization parameter to control whether an allocation function is generated.
• When set, you can restart code generated from the model from a single execution
instance. The sequence of function calls from the main.c is allocfcn,
model_init, model_term, allocfcn, model_init, model_term.
• When cleared,
2-79
2 Alphabetical List
Note: If you have an Embedded Coder license, for Nonreusable function code
interface packaging, you can use the Configure Model Functions button on the
Interface pane of the Configuration Parameters dialog box. For more information, see
“Control Generation of Function Prototypes” (Embedded Coder).
Description
The generated model_initialize function contains initialization code for a Simulink
model and should be called once at the start of your application code.
Do not use the model_initialize function to reset the real-time model data structure
(rtM).
See Also
model_step | model_terminate
Topics
“Entry-Point Functions and Scheduling”
“Generate Code That Responds to Initialize, Reset, and Terminate Events”
2-80
model_step
model_step
Step routine entry point in generated code for Simulink model
Syntax
void model_step(void)
void model_stepN(void)
Calling Interfaces
The model_step default function prototype varies depending on the “Treat each
discrete rate as a separate task” (Simulink) (EnableMultiTasking) parameter
specified for the model:
The calling interface generated for this function also differs depending on the value of the
model parameter Code interface packaging on page 9-24:
• C++ class (default for C++ language) — Generated function is encapsulated into a C
++ class method. Required model data is encapsulated into C++ class attributes.
• Nonreusable function (default for C language) — Generated function passes
(void). Model data structures are statically allocated, global, and accessed directly
in the model code.
• Reusable function — Generated function passes the real-time model data
structure, by reference, as an input argument. The real-time model data structure is
exported with the model.h header file.
For an ERT-based model, you can use the Pass root-level I/O as parameter to
control how root-level input and output arguments are passed to the function.
2-81
2 Alphabetical List
They can be included in the real-time model data structure, passed as individual
arguments, or passed as references to an input structure and an output structure.
• For Nonreusable function code interface packaging, you can use the Configure
Model Functions button on the Interface pane of the Configuration Parameters
dialog box. For more information, see “Control Generation of Function Prototypes”
(Embedded Coder).
• For C++ class code interface packaging, you can use the Configure C++ Class
Interface button and related controls on the Interface pane of the Configuration
Parameters dialog box. For more information, see “Control Generation of C++ Class
Interfaces” (Embedded Coder).
Description
The generated model_step function contains the output and update code for the blocks
in a Simulink model. The model_step function computes the current value of the blocks.
If logging is enabled, model_step updates logging variables. If the model's stop time is
finite, model_step signals the end of execution when the current time equals the stop
time.
Under the following conditions, model_step does not check the current time against the
stop time:
Therefore, if one or more of these conditions are true, the program runs indefinitely.
For a GRT or ERT-based model, the software generates a model_step function when
the Single output/update function configuration option is selected (the default) in the
Configuration Parameters dialog box.
2-82
model_step
execute processing for one clock period of the model. For a description of how calls
to model_step are generated and scheduled, see “rt_OneStep and Scheduling
Considerations” (Embedded Coder).
Note: If the Single output/update function configuration option is not selected, the
software generates the following model entry point functions in place of model_step:
• model_output: Contains the output code for the blocks in the model
• model_update: Contains the update code for the blocks in the model
See Also
model_initialize | model_terminate
Topics
“Entry-Point Functions and Scheduling”
2-83
2 Alphabetical List
model_terminate
Termination entry point in generated code for Simulink model
Syntax
void model_terminate(void)
Calling Interfaces
The calling interface generated for this function also differs depending on the value of the
model parameter Code interface packaging on page 9-24:
• C++ class (default for C++ language) — Generated function is encapsulated into a C
++ class method. Required model data is encapsulated into C++ class attributes.
• Nonreusable function (default for C language) — Generated function passes
(void). Model data structures are statically allocated, global, and accessed directly
in the model code.
• Reusable function — Generated function passes the real-time model data
structure, by reference, as an input argument. The real-time model data structure is
exported with the model.h header file.
For an ERT-based model, you can use the Pass root-level I/O as parameter to
control how root-level input and output arguments are passed to the function.
They can be included in the real-time model data structure, passed as individual
arguments, or passed as references to an input structure and an output structure.
Description
The generated model_terminate function contains the termination code for a Simulink
model and should be called as part of system shutdown.
When model_terminate is called, blocks that have a terminate function execute their
terminate code. If logging is enabled, model_terminate ends data logging.
2-84
model_terminate
For an ERT-based model, the code generator produces the model_terminate function
for a model when the Terminate function required configuration option is selected
(the default) in the Configuration Parameters dialog box. If your application runs
indefinitely, you do not need the model_terminate function. To suppress the function,
clear the Terminate function required configuration option in the Configuration
Parameters dialog box.
See Also
model_initialize | model_step
Topics
“Entry-Point Functions and Scheduling”
“Generate Code That Responds to Initialize, Reset, and Terminate Events”
2-85
2 Alphabetical List
packNGo
Package model code in zip file for relocation
Syntax
packNGo(buildinfo, propVals...)
propVals is optional.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
propVals (optional)
A cell array of property-value pairs that specify packaging details.
2-86
packNGo
Default:'model.zip'
If you omit the .zip file
extension, the function
adds it for you.
Include only the minimal header files 'minimalHeaders' true (default)
required to build the code in the zip file.
Include header files found on the include 'minimalHeaders' false
path in the zip file.
Include the html folder for your code 'includeReport' true (default is false)
generation report.
Direct packNGo not to error out on parse 'ignoreParseError' true (default is false)
errors.
Direct packNGo not to error out if files are 'ignoreFileMissing' true (default is false)
missing.
Description
The packNGo function packages the following code files in a compressed zip file so you
can relocate, unpack, and rebuild them in another development environment:
2-87
2 Alphabetical List
• Nonbuild-related files (for example, .dll files required for a final executable and
.txt informational files)
• MAT-file that contains the model build information object (.mat file)
You might use this function to relocate files so they can be recompiled for a specific target
environment or rebuilt in a development environment in which MATLAB is not installed.
By default, the function packages the files as a flat folder structure in a zip file named
model.zip. You can tailor the output by specifying property name and value pairs as
explained above.
After relocating the zip file, use a standard zip utility to unpack the compressed file.
Note: The packNGo function potentially can modify the build information passed in
the first packNGo argument. As part of packaging model code, packNGo might find
additional files from source and include paths recorded in the model's build information
and add them to the build information.
Examples
• Package the code files for model zingbit in the file zingbit.zip as a flat folder
structure.
set_param('zingbit','PostCodeGenCommand','packNGo(buildInfo);');
Alternatives
You can configure model code packaging by selecting the Package code and artifacts
on page 4-40 option on the Code Generation pane of the Configuration Parameters
dialog box.
2-88
packNGo
See Also
Topics
“Customize Post-Code-Generation Build Processing”
“Relocate Code to Another Development Environment”
“packNGo Function Limitations”
Introduced in R2006b
2-89
2 Alphabetical List
rsimgetrtp
Global model parameter structure
Syntax
parameter_structure = rsimgetrtp('model')
Description
parameter_structure = rsimgetrtp('model') forces a block update diagram
action for model, a model for which you are running rapid simulations, and returns the
global parameter structure for that model. The function includes tunable parameter
information in the parameter structure.
Field Description
modelChecksum A four-element vector that encodes the structure. The
code generator uses the checksum to check whether
the structure has changed since the RSim executable
was generated. If you delete or add a block, and then
generate a new version of the structure, the new
checksum will not match the original checksum. The
RSim executable detects this incompatibility in model
parameter structures and exits to avoid returning
incorrect simulation results. If the structure changes, you
must regenerate code for the model.
parameters A structure that defines model global parameters.
Field Description
dataTypeName Name of the parameter data type, for example, double
dataTypeID An internal data type identifier
2-90
rsimgetrtp
Field Description
complex Value 1 if parameter values are complex and 0 if real
dtTransIdx Internal use only
values Vector of parameter values
structParamInfo Information about structure and bus parameters in the
model
Field Description
Identifier Name of the parameter
ModelParam Value 1 if parameter is a model parameter and 0 if it is a
block parameter
BlockPath Block path for a block parameter. This field is empty for
model parameters.
CAPIIdx Internal use only
The function also includes an array of substructures map that represents tunable
parameter information with these fields:
Field Description
Identifier Parameter name
ValueIndicies Vector of indices to parameter values
Dimensions Vector indicating parameter dimensions
Examples
Return global parameter structure for model rtwdemo_rsimtf to param_struct:
rtwdemo_rsimtf
param_struct = rsimgetrtp('rtwdemo_rsimtf')
param_struct =
2-91
2 Alphabetical List
See Also
rsimsetrtpparam
Topics
“Create a MAT-File That Includes a Model Parameter Structure”
“Update Diagram and Run Simulation” (Simulink)
“Default parameter behavior” (Simulink)
“Block Creation” (Simulink)
“Tune Parameters”
Introduced in R2006a
2-92
rsimsetrtpparam
rsimsetrtpparam
Set parameters of rtP model parameter structure
Syntax
rtP = rsimsetrtpparam(rtP,idx)
rtP = rsimsetrtpparam(rtP,'paramName',paramValue)
rtP = rsimsetrtpparam(rtP,idx,'paramName',paramValue)
Description
rtP = rsimsetrtpparam(rtP,idx) expands the rtP structure to have idx sets
of parameters. The rsimsetrtpparam utility defines the values of an existing rtP
parameter structure. The rtP structure matches the format of the structure returned by
rsimgetrtp('modelName').
Examples
rtp = rsimsetrtpparam(rtp,10);
2-93
2 Alphabetical List
Input Arguments
rtP — A parameter structure that contains the sets of parameter names and their respective
values
parameter structure
idx — An index used to indicate the number of parameter sets in the rtP structure
index of parameter sets
paramName — The name of the parameter set to add to the rtP structure
name of the parameter set
Output Arguments
rtP — An expanded rtP parameter structure that contains idx additional parameter sets
defined by the rsimsetrtpparam function call
expanded rtP parameter structure
See Also
See Also
rsimgetrtp
Topics
“Create a MAT-File That Includes a Model Parameter Structure”
“Update Diagram and Run Simulation” (Simulink)
“Default parameter behavior” (Simulink)
2-94
rsimsetrtpparam
Introduced in R2009b
2-95
2 Alphabetical List
rtw_precompile_libs
Build libraries within model without building model
Syntax
rtw_precompile_libs('model', build_spec)
Description
rtw_precompile_libs('model', build_spec) builds libraries within model,
according to the build_spec arguments, and places the libraries in a precompiled
folder.
Input Arguments
model
Character array. Name of the model containing the libraries that you want to build.
build_spec
Structure of field and value pairs that define a build specification; fields except
rtwmakecfgDirs are optional:
Field Value
rtwmakecfgDirs Cell array of character vectors that names the folders
containing rtwmakecfg files for libraries that you want
to precompile. Uses the Name and Location elements of
makeInfo.library, as returned by the rtwmakecfg function,
to specify name and location of precompiled libraries. If you use
the TargetPreCompLibLocation parameter to specify the
library folder, it overrides the makeInfo.library.Location
setting.
2-96
rtw_precompile_libs
Field Value
makefile that the build approach generates contains the library
rules only if the conversion requires the libraries.
libSuffix (optional) Character vector that specifies the suffix, including the file type
extension, to append to the name of each library (for example,
.a or _vc.lib). The character vector must include a period (.).
Set the suffix with either this field or the TargetLibSuffix
parameter. If you specify a suffix with both mechanisms, the
TargetLibSuffix setting overrides the setting of this field.
intOnlyBuild Boolean flag. When set to true, indicates the function optimizes
(optional) the libraries so that they compile from integer code only. Applies
to ERT-based targets only.
makeOpts (optional) Character vector that specifies an option to include in the
rtwMake command line.
addLibs (optional) Cell array of structures that specify the libraries to build that
an rtwmakecfg function does not specify. Define each structure
with two fields that are character arrays:
Examples
Build the libraries in my_model without building my_model:
% Specify the library suffix
if isunix
suffix = '.a';
else
suffix = '_vc.lib';
end
set_param(my_model, 'TargetLibSuffix', suffix);
% Define a build specification that specifies the location of the files to compile.
build_spec = [];
2-97
2 Alphabetical List
See Also
Topics
“Use rtwmakecfg.m API to Customize Generated Makefiles”
“Precompile S-Function Libraries”
“Recompile Precompiled Libraries”
“Choose and Configure Build Process”
Introduced in R2009b
2-98
rtwbuild
rtwbuild
Initiate build process
Syntax
rtwbuild(model)
rtwbuild(model,Name,Value)
rtwbuild(subsystem)
rtwbuild(subsystem,'Mode','ExportFunctionCalls')
blockHandle = rtwbuild(subsystem,'Mode','ExportFunctionCalls')
rtwbuild(subsystem,'Mode','ExportFunctionCalls,
'ExportFunctionInitializeFunctionName', fcnname)
Description
rtwbuild(model) generates code from model based on current model configuration
parameter settings. If model is not already loaded into the MATLAB environment,
rtwbuild loads it before generating code.
If you clear the Generate code only model configuration parameter, the function
generates code and builds an executable image.
To reduce time for code generation, when rebuilding a model, rtwbuild provides
incremental model build, which only rebuilds a model or sub-models that have
changed since the most recent model build. To force a top-model build, see the
‘ForceTopModelBuild’ argument.
Note: Do not use rtwbuild, rtwrebuild, or slbuild commands with parallel language
features (Parallel Computing Toolbox) (for example, within a parfor or spmd loop).
For information about parallel builds of referenced models, see “Reduce Build Time for
Referenced Models”.
2-99
2 Alphabetical List
If you clear the Generate code only model configuration parameter, the function
generates code and builds an executable image.
rtwbuild(subsystem,'Mode','ExportFunctionCalls,
'ExportFunctionInitializeFunctionName', fcnname) names the exported
initialization function, specified as a character vector, for the specified subsystem.
Examples
Generate Code and Build Executable Image for Model
rtwbuild('rtwdemo_rtwintro')
For the GRT system target file, the code generator produces the following code files and
places them in folders rtwdemo_rtwintro_grt_rtw and slprj/grt/_sharedutils.
2-100
rtwbuild
If the following model configuration parameters settings apply, the code generator
produces additional results.
Generate code and build an executable image for rtwdemo_mdlreftop, which refers to
model rtwdemo_mdlrefbot, regardless of model checksums and parameter settings.
rtwbuild('rtwdemo_mdlreftop','ForceTopModelBuild',true)
2-101
2 Alphabetical List
For the GRT target, the code generator produces the following code files and places them
in folders Amplifier_grt_rtw and slprj/grt/_sharedutils.
If the following model configuration parameters settings apply, the code generator
produces additional results.
Build an executable image from a function-call subsystem to export the image to external
application code.
rtwdemo_exporting_functions
rtwbuild('rtwdemo_exporting_functions/rtwdemo_subsystem','Mode','ExportFunctionCalls')
From a function-call subsystem, create a SIL block that you can use to test the code
generated from a model.
2-102
rtwbuild
The code generator produces a SIL block for the generated subsystem code. You can add
the block to an environment or test harness model that supplies test vectors or stimulus
input. You can then run simulations that perform SIL tests and verify that the generated
code in the SIL block produces the same result as the original subsystem.
Name the initialization function generated when building an executable image from a
function-call subsystem.
rtwdemo_exporting_functions
rtwbuild('rtwdemo_exporting_functions/rtwdemo_subsystem',...
'Mode','ExportFunctionCalls','ExportFunctionInitializeFunctionName','subsysinit')
Input Arguments
model — Model for which to generate code or build an executable image
handle | name
Model for which to generate code or build an executable image, specified as a handle or
character vector representing the model name.
Example: 'rtwdemo_exporting_functions'
2-103
2 Alphabetical List
Consider forcing regeneration of code for a top model if you make changes associated
with external or custom code, such as code for a custom target. For example, you should
set ForceTopModelBuild to true if you change
• TLC code
• S-function source code, including rtwmakecfg.m files
• Integrated custom code
Alternatively, you can force regeneration of top model code by deleting folders in the code
generation folder (Simulink), such as slprj or the generated model code folder.
2-104
rtwbuild
Output Arguments
blockHandle — Handle to SIL block created for generated subsystem code
handle
Handle to SIL block created for generated subsystem code. Returned only if both of the
following conditions apply:
Tips
You can initiate code generation and the build process by using the following options:
• Press Ctrl+B.
• Select Code > C/C++ Code > Build Model.
• Invoke the slbuild command from the MATLAB command line.
2-105
2 Alphabetical List
See Also
See Also
rtwrebuild | slbuild
Topics
“Build and Run a Program”
“Choose and Configure Build Process”
Control Regeneration of Top Model Code
“Generate Component Source Code for Export to External Code Base” (Embedded Coder)
“Software-in-the-Loop Simulation” (Embedded Coder)
Introduced in R2009a
2-106
RTW.getBuildDir
RTW.getBuildDir
Build folder information for model
Syntax
RTW.getBuildDir(model)
folderstruct = RTW.getBuildDir(model)
Description
RTW.getBuildDir(model) displays build folder information for model.
If the model is closed, the function opens and then closes the model, leaving it in its
original state. If the model is large and closed, the RTW.getBuildDir function can take
significantly longer to execute.
You can use this function in automated scripts to determine the build folder in which the
generated code for a model is placed.
Note: This function can return build folder information for protected models.
Examples
Display Build Folder Information
>> RTW.getBuildDir('sldemo_fuelsys')
ans =
BuildDirectory: 'C:\work\modelref\sldemo_fuelsys_ert_rtw'
CacheFolder: 'C:\work\modelref'
CodeGenFolder: 'C:\work\modelref'
2-107
2 Alphabetical List
RelativeBuildDir: 'sldemo_fuelsys_ert_rtw'
BuildDirSuffix: '_ert_rtw'
ModelRefRelativeRootSimDir: 'slprj\sim'
ModelRefRelativeRootTgtDir: 'slprj\ert'
ModelRefRelativeBuildDir: 'slprj\ert\sldemo_fuelsys'
ModelRefRelativeSimDir: 'slprj\sim\sldemo_fuelsys'
ModelRefRelativeHdlDir: 'slprj\hdl\sldemo_fuelsys'
ModelRefDirSuffix: ''
SharedUtilsSimDir: 'slprj\sim\_sharedutils'
SharedUtilsTgtDir: 'slprj\ert\_sharedutils'
folderstruct =
BuildDirectory: 'H:\MyModel_ert_rtw'
CacheFolder: 'H:\'
CodeGenFolder: 'H:\'
RelativeBuildDir: 'MyModel_ert_rtw'
BuildDirSuffix: '_ert_rtw'
ModelRefRelativeRootSimDir: 'slprj\sim'
ModelRefRelativeRootTgtDir: 'slprj\ert'
ModelRefRelativeBuildDir: 'slprj\ert\MyModel'
ModelRefRelativeSimDir: 'slprj\sim\MyModel'
ModelRefRelativeHdlDir: 'slprj\hdl\MyModel'
ModelRefDirSuffix: ''
SharedUtilsSimDir: 'slprj\sim\_sharedutils'
SharedUtilsTgtDir: 'slprj\ert\_sharedutils'
Input Arguments
model — Input data
character vector
2-108
RTW.getBuildDir
Output Arguments
folderstruct — Output data
structure
Field Description
BuildDirectory Character vector specifying fully qualified path to build folder
for model.
CacheFolder Character vector specifying root folder in which to place model
build artifacts used for simulation.
CodeGenFolder Character vector specifying root folder in which to place code
generation files.
RelativeBuildDir Character vector specifying build folder relative to the current
working folder (pwd).
BuildDirSuffix Character vector specifying suffix appended to model name to
create build folder.
ModelRefRelativeRootSimDir Character vector specifying the relative root folder for the
model reference target simulation folder.
ModelRefRelativeRootTgtDir Character vector specifying the relative root folder for the
model reference target build folder.
ModelRefRelativeBuildDir Character vector specifying model reference target build folder
relative to current working folder (pwd).
ModelRefRelativeSimDir Character vector specifying model reference target simulation
folder relative to current working folder (pwd).
ModelRefRelativeHdlDir Character vector specifying model reference target HDL folder
relative to current working folder (pwd).
ModelRefDirSuffix Character vector specifying suffix appended to system target
file name to create model reference build folder.
SharedUtilsSimDir Character vector specifying the shared utility folder for
simulation.
SharedUtilsTgtDir Character vector specifying the shared utility folder for code
generation.
2-109
2 Alphabetical List
See Also
See Also
rtwbuild
Topics
“Working Folder”
“Manage Build Process Folders”
Introduced in R2008b
2-110
rtwrebuild
rtwrebuild
Rebuild generated code
Syntax
rtwrebuild()
rtwrebuild('model')
rtwrebuild('path')
Description
rtwrebuild invokes the makefile generated during the previous build to recompile
files you modified since that build. Operation of this function depends on the current
working folder, not the current loaded model. If your model includes referenced
models, rtwrebuild invokes the makefile for referenced model code recursively before
recompiling the top model.
rtwrebuild() assumes that the current working folder is the build folder of the model
(not the model location) and invokes the makefile in the build folder. If the current
working folder is not the build folder, the function exits with an error.
rtwrebuild('model') assumes that the current working folder is one level above
the build folder (as indicated by pwd when initiating the model build) and invokes the
makefile in the build folder. If the current working folder is not one level above the build
folder, the function exits with an error.
rtwrebuild('path') finds the build folder indicated with the path and invokes the
makefile in the build folder. This syntax lets the function operate without regard to the
relationship between the current working folder and the build folder of the model.
Note: Do not use rtwbuild, rtwrebuild, or slbuild commands with parallel language
features (Parallel Computing Toolbox) (for example, within a parfor or spmd loop).
For information about parallel builds of referenced models, see “Reduce Build Time for
Referenced Models”.
2-111
2 Alphabetical List
Input Arguments
model — Character vector specifying the model name
Example: 'mymodel'
path — Character vector specifying the fully qualified path to the build folder for the model
Example: fullfile('C:','work','mymodel_grt_rtw')
Examples
Rebuild Code from Build Folder
Invoke the makefile and recompile code when the current working folder is the build
folder. If the model name is mymodel, the model build was initiated in the C:\work
folder, and the system target is GRT; invoke the previously generated makefile in the
current working folder (build folder) C:\work\mymodel_grt_rtw.
rtwrebuild()
See Also
See Also
rtwbuild | slbuild
2-112
rtwrebuild
Topics
“Rebuild a Model”
Introduced in R2009a
2-113
2 Alphabetical List
rtwreport
Create generated code report for model with Simulink Report Generator
Syntax
rtwreport(model)
rtwreport(model,folder)
Description
rtwreport(model) creates a report of code generation information for a model. Before
creating the report, the function loads the model and generates code. The code generator
names the report codegen.html. It places the file in your current folder. The report
includes:
Examples
rtwreport('rtwdemo_secondOrderSystem');
2-114
rtwreport
rtwreport('rtwdemo_secondOrderSystem','rtwdemo_secondOrderSystem_grt_rtw');
Input Arguments
model — Model name
character vector
Model name for which the report is generated, specified as a character vector.
Example: 'rtwdemo_secondOrderSystem'
Data Types: char
Build folder name, specified as a character vector. When you have multiple build folders,
include a folder name. For example, if you have multiple builds using different targets,
such as GRT and ERT.
Example: 'rtwdemo_secondOrderSystem_grt_rtw'
Data Types: char
See Also
Topics
“Document Generated Code with Simulink Report Generator”
Import Generated Code (Simulink Report Generator)
“Working with the Report Explorer” (Simulink Report Generator)
Code Generation Summary (Simulink Report Generator)
Introduced in R2007a
2-115
2 Alphabetical List
rtwtrace
Trace a block to generated code in HTML code generation report
Syntax
rtwtrace('blockpath')
rtwtrace('blockpath', 'hdl')
rtwtrace('blockpath', 'plc')
Description
rtwtrace('blockpath') opens an HTML code generation report that displays
contents of the source code file, and highlights the line of code corresponding to the
specified block.
To do this, on the Configuration Parameters dialog box, select the All Parameters
tab, and select the Model-to-code parameter.
• You generate code for the model using the code generator.
• You have the build folder under the current working folder; otherwise, rtwtrace may
produce an error.
2-116
rtwtrace
Examples
rtwtrace('rtwdemo_comments/Out1')
2-117
2 Alphabetical List
Input Arguments
blockpath — block path
character vector (default)
blockpath is a character vector enclosed in quotes specifying the full Simulink block
path, for example, 'model_name/block_name'.
Example: 'Out1'
Data Types: char
hdl is a character vector enclosed in quotes specifying the code report is from HDL
Coder.
Example: 'Out1'
Data Types: char
plc is a character vector enclosed in quotes specifying the code report is from Simulink
PLC Coder.
Example: 'Out1'
Data Types: char
Alternatives
To trace from a block in the model diagram, right-click a block and select C/C++ Code >
Navigate to C/C++ Code.
See Also
Topics
“Trace Model Objects to Generated Code” (Embedded Coder)
2-118
rtwtrace
Introduced in R2009b
2-119
2 Alphabetical List
setTargetProvidesMain
Disable inclusion of a code generator provided (generated or static) main.c source file
Syntax
setTargetProvidesMain(buildinfo,varargin)
Description
setTargetProvidesMain(buildinfo,varargin) can appear in the ‘after_tlc’
case in the ert_make_rtw_hook.m or grt_make_rtw_hook.m file. Use the
setTargetProvidesMain function to disable the build process from generating a
sample main.obj object file.
Input Arguments
buildinfo
varargin
A character array that specifies whether the target provides main.c or the build process
generates a sample main.obj.
• false — the build process generates a sample main.obj object file (default).
• true — the target provides the main.c source file.
Examples
Apply setTargetProvidesMain
2-120
setTargetProvidesMain
For ERT and ERT-derived code generation targets, set the Configuration Parameters
> Code Generation > Templates > Generated an example main program
parameter value to 'off'.
case 'after_tlc'
% Called just after to invoking TLC Compiler (actual code generation.)
% Valid arguments at this stage are hookMethod, modelName, and
% buildArgs, buildInfo
%
setTargetProvidesMain(buildInfo,true);
Use the Configuration Parameters > Code Generation > Custom Code > Source
Files field to add your custom main.c to the model. The model requires this file to build
without errors when you indicate that the target provides main.c.
See Also
See Also
addSourceFiles | addSourcePaths
Topics
“Customize Build Process with STF_make_rtw_hook File”
Introduced in R2009a
2-121
2 Alphabetical List
Simulink.fileGenControl
Specify root folders in which to put files generated by diagram updates and model builds
Syntax
Simulink.fileGenControl(action)
cfg = Simulink.fileGenControl('getConfig')
Simulink.fileGenControl('reset', 'keepPreviousPath', true)
Simulink.fileGenControl('setConfig', 'config', cfg,
'keepPreviousPath', true, 'createDir', true)
Simulink.fileGenControl('set', 'CacheFolder', cacheFolderPath,
'CodeGenFolder', codeGenFolderPath, 'keepPreviousPath', true,
'createDir', true)
Description
Simulink.fileGenControl(action) performs a requested action related to the
file generation control parameters CacheFolder and CodeGenFolder for the current
MATLAB session. CacheFolder specifies the root folder in which to put model build
artifacts used for simulation (including Simulink cache files), and CodeGenFolder
specifies the root folder in which to put code generation files. The initial session defaults
for these parameters are provided by the Simulink preferences “Simulation cache folder”
(Simulink) and “Code generation folder” (Simulink).
2-122
Simulink.fileGenControl
Naming Conflicts
Using Simulink.fileGenControl to set CacheFolder and CodeGenFolder adds
the specified folders to your MATLAB search path. Be aware that there is the same
potential for a naming conflict as when you use addpath to add folders to the search
path. For example, a naming conflict occurs if the folder you specify for CacheFolder or
CodeGenFolder contains a model file with the same name as an open model. For more
information, see “What Is the MATLAB Search Path?” (MATLAB) and “Files and Folders
that MATLAB Accesses” (MATLAB).
Build artifacts (for example, a build folder present in the current working folder, selected
cache folder, or selected code generation folder) from previous builds can contain conflicts
if you change the default selection for the cache folder or code generation folder. To use
a nondefault location (default location is the current working folder, pwd) for the cache
folder or code generation folder, use these guidelines:
• Delete any potentially conflicting build artifacts from previous builds from the pwd
folder, selected nondefault cache folder, and selected nondefault code generation
folder.
• Change the cache folder selection or code generation folder selection with
Simulink.fileGenControl or with Simulink preferences.
2-123
2 Alphabetical List
Input Arguments
action
Action Description
getConfig Returns a handle to an instance of the
Simulink.FileGenConfig object containing the
current values of the CacheFolder and CodeGenFolder
parameters.
reset Reinitializes the CacheFolder and CodeGenFolder
parameters to the values provided by the Simulink
preferences “Simulation cache folder” (Simulink) and “Code
generation folder” (Simulink).
set Sets the CacheFolder and/or CodeGenFolder parameters
for the current MATLAB session by directly passing values.
setConfig Sets the CacheFolder and/or CodeGenFolder parameters
for the current MATLAB session by passing a handle to an
instance of the Simulink.FileGenConfig object.
'config', cfg
'CacheFolder', cacheFolderPath
'CodeGenFolder', codeGenFolderPath
Note: You can specify absolute or relative paths to the build folders. For example:
2-124
Simulink.fileGenControl
'keepPreviousPath', true
For reset, set, or setConfig, specifies whether to keep the previous values of
CacheFolder and CodeGenFolder in the MATLAB path. If 'keepPreviousPath' is
omitted or specified as false, the call removes previous folder values from the MATLAB
path.
'createDir', true
For set or setConfig, specifies whether to create the specified file generation folders
if they do not already exist. If 'createDir' is omitted or specified as false, the call
throws an exception if a specified file generation folder does not exist.
Output Arguments
cfg
Examples
Obtain the current CacheFolder and CodeGenFolder values:
cfg = Simulink.fileGenControl('getConfig');
myCacheFolder = cfg.CacheFolder;
myCodeGenFolder = cfg.CodeGenFolder;
2-125
2 Alphabetical List
Set the CacheFolder and CodeGenFolder parameters for the current MATLAB session
by first setting fields in an instance of the Simulink.FileGenConfig object and then
passing a handle to the object instance. This example assumes that your system has
aNonDefaultCacheFolder and aNonDefaultCodeGenFolder folders.
% Get the current configuration
cfg = Simulink.fileGenControl('getConfig');
% Change the parameters to non-default locations for the cache and code generation folders
cfg.CacheFolder = fullfile('C:','aNonDefaultCacheFolder');
cfg.CodeGenFolder = fullfile('C:','aNonDefaultCodeGenFolder');
Simulink.fileGenControl('setConfig', 'config', cfg);
Directly set the CacheFolder and CodeGenFolder parameters for the current
MATLAB session without creating an instance of the Simulink.FileGenConfig
object. This example assumes that your system has aNonDefaultCacheFolder and
aNonDefaultCodeGenFolder folders.
myCacheFolder = fullfile('C:','aNonDefaultCacheFolder');
myCodeGenFolder = fullfile('C:','aNonDefaultCodeGenFolder');
Simulink.fileGenControl('set', 'CacheFolder', myCacheFolder, ...
'CodeGenFolder', myCodeGenFolder);
See Also
“Code generation folder” (Simulink) | “Simulation cache folder” (Simulink)
Topics
“Manage Build Process Folders”
“Reuse Simulation Builds for Faster Simulations” (Simulink)
Introduced in R2010b
2-126
Simulink.ModelReference.modifyProtectedModel
Simulink.ModelReference.modifyProtectedModel
Modify existing protected model
Syntax
Simulink.ModelReference.modifyProtectedModel(model)
Simulink.ModelReference.modifyProtectedModel(model,Name,Value)
[harnessHandle] = Simulink.ModelReference.modifyProtectedModel(
model,'Harness',true)
[~ ,neededVars] = Simulink.ModelReference.modifyProtectedModel(
model)
Description
Simulink.ModelReference.modifyProtectedModel(model) modifies options
for an existing protected model created from the specified model. If Name,Value pair
arguments are not specified, the modified protected model is updated with default values
and supports only simulation.
Simulink.ModelReference.modifyProtectedModel(model,Name,Value) uses
additional options specified by one or more Name,Value pair arguments. These options
are the same options that are provided by the Simulink.ModelReference.protect
function. However, these options have additional options to change encryption passwords
for read-only view, simulation, and code generation. When you add functionality to
the protected model or change encryption passwords, the unprotected model must be
available. The software searches for the model on the MATLAB path. If the model is not
found, the software reports an error.
[harnessHandle] = Simulink.ModelReference.modifyProtectedModel(
model,'Harness',true) creates a harness model for the protected model. It returns
the handle of the harnessed model in harnessHandle.
[~ ,neededVars] = Simulink.ModelReference.modifyProtectedModel(
model) returns a cell array that includes the names of base workspace variables used by
the protected model.
2-127
2 Alphabetical List
Examples
Update Protected Model with Default Values
Create a modifiable protected model with support for code generation, then reset it to
default values.
Add the password for when a protected model is modified. If you skip this step, you are
prompted to set a password when a modifiable protected model is created.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter','password');
Create a modifiable protected model with support for code generation and Web view.
Simulink.ModelReference.protect('sldemo_mdlref_counter','Mode',...
'CodeGeneration','Modifiable',true,'Report',true);
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter','password');
Simulink.ModelReference.modifyProtectedModel(...
'sldemo_mdlref_counter');
The resulting protected model is updated with default values and supports only
simulation.
Create a modifiable protected model with support for code generation and Web view, then
modify it to remove the Web view support.
Add the password for when a protected model is modified. If you skip this step, you are
prompted to set a password when a modifiable protected model is created.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter','password');
Create a modifiable protected model with support for code generation and Web view.
2-128
Simulink.ModelReference.modifyProtectedModel
Simulink.ModelReference.protect('sldemo_mdlref_counter','Mode',...
'CodeGeneration','Webview',true,'Modifiable',true,'Report',true);
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter','password');
Remove support for Web view from the protected model that you created.
Simulink.ModelReference.modifyProtectedModel(...
'sldemo_mdlref_counter', 'Mode', 'CodeGeneration','Report',true);
Add the password for when a protected model is modified. If you skip this step, you are
prompted to set a password when a modifiable protected model is created.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter','password');
Add the password that the protected model user must provide to generate code.
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation(...
'sldemo_mdlref_counter','cgpassword');
Create a modifiable protected model with a report and support for code generation with
encryption.
Simulink.ModelReference.protect('sldemo_mdlref_counter','Mode',...
'CodeGeneration','Encrypt',true,'Modifiable',true,'Report',true);
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter','password');
Simulink.ModelReference.modifyProtectedModel(
'sldemo_mdlref_counter','Mode','CodeGeneration','Encrypt',true,...
'Report',true,'ChangeSimulationPassword',...
2-129
2 Alphabetical List
{'cgpassword','new_password'});
Add the password for when a protected model is modified. If you skip this step, you are
prompted to set a password when a modifiable protected model is created.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter','password');
Create a modifiable protected model with a report and support for code generation with
encryption.
Simulink.ModelReference.protect('sldemo_mdlref_counter','Mode',...
'CodeGeneration','Modifiable',true,'Report',true);
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter','password');
[harnessHandle] = Simulink.ModelReference.modifyProtectedModel(...
'sldemo_mdlref_counter','Mode','CodeGeneration','Report',true,...
'Harness',true);
Input Arguments
model — Model name
string or character vector (default)
Model name, specified as a string or character vector. It contains the name of a model or
the path name of a Model block that references the protected model.
2-130
Simulink.ModelReference.modifyProtectedModel
quotes (' '). You can specify several name and value pair arguments in any order as
Name1,Value1,...,NameN,ValueN.
Example:
'Mode','CodeGeneration','OutputFormat','Binaries','ObfuscateCode',true
specifies that obfuscated code be generated for the protected model. It also specifies that
only binary files and headers in the generated code be visible to users of the protected
model.
General
'Path' — Folder for protected model
current working folder (default) | string or character vector
To view the report, right-click the protected-model badge icon and select Display
Report. Or, call the Simulink.ProtectedModel.open function with the report
option.
2-131
2 Alphabetical List
Option to add a postprocessing function for protected model files, specified as a function
handle. The function accepts a Simulink.ModelReference.ProtectedModel.HookInfo object
as an input variable. This object provides information on the source code files and other
files generated during protected model creation. The object also provides information on
exported symbols that you must not modify. Prior to packaging the protected model, the
postprocessing function is called.
Example:
'CustomPostProcessingHook',@(protectedMdlInf)myHook(protectedMdlInf)
Functionality
'Mode' — Model protection mode
'Normal' (default) | 'Accelerator' | 'CodeGeneration' | 'ViewOnly'
• 'Normal': If the top model is running in 'Normal' mode, the protected model runs
as a child of the top model.
• 'Accelerator': The top model can run in 'Normal', 'Accelerator', or 'Rapid
Accelerator' mode.
• 'CodeGeneration': The top model can run in 'Normal', 'Accelerator', or
'Rapid Accelerator' mode and support code generation.
• 'ViewOnly': Turns off Simulate and Generate code functionality modes. Turns on
the read-only view mode.
Example: 'Mode','Accelerator'
Note: This argument affects the output only when you specify Mode as 'Accelerator'
or 'CodeGeneration. When you specify Mode as 'Normal', only a MEX-file is part of
the output package.
Protected code visibility. This argument determines what part of the code generated for a
protected model is visible to users. Specify one of the following values:
2-132
Simulink.ModelReference.modifyProtectedModel
• 'MinimalCode': All code in the build folder is visible. Users can inspect the code in
the protected model report and recompile it for their purposes.
• 'AllReferencedHeaders': All code in the build folder is visible. All headers
referenced by the code are also visible.
Example: 'OutputFormat','AllReferencedHeaders'
Option to obfuscate generated code, specified as a Boolean value. Applicable only when
code generation is enabled for the protected model.
Example: 'ObfuscateCode',true
To open the Web view of a protected model, use one of the following methods:
• Right-click the protected-model badge icon and select Show Web view.
• Use the Simulink.ProtectedModel.open function. For example, to display the
Web view for protected model sldemo_mdlref_counter, you can call:
Simulink.ProtectedModel.open(‘sldemo_mdlref_counter’, ‘webview’);
• Double-click the .slxp protected model file in the Current Folder browser.
• In the Block Parameter dialog box for the protected model, click Open Model.
Example: 'Webview',true
Encryption
'ChangeSimulationPassword' — Option to change the encryption password for
simulation
cell array of two character vectors
Option to change the encryption password for simulation, specified as a cell array of
two character vectors. The first vector is the old password, the second vector is the new
password.
2-133
2 Alphabetical List
Example: 'ChangeSimulationPassword',{'old_password','new_password'}
Option to change the encryption password for read-only view, specified as a cell array of
two character vectors. The first vector is the old password, the second vector is the new
password.
Example: 'ChangeViewPassword',{'old_password','new_password'}
Option to change the encryption password for code generation, specified as a cell array of
two character vectors. The first vector is the old password, the second vector is the new
password.
Example: 'ChangeCodeGenerationPassword',
{'old_password','new_password'}
Option to encrypt a protected model, specified as a Boolean value. Applicable when you
have specified a password during protection, or by using the following methods:
Example: 'Encrypt',true
Output Arguments
harnessHandle — Handle of the harness model
double
2-134
Simulink.ModelReference.modifyProtectedModel
If Harness is true, the value is the handle of the harness model; otherwise, the value is
0.
Names of base workspace variables used by the protected model, returned as a cell array.
The cell array can also include variables that the protected model does not use.
See Also
See Also
Simulink.ModelReference.protect |
Simulink.ModelReference.ProtectedModel.setPasswordForModify
Introduced in R2014b
2-135
2 Alphabetical List
Simulink.ModelReference.protect
Obscure referenced model contents to hide intellectual property
Syntax
Simulink.ModelReference.protect(model)
Simulink.ModelReference.protect(model,Name,Value)
[harnessHandle] = Simulink.ModelReference.protect(model,'
Harness',true)
[~ ,neededVars] = Simulink.ModelReference.protect(model)
Description
Simulink.ModelReference.protect(model) creates a protected model from
the specified model. It places the protected model in the current working folder. The
protected model has the same name as the source model. It has the extension .slxp.
[harnessHandle] = Simulink.ModelReference.protect(model,'
Harness',true) creates a harness model for the protected model. It returns the handle
of the harnessed model in harnessHandle.
Examples
Protect Referenced Model
Protect a referenced model and place the protected model in the current working folder.
sldemo_mdlref_bus;
2-136
Simulink.ModelReference.protect
model= 'sldemo_mdlref_counter_bus'
Simulink.ModelReference.protect(model);
Protect a referenced model and place the protected model in a specified folder.
sldemo_mdlref_bus;
model= 'sldemo_mdlref_counter_bus'
Simulink.ModelReference.protect(model,'Path','C:\Work');
Protect a referenced model, generate code for it in Normal mode, and obfuscate the code.
sldemo_mdlref_bus;
model= 'sldemo_mdlref_counter_bus'
Simulink.ModelReference.protect(model,'Path','C:\Work','Mode','CodeGeneration',...
'ObfuscateCode',true);
Control code visibility by allowing users to view only binary files and headers in the code
generated for a protected model.
sldemo_mdlref_bus;
model= 'sldemo_mdlref_counter_bus'
Simulink.ModelReference.protect(model,'Mode','CodeGeneration','OutputFormat',...
'CompiledBinaries');
2-137
2 Alphabetical List
Create a harness model for a protected model and generate an HTML report.
sldemo_mdlref_bus;
modelPath= 'sldemo_mdlref_bus/CounterA'
[harnessHandle] = Simulink.ModelReference.protect(modelPath,'Path','C:\Work',...
'Harness',true,'Report',true);
Input Arguments
model — Model name
string or character vector (default)
Model name, specified as a string or character vector. It contains the name of a model or
the path name of a Model block that references the model to be protected.
2-138
Simulink.ModelReference.protect
Example:
'Mode','CodeGeneration','OutputFormat','Binaries','ObfuscateCode',true
specifies that obfuscated code be generated for the protected model. It also specifies that
only binary files and headers in the generated code be visible to users of the protected
model.
• 'Normal': If the top model is running in 'Normal' mode, the protected model runs
as a child of the top model.
• 'Accelerator': The top model can run in 'Normal', 'Accelerator', or 'Rapid
Accelerator' mode.
• 'CodeGeneration': The top model can run in 'Normal', 'Accelerator', or
'Rapid Accelerator' mode and support code generation.
• 'ViewOnly': Turns off Simulate and Generate code functionality modes. Turns on
the read-only view mode.
Example: 'Mode','Accelerator'
Applies only if the system target file (SystemTargetFile) is set to an ERT based
system target file (for example, ert.tlc). Requires Embedded Coder license.
• 'Model reference': Code access through the model reference code interface, which
allows use of the protected model within a model reference hierarchy. Users of the
protected model can generate code from a parent model that contains the protected
model. In addition, users can run Model block SIL/PIL simulations with the protected
model.
2-139
2 Alphabetical List
• 'Top model': Code access through the standalone interface. Users of the protected
model can run Model block SIL/PIL simulations with the protected model.
Option to obfuscate generated code, specified as a Boolean value. Applicable only when
code generation during protection is enabled.
Example: 'ObfuscateCode',true
To view the report, right-click the protected-model badge icon and select Display
Report. Or, call the Simulink.ProtectedModel.open function with the report
option.
Note: This argument affects the output only when you specify Mode as 'Accelerator'
or 'CodeGeneration. When you specify Mode as 'Normal', only a MEX-file is part of
the output package.
Protected code visibility. This argument determines what part of the code generated for a
protected model is visible to users. Specify one of the following values:
2-140
Simulink.ModelReference.protect
Example: 'OutputFormat','AllReferencedHeaders'
To open the Web view of a protected model, use one of the following methods:
• Right-click the protected-model badge icon and select Show Web view.
• Use the Simulink.ProtectedModel.open function. For example, to display the
Web view for protected model sldemo_mdlref_counter, you can call:
Simulink.ProtectedModel.open(‘sldemo_mdlref_counter’, ‘webview’);
• Double-click the .slxp protected model file in the Current Folder browser.
• In the Block Parameter dialog box for the protected model, click Open Model.
Example: 'Webview',true
Option to encrypt a protected model, specified as a Boolean value. Applicable when you
have specified a password during protection, or by using the following methods:
Example: 'Encrypt',true
2-141
2 Alphabetical List
Option to add a postprocessing function for protected model files, specified as a function
handle. The function accepts a Simulink.ModelReference.ProtectedModel.HookInfo
object as an input variable. This object provides information on the source code files and
other files generated during protected model creation. It also provides information on
exported symbols that you must not modify. Prior to packaging the protected model, the
postprocessing function is called.
Example:
'CustomPostProcessingHook',@(protectedMdlInf)myHook(protectedMdlInf)
Option to create a modifiable protected model, specified as a Boolean value. To use this
option:
Example: 'Modifiable',true
2-142
Simulink.ModelReference.protect
Output Arguments
harnessHandle — Handle of the harness model
double
If Harness is true, the value is the handle of the harness model; otherwise, the value is
0.
Names of base workspace variables used by the model being protected, returned as a cell
array.
The cell array can also include variables that the protected model does not use.
Alternatives
“Create a Protected Model”
See Also
See Also
Simulink.ModelReference.modifyProtectedModel |
Simulink.ModelReference.ProtectedModel.clearPasswords |
Simulink.ModelReference.ProtectedModel.clearPasswordsForModel |
Simulink.ModelReference.ProtectedModel.setPasswordForCodeGeneration
| Simulink.ModelReference.ProtectedModel.setPasswordForModify |
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation |
Simulink.ModelReference.ProtectedModel.setPasswordForView
Topics
Protected Models for Model Reference
2-143
2 Alphabetical List
Introduced in R2012b
2-144
Simulink.ModelReference.ProtectedModel.clearPasswords
Simulink.ModelReference.ProtectedModel.clearPasswords
Clear all cached passwords for protected models
Syntax
Simulink.ModelReference.ProtectedModel.clearPasswords()
Description
Simulink.ModelReference.ProtectedModel.clearPasswords() clears all
protected model passwords that have been cached during the current MATLAB session.
If this function is not called, cached passwords are cleared at the end of a MATLAB
session.
Examples
Clear all cached passwords for protected models
After using protected models, clear passwords cached for the models during the MATLAB
session.
Simulink.ModelReference.ProtectedModel.clearPasswords()
See Also
See Also
Simulink.ModelReference.ProtectedModel.clearPasswordsForModel
Topics
“Protect a Referenced Model”
Introduced in R2014b
2-145
2 Alphabetical List
Simulink.ModelReference.ProtectedModel.clearPasswordsFor
Clear cached passwords for a protected model
Syntax
Simulink.ModelReference.ProtectedModel.clearPasswordsForModel(model)
Description
Simulink.ModelReference.ProtectedModel.clearPasswordsForModel(model)
clears all protected model passwords for model that have been cached during the current
MATLAB session. If this function is not called, cached passwords are cleared at the end
of a MATLAB session.
Examples
Clear all cached passwords for a protected model
After using a protected model, clear passwords cached for the model during the MATLAB
session.
Simulink.ModelReference.ProtectedModel.clearPasswordsForModel(model)
Input Arguments
model — Protected model name
string or character vector
2-146
Simulink.ModelReference.ProtectedModel.clearPasswordsForModel
See Also
See Also
Simulink.ModelReference.ProtectedModel.clearPasswords
Topics
“Protect a Referenced Model”
Introduced in R2014b
2-147
2 Alphabetical List
Simulink.ModelReference.ProtectedModel.HookInfo
class
Package: Simulink.ModelReference.ProtectedModel
Description
Specifies information about files and symbols generated when creating a protected
model. The creator of a protected model can use this information for postprocessing of the
generated files prior to packaging. Information includes:
Construction
To access the properties of this class, use the ‘CustomPostProcessingHook’
option of the Simulink.ModelReference.protect function. The
value for the option is a handle to a postprocessing function accepting a
Simulink.ModelReference.ProtectedModel.HookInfo object as input.
Properties
ExportedSymbols — Exported Symbols
cell array of character vectors
A list of exported symbols generated by protected model that you must not modify.
Default value is empty.
2-148
Simulink.ModelReference.ProtectedModel.HookInfo class
A list of non-source files generated by protected model creation. Examples are *.mat,
*.rsp, and *.prj. Default value is empty.
A list of source code files generated by protected model creation. Examples are *.c, *.h,
*.cpp, and *.hpp. Default value is empty.
Copy Semantics
Handle. To learn how handle classes affect copy operations, see Copying Objects
(MATLAB) in the MATLAB documentation.
See Also
See Also
Simulink.ModelReference.protect
Topics
“Specify Custom Obfuscator for Protected Model”
2-149
2 Alphabetical List
Simulink.ModelReference.ProtectedModel.setPasswordForCod
Add or provide encryption password for code generation from protected model
Syntax
Simulink.ModelReference.ProtectedModel.setPasswordForCodeGeneration(
model,password)
Description
Simulink.ModelReference.ProtectedModel.setPasswordForCodeGeneration(
model,password) adds an encryption password for code generation if you create
a protected model. If you use a protected model, the function provides the required
password to generate code from the model.
Examples
Create a Protected Model with Encryption
Simulink.ModelReference.ProtectedModel.setPasswordForCodeGeneration(...
'sldemo_mdlref_counter','password');
Simulink.ModelReference.protect('sldemo_mdlref_counter',...
'Mode','Code Generation','Encrypt',true,'Report',true);
Provide the encryption password required for code generation from the protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForCodeGeneration(...
2-150
Simulink.ModelReference.ProtectedModel.setPasswordForCodeGeneration
'sldemo_mdlref_counter','password');
After you have provided the encryption password, you can generate code from the
protected model.
Input Arguments
model — Model name
string or character vector
Model name, specified as a string or character vector. It contains the name of a model or
the path name of a Model block that references the protected model.
Password, specified as a string or character vector. If the protected model is encrypted for
code generation, the password is required.
See Also
See Also
Simulink.ModelReference.protect |
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation |
Simulink.ModelReference.ProtectedModel.setPasswordForView
Introduced in R2014b
2-151
2 Alphabetical List
Simulink.ModelReference.ProtectedModel.setPasswordForMo
Add or provide password for modifying protected model
Syntax
Simulink.ModelReference.ProtectedModel.setPasswordForModify(model,
password)
Description
Simulink.ModelReference.ProtectedModel.setPasswordForModify(model,
password) adds a password for a modifiable protected model. After the password has
been created, the function provides the password for modifying the protected model.
Examples
Add Functionality to Protected Model
Create a modifiable protected model with support for code generation, then modify it to
add Web view support.
Add the password for when a protected model is modified. If you skip this step, you are
prompted to set a password when a modifiable protected model is created.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter','password');
Create a modifiable protected model with support for code generation and Web view.
Simulink.ModelReference.protect('sldemo_mdlref_counter','Mode',...
'CodeGeneration', 'Modifiable',true, 'Report',true);
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'sldemo_mdlref_counter', 'password');
2-152
Simulink.ModelReference.ProtectedModel.setPasswordForModify
Add support for Web view to the protected model that you created.
Simulink.ModelReference.modifyProtectedModel(...
'sldemo_mdlref_counter','Mode','CodeGeneration','Webview',true,...
'Report',true);
Input Arguments
model — Model name
string or character vector
Model name, specified as a string or character vector. It contains the name of a model or
the path name of a Model block that references the protected model to be modified.
See Also
See Also
Simulink.ModelReference.modifyProtectedModel |
Simulink.ModelReference.protect
Introduced in R2014b
2-153
2 Alphabetical List
Simulink.ModelReference.ProtectedModel.setPasswordForSim
Add or provide encryption password for simulation of protected model
Syntax
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation(
model,password)
Description
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation(
model,password) adds an encryption password for simulation if you create a protected
model. If you use a protected model, the function provides the required password to
simulate the model.
Examples
Create a Protected Model with Encryption
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation(...
'sldemo_mdlref_counter','password');
Simulink.ModelReference.protect('sldemo_mdlref_counter',...
'Encrypt',true,'Report',true);
Provide the encryption password required for simulation of the protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation(...
2-154
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation
'sldemo_mdlref_counter','password');
After you have provided the encryption password, you can simulate the protected model.
Input Arguments
model — Model name
string or character vector
Model name, specified as a string or character vector. It contains the name of a model or
the path name of a Model block that references the protected model.
Password, specified as a string or character vector. If the protected model is encrypted for
simulation, the password is required.
See Also
See Also
Simulink.ModelReference.protect |
Simulink.ModelReference.ProtectedModel.setPasswordForCodeGeneration |
Simulink.ModelReference.ProtectedModel.setPasswordForView
Introduced in R2014b
2-155
2 Alphabetical List
Simulink.ModelReference.ProtectedModel.setPasswordForVie
Add or provide encryption password for read-only view of protected model
Syntax
Simulink.ModelReference.ProtectedModel.setPasswordForView(model,
password)
Description
Simulink.ModelReference.ProtectedModel.setPasswordForView(model,
password) adds an encryption password for read-only view if you create a protected
model. If you use a protected model, the function provides the required password for a
read-only view of the model.
Examples
Create a Protected Model with Encryption
Simulink.ModelReference.ProtectedModel.setPasswordForView(...
'sldemo_mdlref_counter','password');
Simulink.ModelReference.protect('sldemo_mdlref_counter',...
'Webview',true,'Encrypt',true,'Report',true);
Provide the encryption password required for the read-only view of the protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForView(...
2-156
Simulink.ModelReference.ProtectedModel.setPasswordForView
'sldemo_mdlref_counter','password');
After you have provided the encryption password, you have access to the read-only view
of the protected model.
Input Arguments
model — Model name
string or character vector
Model name, specified as a string or character vector. It contains the name of a model or
the path name of a Model block that references the protected model.
Password, specified as a string or character vector. If the protected model is encrypted for
read-only view, the password is required.
See Also
See Also
Simulink.ModelReference.protect |
Simulink.ModelReference.ProtectedModel.setPasswordForCodeGeneration |
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation
Introduced in R2014b
2-157
2 Alphabetical List
Simulink.ProtectedModel.addTarget
Add code generation support for current target to protected model
Syntax
Simulink.ProtectedModel.addTarget(model)
Description
Simulink.ProtectedModel.addTarget(model) adds code generation support for
the current model target to a protected model of the same name. Each target that the
protected model supports is identified by the root of the Code Generation > System
Target file (SystemTargetFile) parameter. For example, if the System Target file is
ert.tlc, the target identifier is ert.
• The model and the protected model of the same name must be on the MATLAB path.
• The protected model must have the Modifiable option enabled and have a password
for modification.
• The target must be unique in the protected model.
If you add a target to a protected model that did not previously support code
generation, the software switches the protected model Mode to CodeGeneration and
ObfuscateCode to true.
Examples
Add a Target to a Protected Model
2-158
Simulink.ProtectedModel.addTarget
sldemo_mdlref_counter
save_system('sldemo_mdlref_counter','mdlref_counter.slx');
Add a required password for modifying a protected model. If you do not add a password,
you are prompted to set a password when you create a modifiable, protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'mdlref_counter','password');
Simulink.ModelReference.protect('mdlref_counter','Mode',...
'CodeGeneration', 'Modifiable',true, 'Report',true);
st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
Add support to the protected model for the new target. You are prompted for the
modification password.
Simulink.ProtectedModel.addTarget('mdlref_counter');
Verify that support for the new target has been added to the protected model.
st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
Input Arguments
model — Model name
string or character vector
Model name, specified as a string or character vector. It contains the name of a model or
the path name of a Model block that references the protected model.
2-159
2 Alphabetical List
See Also
See Also
Simulink.ModelReference.protect |
Simulink.ProtectedModel.getConfigSet |
Simulink.ProtectedModel.getCurrentTarget |
Simulink.ProtectedModel.getSupportedTargets
| Simulink.ProtectedModel.removeTarget |
Simulink.ProtectedModel.setCurrentTarget
Topics
“Create a Protected Model with Multiple Targets”
Introduced in R2015a
2-160
Simulink.ProtectedModel.Callback class
Simulink.ProtectedModel.Callback class
Package: Simulink.ProtectedModel
Description
For a protected model functionality, the Simulink.ProtectedModel.Callback object
specifies code to execute in response to an event. The callback code can be a character
vector of MATLAB commands or a MATLAB script. The object includes:
Construction
pmCallback = Simulink.ProtectedModel.Callback(event,functionality,
callbackText) creates a callback object for a specific protected model functionality and
event. The callbackText specifies MATLAB commands to execute for the callback.
pmCallback = Simulink.ProtectedModel.Callback(event,functionality,
callbackFile) creates a callback object for a specific protected model functionality and
event. The callbackFile specifies a MATLAB script to execute for the callback. The
script must be on the MATLAB path.
Input Arguments
event — Event that triggers callback
'PreAccess' | 'Build'
2-161
2 Alphabetical List
Protected model functionality that the event applies to. Specify one of the following
values:
Properties
AppliesTo — Protected model functionality
'CODEGEN' | 'SIM' | 'VIEW' | 'AUTO'
Protected model functionality that the event applies to. Value is one of the following:
2-162
Simulink.ProtectedModel.Callback class
Option to override the protected model build process, specified as a Boolean value.
Applies only to a callback object that you define for a 'Build' event for 'CODEGEN'
functionality. You set this option using the setOverrideBuild method.
2-163
2 Alphabetical List
Methods
setOverrideBuild Specify option to override protected model
build
Copy Semantics
Handle. To learn how handle classes affect copy operations, see Copying Objects
(MATLAB) in the MATLAB documentation.
Examples
For each instance of the protected model reference in the top model, the output is listed.
Hello world!
Hello world!
Hello world!
2-164
Simulink.ProtectedModel.Callback class
rtwbuild('sldemo_mdlref_basic')
Before the protected model build process begins, code in pm_callback.m executes.
See Also
See Also
Simulink.ModelReference.protect |
Simulink.ProtectedModel.getCallbackInfo
Topics
“Define Callbacks for Protected Model”
“Protect a Referenced Model”
“Code Generation Support in a Protected Model”
Introduced in R2016a
2-165
2 Alphabetical List
setOverrideBuild
Class: Simulink.ProtectedModel.Callback
Package: Simulink.ProtectedModel
Syntax
setOverrideBuild(override)
Description
setOverrideBuild(override) specifies whether a Simulink.ProtectedModel.Callback
object can override the build process. This method is valid only for callbacks that execute
in response to a 'Build' event for 'CODEGEN' functionality.
Input Arguments
override — Option to override protected model build process
false (default) | true
Option to override the protected model build process, specified as a Boolean value. This
option applies only to a callback object defined for a 'Build' event for 'CODEGEN'
functionality.
Example: pmcallback.setOverrideBuild(true)
Examples
2-166
setOverrideBuild
pmCallback = Simulink.ProtectedModel.Callback('Build',...
'CODEGEN','disp(''Hello world!'')')
pmCallback.setOverrideBuild(true);
Simulink.ModelReference.protect('sldemo_mdlref_counter',...
'Mode', 'CodeGeneration','Callbacks',{pmCallback})
rtwbuild('sldemo_mdlref_basic')
See Also
See Also
Simulink.ModelReference.protect | Simulink.ProtectedModel.Callback
Topics
“Define Callbacks for Protected Model”
“Protect a Referenced Model”
“Code Generation Support in a Protected Model”
Introduced in R2016a
2-167
2 Alphabetical List
Simulink.ProtectedModel.CallbackInfo class
Package: Simulink.ProtectedModel
Description
A Simulink.ProtectedModel.CallbackInfo object contains information about a protected
model that you can use in the code executed for a callback. The object provides:
• Model name.
• List of models and submodels in the protected model container.
• Callback event.
• Callback functionality.
• Code interface.
• Current target. This information is available only for code generation callbacks.
Construction
cbinfobj =
Simulink.ProtectedModel.getCallbackInfo(modelName,event,functionality)
creates a Simulink.ProtectedModel.CallbackInfo object.
Properties
CodeInterface — Code interface generated by protected model
'Top model' | 'Model reference'
2-168
Simulink.ProtectedModel.CallbackInfo class
Protected model functionality that the event applies to. Value is one of the following:
Names of all models and submodels in the protected model container, specified as a cell
array of character vectors.
Current target identifier for the protected model, specified as a character vector. This
property is available only for code generation callbacks.
Methods
getBuildInfoForModel Get build information object for specified
model
2-169
2 Alphabetical List
Copy Semantics
Handle. To learn how handle classes affect copy operations, see Copying Objects
(MATLAB) in the MATLAB documentation.
Examples
Use Protected Model Information in Simulation Callback
Create a protected model callback that uses information from the
Simulink.ProtectedModel.Callback object.
When you create a protected model with a simulation callback, use the script.
pmCallback = Simulink.ProtectedModel.Callback('PreAccess'...
,'SIM', 'pm_callback.m')
Simulink.ModelReference.protect('sldemo_mdlref_counter',...
'Callbacks',{pmCallback})
Simulate the protected model. For each instance of the protected model reference in the
top model, the output from the callback is listed.
sim('sldemo_mdlref_basic')
See Also
See Also
Simulink.ModelReference.protect |
Simulink.ProtectedModel.getCallbackInfo
2-170
Simulink.ProtectedModel.CallbackInfo class
Topics
“Define Callbacks for Protected Model”
“Protect a Referenced Model”
“Code Generation Support in a Protected Model”
Introduced in R2016a
2-171
2 Alphabetical List
Simulink.ProtectedModel.getCallbackInfo
Get Simulink.ProtectedModel.CallbackInfo object for use by callbacks
Syntax
cbinfobj = Simulink.ProtectedModel.getCallbackInfo(modelName,event,
functionality)
Description
cbinfobj = Simulink.ProtectedModel.getCallbackInfo(modelName,event,
functionality) returns a Simulink.ProtectedModel.CallbackInfo object that provides
information for protected model callbacks. The object contains information about the
protected model, including:
• Model name.
• List of models and submodels in the protected model container.
• Callback event.
• Callback functionality.
• Code interface.
• Current target. This information is available only for code generation callbacks.
Examples
2-172
Simulink.ProtectedModel.getCallbackInfo
When you create a protected model with a simulation callback, use the script.
pmCallback = Simulink.ProtectedModel.Callback('Build',...
'CODEGEN', 'pm_callback.m')
Simulink.ModelReference.protect('sldemo_mdlref_counter',...
'Mode', 'CodeGeneration','Callbacks',{pmCallback})
Build the protected model. Before the start of the protected model build process, the code
interface is displayed.
rtwbuild('sldemo_mdlref_basic')
Input Arguments
modelName — Protected model name
string or character vector
Protected model functionality that the event applies to. Value is one of the following:
2-173
2 Alphabetical List
Output Arguments
cbinfobj — Callback information object
Simulink.ProtectedModel.CallbackInfo
See Also
See Also
Simulink.ModelReference.protect | Simulink.ProtectedModel.CallbackInfo
Topics
“Define Callbacks for Protected Model”
“Protect a Referenced Model”
“Code Generation Support in a Protected Model”
Introduced in R2016a
2-174
getBuildInfoForModel
getBuildInfoForModel
Class: Simulink.ProtectedModel.CallbackInfo
Package: Simulink.ProtectedModel
Syntax
bldobj = getBuildInfoForModel(model)
Description
bldobj = getBuildInfoForModel(model) returns a handle to an RTW.BuildInfo
object. This object specifies the build toolchain and arguments. The model
name must be in the list of model names in the SubModels property of the
Simulink.ProtectedModel.CallbackInfo object. You can call this method only for code
generation callbacks in response to a 'Build' event.
Input Arguments
model — Model name
string or character vector
Output Arguments
bldobj — Object for build toolchain and arguments
RTW.BuildInfo
2-175
2 Alphabetical List
Build toolchain and arguments, specified as a RTW.BuildInfo object. If you do not call
the method for a code generation callback and 'Build' event, the return value is an
empty array.
Examples
Get Build Information from a Code Generation Callback
On the MATLAB path, create a callback script, pm_callback.m, containing:
cbinfobj = Simulink.ProtectedModel.getCallbackInfo(...
'sldemo_mdlref_counter','Build','CODEGEN');
bldinfo = cbinfobj.getBuildInfoForModel(cbinfobj.ModelName);
buildargs = getBuildArgs(bldinfo)
When you create a protected model with a simulation callback, use the script.
pmCallback = Simulink.ProtectedModel.Callback('Build',...
'CODEGEN', 'pm_callback.m')
Simulink.ModelReference.protect('sldemo_mdlref_counter',...
'Mode', 'CodeGeneration','Callbacks',{pmCallback})
Build the protected model. Before the start of the protected model build, the build
arguments are displayed.
rtwbuild('sldemo_mdlref_basic')
See Also
See Also
Simulink.ModelReference.protect | Simulink.ProtectedModel.CallbackInfo
Topics
“Define Callbacks for Protected Model”
“Protect a Referenced Model”
“Code Generation Support in a Protected Model”
Introduced in R2016a
2-176
Simulink.ProtectedModel.getConfigSet
Simulink.ProtectedModel.getConfigSet
Get configuration set for current protected model target or for specified target
Syntax
configSet = Simulink.ProtectedModel.getConfigSet(protectedModel)
configSet = Simulink.ProtectedModel.getConfigSet(protectedModel,
targetID)
Description
configSet = Simulink.ProtectedModel.getConfigSet(protectedModel)
returns the configuration set object for the current, protected model target.
configSet = Simulink.ProtectedModel.getConfigSet(protectedModel,
targetID) returns the configuration set object for a specified target that the protected
model supports.
Examples
Get Configuration Set for Current Target
Get the configuration set for the currently configured, protected model target.
sldemo_mdlref_counter
save_system('sldemo_mdlref_counter','mdlref_counter.slx');
Add a required password for modifying a protected model. If you do not add a password,
you are prompted to set a password when you create a modifiable, protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'mdlref_counter','password');
2-177
2 Alphabetical List
Simulink.ModelReference.protect('mdlref_counter','Mode',...
'CodeGeneration', 'Modifiable',true, 'Report',true);
Get the configuration set for a specified target that the protected model supports.
Add a required password for modifying a protected model. If you do not add a password,
you are prompted to set a password when you create a modifiable, protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'mdlref_counter','password');
Add support to the protected model for the new target. You are prompted for the
modification password.
Simulink.ProtectedModel.addTarget('mdlref_counter');
Verify that support for the new target has been added to the protected model.
st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
2-178
Simulink.ProtectedModel.getConfigSet
Input Arguments
protectedModel — Model name
string or character vector
Output Arguments
configSet — Configuration object
Simulink.ConfigSet
See Also
See Also
Simulink.ModelReference.protect | Simulink.ProtectedModel.addTarget
| Simulink.ProtectedModel.getCurrentTarget |
Simulink.ProtectedModel.getSupportedTargets
| Simulink.ProtectedModel.removeTarget |
Simulink.ProtectedModel.setCurrentTarget
Topics
“Create a Protected Model with Multiple Targets”
2-179
2 Alphabetical List
Introduced in R2015a
2-180
Simulink.ProtectedModel.getCurrentTarget
Simulink.ProtectedModel.getCurrentTarget
Get current protected model target
Syntax
currentTarget = Simulink.ProtectedModel.getCurrentTarget(
protectedModel)
Description
currentTarget = Simulink.ProtectedModel.getCurrentTarget(
protectedModel) returns the target identifier for the target that is currently
configured for the protected model. At the start of a MATLAB session, the default
current target is the last target added to the protected model. Otherwise, the current
target is the last target that you used. You can change the current target using the
Simulink.ProtectedModel.setCurrentTarget function.
When building the model, the software changes the target to match the parent if the
currently selected target does not match the target of the parent model.
Examples
Get Currently Configured Target for Protected Model
Add a target to a protected model, and then get the currently configured target for the
protected model.
sldemo_mdlref_counter
save_system('sldemo_mdlref_counter','mdlref_counter.slx');
Add a required password for modifying a protected model. If you do not add a password,
you are prompted to set a password when you create a modifiable, protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
2-181
2 Alphabetical List
'mdlref_counter','password');
Add support to the protected model for the new target. You are prompted for the
modification password.
Simulink.ProtectedModel.addTarget('mdlref_counter');
Verify that support for the new target has been added to the protected model.
st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
Input Arguments
protectedModel — Model name
string or character vector
Output Arguments
currentTarget — Current target
character vector
2-182
Simulink.ProtectedModel.getCurrentTarget
See Also
See Also
Simulink.ModelReference.protect | Simulink.ProtectedModel.addTarget
| Simulink.ProtectedModel.getConfigSet |
Simulink.ProtectedModel.getSupportedTargets
| Simulink.ProtectedModel.removeTarget |
Simulink.ProtectedModel.setCurrentTarget
Topics
“Create a Protected Model with Multiple Targets”
“Use a Protected Model with Multiple Targets”
Introduced in R2015a
2-183
2 Alphabetical List
Simulink.ProtectedModel.getSupportedTargets
Get list of targets that protected model supports
Syntax
supportedTargets = Simulink.ProtectedModel.getSupportedTargets(
protectedModel)
Description
supportedTargets = Simulink.ProtectedModel.getSupportedTargets(
protectedModel) returns a list of target identifiers for the code generation targets
supported by the specified protected model. The target identifier sim represents
simulation support.
Examples
Get List of Supported Targets for a Protected Model
Add a target to a protected model, and then get a list of supported targets to verify the
addition of the new target.
Add a required password for modifying a protected model. If you do not add a password,
you are prompted to set a password when you create a modifiable, protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'mdlref_counter','password');
2-184
Simulink.ProtectedModel.getSupportedTargets
Add support to the protected model for the new target. You are prompted for the
modification password.
Simulink.ProtectedModel.addTarget('mdlref_counter');
Verify that support for the new target has been added to the protected model.
st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
Input Arguments
protectedModel — Model name
string or character vector
Output Arguments
supportedTargets — List of target identifiers
cell array of character vectors
List of target identifiers for the targets that the protected model supports, specified as a
cell array of character vectors.
See Also
See Also
Simulink.ModelReference.protect | Simulink.ProtectedModel.addTarget
| Simulink.ProtectedModel.getConfigSet |
2-185
2 Alphabetical List
Simulink.ProtectedModel.getCurrentTarget
| Simulink.ProtectedModel.removeTarget |
Simulink.ProtectedModel.setCurrentTarget
Topics
“Create a Protected Model with Multiple Targets”
“Use a Protected Model with Multiple Targets”
Introduced in R2015a
2-186
Simulink.ProtectedModel.open
Simulink.ProtectedModel.open
Open protected model
Syntax
Simulink.ProtectedModel.open(model)
Simulink.ProtectedModel.open(model,type)
Description
Simulink.ProtectedModel.open(model) opens a protected model. If you do not
specify how to view the protected model, the software first tries to open the Web view. If
the Web view is not enabled for the protected model, the software then tries to open the
report. If you did not create a report, the software reports an error.
Examples
Open a Protected Model
sldemo_mdlref_counter
save_system('sldemo_mdlref_counter','mdlref_counter.slx');
Create a protected model enabling support for code generation and reporting.
Simulink.ModelReference.protect('mdlref_counter','Mode',...
2-187
2 Alphabetical List
'CodeGeneration', 'Report',true);
Simulink.ProtectedModel.open('mdlref_counter')
The protected model does not have Web view enabled, so the protected model report is
opened.
sldemo_mdlref_counter
save_system('sldemo_mdlref_counter','mdlref_counter.slx');
Create a protected model with support for code generation, Web view, and reporting.
Simulink.ModelReference.protect('mdlref_counter','Mode',...
'CodeGeneration', 'Webview',true,'Report',true);
Open the protected model and specify that you want to see the Web view.
Simulink.ProtectedModel.open('mdlref_counter','webview')
Input Arguments
model — Model name
string or character vector
Method for viewing the protected model. If you specify ‘webview’, the software opens the
Web view for the protected model. If you specify ‘report’, the software opens the protected
model report.
2-188
Simulink.ProtectedModel.open
See Also
See Also
Simulink.ModelReference.protect
Introduced in R2015a
2-189
2 Alphabetical List
Simulink.ProtectedModel.removeTarget
Remove support for specified target from protected model
Syntax
Simulink.ProtectedModel.removeTarget(protectedModel,targetID)
Description
Simulink.ProtectedModel.removeTarget(protectedModel,targetID) removes
code generation support for the specified target from a protected model. You must
provide the modification password to make this update. Removing a target does not
require access to the unprotected model.
Note: You cannot remove the sim target. If you do not want the protected model to
support simulation, use the Simulink.ModelReference.modifyProtectedModel
function to change the protected model mode to ViewOnly.
Examples
Remove Target Support from a Protected Model
sldemo_mdlref_counter
save_system('sldemo_mdlref_counter','mdlref_counter.slx');
Add a required password for modifying a protected model. If you do not add a password,
you are prompted to set a password when you create a modifiable, protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'mdlref_counter','password');
2-190
Simulink.ProtectedModel.removeTarget
Simulink.ModelReference.protect('mdlref_counter','Mode',...
'CodeGeneration', 'Modifiable',true, 'Report',true);
Add support to the protected model for the new target. You are prompted for the
modification password.
Simulink.ProtectedModel.addTarget('mdlref_counter');
Verify that support for the new target has been added to the protected model.
st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
Remove support for the ert target from the protected model. You are prompted for the
modification password.
Simulink.ProtectedModel.removeTarget('mdlref_counter','ert');
Verify that support for the ert target has been removed from the protected model.
st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
Input Arguments
protectedModel — Model name
string or character vector
2-191
2 Alphabetical List
See Also
See Also
Simulink.ModelReference.modifyProtectedModel |
Simulink.ModelReference.protect | Simulink.ProtectedModel.addTarget
| Simulink.ProtectedModel.getConfigSet |
Simulink.ProtectedModel.getCurrentTarget |
Simulink.ProtectedModel.getSupportedTargets |
Simulink.ProtectedModel.setCurrentTarget
Topics
“Create a Protected Model with Multiple Targets”
Introduced in R2015a
2-192
Simulink.ProtectedModel.setCurrentTarget
Simulink.ProtectedModel.setCurrentTarget
Configure protected model to use specified target
Syntax
Simulink.ProtectedModel.setCurrentTarget(protectedModel, targetID)
Description
Simulink.ProtectedModel.setCurrentTarget(protectedModel, targetID)
configures the protected model to use the target that the target identifier specifies.
Note: If you include the protected model in a model reference hierarchy, the software
tries to change the current target to match the target of the parent model. If the software
cannot match the target of the parent, it reports an error.
Examples
Set Current Target for Protected Model
After you get a list of supported targets, set the current target for a protected model.
Add a required password for modifying a protected model. If you do not add a password,
you are prompted to set a password when you create a modifiable, protected model.
Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'mdlref_counter','password');
2-193
2 Alphabetical List
st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
Add support to the protected model for the new target. You are prompted for the
modification password.
Simulink.ProtectedModel.addTarget('mdlref_counter');
Verify that support for the new target has been added to the protected model.
st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
Simulink.ProtectedModel.setCurrentTarget('mdlref_counter','ert');
ct = Simulink.ProtectedModel.getCurrentTarget('mdlref_counter')
Input Arguments
protectedModel — Model name
string or character vector
2-194
Simulink.ProtectedModel.setCurrentTarget
See Also
See Also
Simulink.ModelReference.protect | Simulink.ProtectedModel.addTarget
| Simulink.ProtectedModel.getConfigSet |
Simulink.ProtectedModel.getCurrentTarget |
Simulink.ProtectedModel.getSupportedTargets |
Simulink.ProtectedModel.removeTarget
Topics
“Create a Protected Model with Multiple Targets”
“Use a Protected Model with Multiple Targets”
Introduced in R2015a
2-195
2 Alphabetical List
slConfigUIGetVal
Return current value for custom target configuration option
Syntax
value = slConfigUIGetVal(hDlg,hSrc,'OptionName')
Input Arguments
hDlg
Handle created in the context of a SelectCallback function and used by the
System Target File Callback Interface functions. Pass this variable but do not set it
or use it for another purpose.
hSrc
Handle created in the context of a SelectCallback function and used by the
System Target File Callback Interface functions. Pass this variable but do not set it
or use it for another purpose.
'OptionName'
Quoted name of the TLC variable defined for a custom target configuration option.
Output Arguments
Current value of the specified option. The data type of the return value depends on the
data type of the option.
Description
The slConfigUIGetVal function is used in the context of a user-written
SelectCallback function, which is triggered when the custom target is selected in
the System Target File Browser in the Configuration Parameters dialog box. You use
slConfigUIGetVal to read the current value of a specified target option.
2-196
slConfigUIGetVal
Examples
In the following example, the slConfigUIGetVal function returns the value of the
Terminate function required option on the All Parameters tab of the Configuration
Parameters dialog box.
function usertarget_selectcallback(hDlg,hSrc)
slConfigUISetVal(hDlg,hSrc,'IncludeMdlTerminateFcn','off');
slConfigUISetEnabled(hDlg,hSrc,'IncludeMdlTerminateFcn',false);
See Also
slConfigUISetEnabled | slConfigUISetVal
Topics
“Define and Display Custom Target Options”
“Custom Target Optional Features”
Introduced in R2006b
2-197
2 Alphabetical List
slConfigUISetEnabled
Enable or disable custom target configuration option
Syntax
slConfigUISetEnabled(hDlg,hSrc,'OptionName',true)
slConfigUISetEnabled(hDlg,hSrc,'OptionName',false)
Arguments
hDlg
Handle created in the context of a SelectCallback function and used by the
System Target File Callback Interface functions. Pass this variable but do not set it
or use it for another purpose.
hSrc
Handle created in the context of a SelectCallback function and used by the
System Target File Callback Interface functions. Pass this variable but do not set it
or use it for another purpose.
'OptionName'
Quoted name of the TLC variable defined for a custom target configuration option.
true
Specifies that the option should be enabled.
false
Specifies that the option should be disabled.
Description
The slConfigUISetEnabled function is used in the context of a user-written
SelectCallback function, which is triggered when the custom target is selected in
the System Target File Browser in the Configuration Parameters dialog box. You use
slConfigUISetEnabled to enable or disable a specified target option.
2-198
slConfigUISetEnabled
If you use this function to disable a parameter that is represented in the Configuration
Parameters dialog box, the parameter appears greyed out in the dialog context.
Examples
In the following example, the slConfigUISetEnabled function disables the Terminate
function required option on the All Parameters tab of the Configuration Parameters
dialog box.
function usertarget_selectcallback(hDlg,hSrc)
slConfigUISetVal(hDlg,hSrc,'IncludeMdlTerminateFcn','off');
slConfigUISetEnabled(hDlg,hSrc,'IncludeMdlTerminateFcn',false);
See Also
slConfigUIGetVal | slConfigUISetVal
Topics
“Define and Display Custom Target Options”
“Custom Target Optional Features”
Introduced in R2006b
2-199
2 Alphabetical List
slConfigUISetVal
Set value for custom target configuration option
Syntax
slConfigUISetVal(hDlg,hSrc,'OptionName',OptionValue)
Arguments
hDlg
Handle created in the context of a SelectCallback function and used by the
System Target File Callback Interface functions. Pass this variable but do not set it
or use it for another purpose.
hSrc
Handle created in the context of a SelectCallback function and used by the
System Target File Callback Interface functions. Pass this variable but do not set it
or use it for another purpose.
'OptionName'
Quoted name of the TLC variable defined for a custom target configuration option.
OptionValue
Value to be set for the specified option.
Description
The slConfigUISetVal function is used in the context of a user-written
SelectCallback function, which is triggered when the custom target is selected in
the System Target File Browser in the Configuration Parameters dialog box. You use
slConfigUISetVal to set the value of a specified target option.
2-200
slConfigUISetVal
Examples
In the following example, the slConfigUISetVal function sets the value 'off' for the
Terminate function required option on the All Parameters tab of the Configuration
Parameters dialog box.
function usertarget_selectcallback(hDlg,hSrc)
slConfigUISetVal(hDlg,hSrc,'IncludeMdlTerminateFcn','off');
slConfigUISetEnabled(hDlg,hSrc,'IncludeMdlTerminateFcn',false);
See Also
slConfigUIGetVal | slConfigUISetEnabled
Topics
“Define and Display Custom Target Options”
“Custom Target Optional Features”
Introduced in R2006b
2-201
2 Alphabetical List
switchTarget
Select target for configuration set
Syntax
switchTarget(myConfigObj,systemTargetFile,[])
switchTarget(myConfigObj,systemTargetFile,targetOptions)
Description
switchTarget(myConfigObj,systemTargetFile,[]) selects a system target file for
the active configuration set.
Examples
Select target file without options
% Get the active configuration set for 'model'
myConfigObj = getActiveConfigSet(model);
% Change the system target file for the configuration set.
switchTarget(myConfigObj,'ert.tlc',[]);
2-202
switchTarget
TLCOptions: '-aVarName=1'
MakeCommand: 'make_rtw'
Description: 'my target'
TemplateMakefile: 'grt_default_tmf'
Use options to select MSVC ERT target file, instead of default ERT target
% use switchTarget to select tmf build of MSVC ERT target
model='rtwdemo_rtwintro';
open_system(model);
myConfigObj = getActiveConfigSet(model);
targetOptions.MakeCommand = 'make_rtw';
targetOptions.Description = 'Create Visual C/C++ Solution File for Embedded Coder';
targetOptions.TemplateMakefile = 'RTW.MSVCBuild';
switchTarget(myConfigObj,'ert.tlc',targetOptions);
Input Arguments
myConfigObj — Input data
configuration set object
2-203
2 Alphabetical List
Specify the name of the system target file, such as ert.tlc for Embedded Coder, or
grt.tlc for Simulink Coder™.
Example: systemTargetFile = ‘ert.tlc’;
Data Types: char
Field Value
TemplateMakefile Character vector specifying file name of
template makefile.
TLCOptions Character vector specifying TLC argument.
MakeCommand Character vector specifying make command
MATLAB language file.
Description Character vector specifying description of
target.
See Also
See Also
getActiveConfigSet | Simulink.ConfigSet | Simulink.ConfigSetRef
Topics
“Select a System Target File Programmatically”
2-204
switchTarget
Introduced in R2009b
2-205
2 Alphabetical List
tlc
Invoke Target Language Compiler to convert model description file to generated code
Syntax
tlc [-options] [file]
Description
tlc invokes the Target Language Compiler (TLC) from the command prompt. The TLC
converts the model description file, model.rtw (or similar files), into target-specific code
or text. Typically, you do not call this command because the build process automatically
invokes the Target Language Compiler when generating code. For more information, see
“Introduction to the Target Language Compiler”.
Note: This command is used only when invoking the TLC separately from the build
process. You cannot use this command to initiate code generation for a model.
You can change the default behavior by specifying one or more compilation options as
described in “Options” on page 2-206
Options
You can specify one or more compilation options with each tlc command. Use spaces
to separate options and arguments. TLC resolves options from left to right. If you use
conflicting options, the right-most option prevails. The tlc options are:
2-206
tlc
Specify a number indicating the verbose level. If you omit this option, the default value is
one.
Specify a folder path to local include files. The TLC searches this path in the order
specified.
Specify the maximum number of errors reported by the TLC prior to terminating the
translation of the .tlc file.
2-207
2 Alphabetical List
If you omit this option, TLC places output files in the current folder.
-dn produce log files, which indicate those lines hit and those lines missed during
compilation.
-a Specify parameters
-a identifier = expression
Specify parameters to change the behavior of your TLC program. For example, this
option is used by the code generator to set inlining of parameters or file size limits.
-p Print progress
-p number
Print a '.' indicating progress for every number of TLC primitive operations executed.
2-208
tlc
Introduced in R2009a
2-209
2 Alphabetical List
updateFilePathsAndExtensions
Update files in model build information with missing paths and file extensions
Syntax
updateFilePathsAndExtensions(buildinfo, extensions)
extensions is optional.
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
extensions (optional)
A cell array of character arrays that specifies the extensions (file types) of files
for which to search and include in the update processing. By default, the function
searches for files with a .c extension. The function checks files and updates paths
and extensions based on the order in which you list the extensions in the cell array.
For example, if you specify {'.c' '.cpp'} and a folder contains myfile.c and
myfile.cpp, an instance of myfile would be updated to myfile.c.
Description
Using paths that already exist in the model build information, the
updateFilePathsAndExtensions function checks whether file references in the
build information need to be updated with a path or file extension. This function can be
particularly useful for
• Maintaining build information for a toolchain that requires the use of file extensions
• Updating multiple customized instances of build information for a given model
2-210
updateFilePathsAndExtensions
Examples
Create the folder path etcproj/etc in your working folder, add files etc.c, test1.c,
and test2.c to the folder etc. This example assumes the working folder is w:\work
\BuildInfo. From the working folder, update build information myModelBuildInfo
with missing paths or file extensions.
myModelBuildInfo = RTW.BuildInfo;
addSourcePaths(myModelBuildInfo, fullfile(pwd,...
'etcproj', '/etc'), 'test');
addSourceFiles(myModelBuildInfo, {'etc' 'test1'...
'test2'}, '', 'test');
before=getSourceFiles(myModelBuildInfo, true, true);
before
before =
updateFilePathsAndExtensions(myModelBuildInfo);
after=getSourceFiles(myModelBuildInfo, true, true);
after{:}
ans =
w:\work\BuildInfo\etcproj\etc\etc.c
ans =
w:\work\BuildInfo\etcproj\etc\test1.c
ans =
w:\work\BuildInfo\etcproj\etc\test2.c
See Also
addIncludeFiles | addIncludePaths | addSourceFiles | addSourcePaths |
updateFileSeparator
2-211
2 Alphabetical List
Topics
“Customize Post-Code-Generation Build Processing”
Introduced in R2006a
2-212
updateFileSeparator
updateFileSeparator
Change file separator used in model build information
Syntax
updateFileSeparator(buildinfo, separator)
Arguments
buildinfo
Build information returned by RTW.BuildInfo.
separator
A character array that specifies the file separator \ (Windows®) or / (UNIX®) to be
applied to file path specifications.
Description
The updateFileSeparator function changes instances of the current file separator (/ or
\) in the model build information to the specified file separator.
The default value for the file separator matches the value returned by the MATLAB
command filesep. For makefile based builds, you can override the default by defining
a separator with the MAKEFILE_FILESEP macro in the template makefile (see “Cross-
Compile Code Generated on Microsoft Windows”. If the GenerateMakefile parameter
is set, the code generator overrides the default separator and updates the model build
information after evaluating the PostCodeGenCommand configuration parameter.
Examples
Update object myModelBuildInfo to apply the Windows file separator.
myModelBuildInfo = RTW.BuildInfo;
updateFileSeparator(myModelBuildInfo, '\');
2-213
2 Alphabetical List
See Also
addIncludeFiles | addIncludePaths | addSourceFiles | addSourcePaths |
updateFilePathsAndExtensions
Topics
“Customize Post-Code-Generation Build Processing”
“Cross-Compile Code Generated on Microsoft Windows”
Introduced in R2006a
2-214
3
Async Interrupt
Generate Versa Module Eurocard (VME) interrupt service routines (ISRs) that are to
execute downstream subsystems or Task Sync blocks
Library
Asynchronous / Interrupt Templates
Description
For each specified VME interrupt level in the example RTOS (VxWorks®), the Async
Interrupt block generates an interrupt service routine (ISR) that calls one of the
following:
Note: You can use the blocks in the vxlib1 library (Async Interrupt and Task Sync)
for simulation and code generation. These blocks provide starting point examples to help
you develop custom blocks for your target environment.
Parameters
VME interrupt number(s)
An array of VME interrupt numbers for the interrupts to be installed. The valid
range is 1..7.
The width of the Async Interrupt block output signal corresponds to the number of
VME interrupt numbers specified.
3-2
Async Interrupt
Note A model can contain more than one Async Interrupt block. However, if you use
more than one Async Interrupt block, do not duplicate the VME interrupt numbers
specified in each block.
The Simulink task priority values are required to generate a rate transition code
(see “Rate Transitions and Asynchronous Blocks”). Simulink task priority values are
also required to maintain absolute time integrity when the asynchronous task needs
to obtain real time from its base rate or its caller. The assigned priorities typically
are higher than the priorities assigned to periodic tasks.
Note: The Simulink software does not simulate asynchronous task behavior. The
task priority of an asynchronous task is for code generation purposes only and is not
honored during simulation.
Higher priority interrupts can preempt lower priority interrupts in the example
RTOS (VxWorks). To lock out interrupts during the execution of an ISR, set the
preemption flag to 0. This causes generation of intLock() and intUnlock()
calls at the beginning and end of the ISR code. Use interrupt locking carefully,
as it increases the system's interrupt response time for interrupts at the
intLockLevelSet() level and below. Specify an array of flags corresponding to the
VME interrupt numbers entered in the VME interrupt number(s) field.
3-3
3 Blocks — Alphabetical List
Note The number of elements in the arrays specifying VME interrupt vector
offset(s) and Simulink task priority must match the number of elements in the
VME interrupt number(s) array.
If you are targeting an RTOS other than the example RTOS (VxWorks), you should
replace the tickGet call with an equivalent call to the target RTOS, or generate code
to read the timer register on the target hardware. For more information, see “Timers
in Asynchronous Tasks” and “Async Interrupt Block Implementation”.
Timer size
The number of bits to be used to store the clock tick for a hardware timer. The ISR
generated by the Async Interrupt block uses the timer size when you select Manage
own timer. The size can be 32bits (the default), 16bits, 8bits, or auto. If you
select auto, the code generator determines the timer size based on the settings of
Application lifespan (days) and Timer resolution.
By default, timer values are stored as 32-bit integers. However, when Timer size
is auto, you can indirectly control the word size of the counters by setting the
Application lifespan (days) option. If you set Application lifespan (days)
to a value that is too large for the code generator to handle as a 32-bit integer of
the specified resolution, the code generator uses a second 32-bit integer to address
overflows.
For more information, see “Control Memory Allocation for Time Counters”. See also
“Timers in Asynchronous Tasks”.
Enable simulation input
3-4
Async Interrupt
If checked, the Simulink software adds an input port to the Async Interrupt block.
This port is for use in simulation only. Connect one or more simulated interrupt
sources to the simulation input.
Note: Before generating code, consider removing blocks that drive the simulation
input to prevent the blocks from contributing to the generated code. Alternatively,
you can use the Environment Controller block, as explained in “Dual-Model
Approach: Code Generation”. However, if you use the Environment Controller block,
be aware that the sample times of driving blocks contribute to the sample times
supported in the generated code.
• Function-call subsystem
• Task Sync block
• Stateflow chart configured for a function call input event
3-5
3 Blocks — Alphabetical List
Performance Considerations
Execution of large subsystems at interrupt level can have a significant impact on
interrupt response time for interrupts of equal and lower priority in the system. As
a general rule, it is best to keep ISRs as short as possible. Connect only function-call
subsystems that contain a small number of blocks to an Async Interrupt block.
A better solution for large subsystems is to use the Task Sync block to synchronize the
execution of the function-call subsystem to a RTOS task. Place the Task Sync block
between the Async Interrupt block and the function-call subsystem. The Async Interrupt
block then uses the Task Sync block as the ISR. The ISR releases a synchronization
semaphore (performs a semGive) to the task, and returns immediately from interrupt
level. The example RTOS (VxWorks) then schedules and runs the task. See the
description of the Task Sync block for more information.
See Also
Task Sync
“Asynchronous Events”
Introduced in R2006a
3-6
Asynchronous Task Specification
Description
The Asynchronous Task Specification block specifies parameters, such as the task
priority, of an asynchronous task represented by a function-call subsystem that is
triggered by an asynchronous interrupt. Use this block to control scheduling of function-
call subsystems that are triggered by asynchronous events. You control the scheduling by
assigning a priority to each function-call subsystem within a referenced model.
To use this block, follow the procedure in “Convert an Asynchronous Subsystem into a
Model Reference”.
• The block must reside in a referenced model between a root level Inport block
and a function-call subsystem. The Asynchronous Task Specification block must
immediately follow and connect directly to the Inport block.
• The Inport block must receive an interrupt signal from an Async Interrupt block that
is in the parent model.
• The Inport block must be configured to receive and send function-call trigger signals.
3-7
3 Blocks — Alphabetical List
Ports
Input
Port_1 — Interrupt input signal
scalar
Output
Port_1 — Interrupt signal with priority
scalar
Interrupt signal with specified task priority that triggers a function-call subsystem.
3-8
Asynchronous Task Specification
Parameters
Task priority — Priority of asynchronous task that calls function-call subsystem
10 (default)
Specify an integer or [] as the priority of the asynchronous task that calls the connected
function-call subsystem. The priority must be a value that generates relevant rate
transition behaviors.
• If you specify an integer, it must match the priority value of the interrupt signal
initiator in the parent model.
• If you specify [], the priority does not have to match the priority of the interrupt signal
initiator in the top model. For this case, the rate transition algorithm is conservative
(not optimized). The algorithm assumes that the priority is unknown but static.
3-9
3 Blocks — Alphabetical List
If the Task priority parameter is set to 10, the Async Interrupt block in the parent
model must also have a priority of 10. Whereas, if the parameter is set to [], the priority
of the Async Interrupt block can be a value other than 10.
See Also
See Also
Blocks
Function-Call Subsystem | Inport
Topics
“Spawn and Synchronize Execution of RTOS Task”
“Pass Asynchronous Events in RTOS as Input To a Referenced Model”
“Convert an Asynchronous Subsystem into a Model Reference”
“Rate Transitions and Asynchronous Blocks”
“Asynchronous Support”
“Asynchronous Events”
“Model Referencing” (Simulink)
Introduced in R2011a
3-10
Generated S-Function
Generated S-Function
Represent model or subsystem as generated S-function code
Library
S-Function Target
Description
An instance of the Generated S-Function block represents code the code generator
produces from its S-function system target file for a model or subsystem. For example,
you extract a subsystem from a model and build a Generated S-Function block from it,
using the S-function target. This mechanism can be useful for
For details on how to create a Generated S-Function block from a subsystem, see “Create
S-Function Blocks from a Subsystem”.
Requirements
• The S-Function block must perform identically to the model or subsystem from which
it was generated.
• Before creating the block, explicitly specify Inport block signal attributes, such as
signal widths or sample times. The sole exception to this rule concerns sample times,
as described in “Sample Time Propagation in Generated S-Functions”.
3-11
3 Blocks — Alphabetical List
• You must set the solver parameters of the Generated S-Function block to be the
same as those of the original model or subsystem. The generated S-function code will
operate identically to the original subsystem (for an exception to this rule, see Choice
of Solver Type).
Parameters
Generated S-function name (model_sf)
The name of the generated S-function. The code generator derives the name by
appending _sf to the name of the model or subsystem from which the block is
generated.
Show module list
If checked, displays modules generated for the S-function.
See Also
“Create S-Function Blocks from a Subsystem”
Introduced in R2011b
3-12
Model Header
Model Header
Specify external header code
Description
For a model that includes the Model Header block, the code generator adds external code
that you specify to the header file (model.h) that it generates. You can specify code for
the code generator to add near the top and bottom of the header file.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
Top of Model Header — Code to add near top of generated header file
Specify code that you want the code generator to add near the top of the header file for
the model. The code generator places the code in the section labeled user code (top
of header file).
Specify code that you want the code generator to add at the bottom of the header file
for the model. The code generator places the code in the section labeled user code
(bottom of header file).
3-13
3 Blocks — Alphabetical List
See Also
See Also
Model Source | System Disable | System Outputs | System Update | System
Derivatives | System Enable | System Initialize | System Start | System
Terminate
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-14
Model Source
Model Source
Specify external source code
Description
For a model that includes the Model Source block, the code generator adds external code
that you specify to the source file (model.c or model.cpp) that it generates. You can
specify code for the code generator to add near the top and bottom of the source file.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
Top of Model Header — Code to add near top of generated source file
Specify code that you want the code generator to add near the top of the source file for
the model. The code generator places the code in the section labeled user code (top
of source file).
Specify code that you want the code generator to add at the bottom of the source file
for the model. The code generator places the code in the section labeled user code
(bottom of source file).
Example
See “Add External Code to Generated Start Function”.
3-15
3 Blocks — Alphabetical List
See Also
See Also
Model Header | System Disable | System Outputs | System Update | System
Derivatives | System Enable | System Initialize | System Start | System
Terminate
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-16
Protected RT
Protected RT
Handle transfer of data between blocks operating at different rates and maintain data
integrity
Library
VxWorks (vxlib1)
Description
The Protected RT block is a Rate Transition block that is preconfigured to maintain
data integrity during data transfers. For more information, see Rate Transition in the
Simulink Reference.
Introduced in R2006a
3-17
3 Blocks — Alphabetical List
System Derivatives
Specify external system derivative code
Description
For a model or nonvirtual subsystem that includes the System Derivatives block and a
block that computes continuous states, the code generator adds external code, which you
specify, to the SystemDerivatives function that it generates. You can specify code for
the code generator to add to the declaration, execution, and exit sections of the function
code.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
System Derivatives Function Declaration Code — Code to add to the declaration
section of the generated function
Specify code that you want the code generator to add to the declaration section of the
SystemDerivatives function for the model or subsystem.
Specify code that you want the code generator to add to the execution section of the
SystemDerivatives function for the model or subsystem.
System Derivatives Function Exit Code — Code to add to the exit section of the
generated function
Specify code that you want the code generator to add to the exit section of the
SystemDerivatives function for the model or subsystem.
3-18
System Derivatives
See Also
See Also
Model Header | Model Source | System Initialize | System Disable | System
Enable | System Outputs | System Start | System Terminate | System Update
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-19
3 Blocks — Alphabetical List
System Disable
Specify external system disable code
Description
For a model or nonvirtual subsystem that includes the System Disable block and a block
that uses a SystemDisable function, the code generator adds external code, which you
specify, to the SystemDisable function that it generates. You can specify code for the
code generator to add to the declaration, execution, and exit sections of the function code.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
System Disable Function Declaration Code — Code to add to the declaration
section of the generated function
Specify code that you want the code generator to add to the declaration section of the
SystemDisable function for the model or subsystem.
System Disable Function Execution Code — Code to add to the execution section of
the generated function
Specify code that you want the code generator to add to the execution section of the
SystemDisable function for the model or subsystem.
System Disable Function Exit Code — Code to add to the exit section of the
generated function
Specify code that you want the code generator to add to the exit section of the
SystemDisable function for the model or subsystem.
3-20
System Disable
See Also
See Also
Model Header | Model Source | System Initialize | System Derivatives |
System Enable | System Outputs | System Start | System Terminate | System
Update
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-21
3 Blocks — Alphabetical List
System Enable
Specify external system enable code
Description
For a model or nonvirtual subsystem that includes the System Enable block and a block
that uses a SystemEnable function, the code generator adds external code, which you
specify, to the SystemEnable function that it generates. You can specify code for the
code generator to add to the declaration, execution, and exit sections of the function code.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
System Enable Function Declaration Code — Code to add to the declaration
section of the generated function
Specify code that you want the code generator to add to the declaration section of the
SystemEnable function for the model or subsystem.
System Enable Function Execution Code — Code to add to the execution section of
the generated function
Specify code that you want the code generator to add to the execution section of the
SystemEnable function for the model or subsystem.
System Enable Function Exit Code — Code to add to the exit section of the generated
function
Specify code that you want the code generator to add to the exit section of the
SystemEnable function for the model or subsystem.
3-22
System Enable
See Also
See Also
Model Header | Model Source | System Initialize | System Derivatives
| System Disable | System Outputs | System Start | System Terminate |
System Update
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-23
3 Blocks — Alphabetical List
System Initialize
Specify external system initialization code
Description
For a model or nonvirtual subsystem that includes the System Initialize block and a
block that uses a SystemInitialize function, the code generator adds external code,
which you specify, to the SystemInitialize function that it generates. You can specify
code for the code generator to add to the declaration, execution, and exit sections of the
function code.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
System Initialize Function Declaration Code — Code to add to the declaration
section of the generated function
Specify code that you want the code generator to add to the declaration section of the
SystemInitialize function for the model or subsystem.
Specify code that you want the code generator to add to the execution section of the
SystemInitialize function for the model or subsystem.
System Initialize Function Exit Code — Code to add to the exit section of the
generated function
Specify code that you want the code generator to add to the exit section of the
SystemInitialize function for the model or subsystem.
3-24
System Initialize
See Also
See Also
Model Header | Model Source | System Enable | System Derivatives | System
Disable | System Outputs | System Start | System Terminate | System
Update
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-25
3 Blocks — Alphabetical List
System Outputs
Specify external system outputs code
Description
For a model or nonvirtual subsystem that includes the System Outputs block and a block
that uses a SystemOutputs function, the code generator adds external code, which you
specify, to the SystemOutputs function that it generates. You can specify code for the
code generator to add to the declaration, execution, and exit sections of the function code.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
System Outputs Function Declaration Code — Code to add to the declaration
section of the generated function
Specify code that you want the code generator to add to the declaration section of the
SystemOutputs function for the model or subsystem.
System Outputs Function Execution Code — Code to add to the execution section of
the generated function
Specify code that you want the code generator to add to the execution section of the
SystemOutputs function for the model or subsystem.
System Outputs Function Exit Code — Code to add to the exit section of the
generated function
Specify code that you want the code generator to add to the exit section of the
SystemOutputs function for the model or subsystem.
3-26
System Outputs
See Also
See Also
Model Header | Model Source | System Enable | System Derivatives | System
Disable | System Initialize | System Start | System Terminate | System
Update
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-27
3 Blocks — Alphabetical List
System Start
Specify external system startup code
Description
For a model or nonvirtual subsystem that includes the System Start block and a block
that uses a SystemStart function, the code generator adds external code, which you
specify, to the SystemStart function that it generates. You can specify code for the code
generator to add to the declaration, execution, and exit sections of the function code.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
System Start Function Declaration Code — Code to add to the declaration section
of the generated function
Specify code that you want the code generator to add to the declaration section of the
SystemStart function for the model or subsystem.
System Start Function Execution Code — Code to add to the execution section of
the generated function
Specify code that you want the code generator to add to the execution section of the
SystemStart function for the model or subsystem.
System Start Function Exit Code — Code to add to the exit section of the generated
function
Specify code that you want the code generator to add to the exit section of the
SystemStart function for the model or subsystem.
3-28
System Start
See Also
See Also
Model Header | Model Source | System Enable | System Terminate | System
Derivatives | System Disable | System Initialize | System Outputs |
System Update
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-29
3 Blocks — Alphabetical List
System Terminate
Specify external system termination code
Description
For a model or nonvirtual subsystem that includes the System Terminate block and a
block that uses a SystemTerminate function, the code generator adds external code,
which you specify, to the SystemTerminate function that it generates. You can specify
code for the code generator to add to the declaration, execution, and exit sections of the
function code.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
System Terminate Function Declaration Code — Code to add to the declaration
section of the generated function
Specify code that you want the code generator to add to the declaration section of the
SystemTerminate function for the model or subsystem.
System Disable Terminate Execution Code — Code to add to the execution section
of the generated function
Specify code that you want the code generator to add to the execution section of the
SystemTerminate function for the model or subsystem.
System Disable Terminate Exit Code — Code to add to the exit section of the
generated function
Specify code that you want the code generator to add to the exit section of the
SystemTerminate function for the model or subsystem.
3-30
System Terminate
See Also
See Also
Model Header | Model Source | System Enable | System Start | System
Derivatives | System Disable | System Initialize | System Outputs |
System Update
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-31
3 Blocks — Alphabetical List
System Update
Specify external system update code
Description
For a model or nonvirtual subsystem that includes the System Update block and a block
that uses a SystemUpdate function, the code generator adds external code, which you
specify, to the SystemUpdate function that it generates. You can specify code for the
code generator to add to the declaration, execution, and exit sections of the function code.
Note: If you include this block in a referenced model, the code generator ignores the block
for simulation target builds, but processes the block for other system target files.
Parameters
System Update Function Declaration Code — Code to add to the declaration
section of the generated function
Specify code that you want the code generator to add to the declaration section of the
SystemUpdate function for the model or subsystem.
System Update Function Execution Code — Code to add to the execution section of
the generated function
Specify code that you want the code generator to add to the execution section of the
SystemUpdate function for the model or subsystem.
System Update Function Exit Code — Code to add to the exit section of the generated
function
Specify code that you want the code generator to add to the exit section of the
SystemUpdate function for the model or subsystem.
3-32
System Update
See Also
See Also
Model Header | Model Source | System Enable | System Start | System
Derivatives | System Disable | System Initialize | System Outputs |
System Terminate
Topics
“Place External C/C++ Code in Generated Code” (Embedded Coder)
Introduced in R2006a
3-33
3 Blocks — Alphabetical List
Task Sync
Spawn an example RTOS (VxWorks) task to run code of downstream function-call
subsystem or Stateflow chart
Library
Asynchronous / Interrupt Templates
Description
The Task Sync block spawns an example RTOS (VxWorks) task that calls a function-call
subsystem or Stateflow chart. Typically, you place the Task Sync block between an Async
Interrupt block and a function-call subsystem block or Stateflow chart. Alternatively, you
might connect the Task Sync block to the output port of a Stateflow diagram that has an
event, Output to Simulink, configured as a function call.
• Uses the RTOS (VxWorks) system call taskSpawn to spawn an independent task.
When the task is activated, it calls the downstream function-call subsystem code
or Stateflow chart. The block calls taskDelete to delete the task during model
termination.
• Creates a semaphore to synchronize the connected subsystem with execution of the
block.
• Wraps the spawned task in an infinite for loop. In the loop, the spawned task listens
for the semaphore, using semTake. The first call to semTake specifies NO_WAIT.
This allows the task to determine whether a second semGive has occurred prior to
the completion of the function-call subsystem or chart. This would indicate that the
interrupt rate is too fast or the task priority is too low.
• Generates synchronization code (for example, semGive()). This code allows the
spawned task to run. The task in turn calls the connected function-call subsystem
code. The synchronization code can run at interrupt level. This is accomplished
3-34
Task Sync
through the connection between the Async Interrupt and Task Sync blocks, which
triggers execution of the Task Sync block within an ISR.
• Supplies absolute time if blocks in the downstream algorithmic code require it. The
time is supplied either by the timer maintained by the Async Interrupt block, or by an
independent timer maintained by the task associated with the Task Sync block.
When you design your application, consider when timer and signal input values should
be taken for the downstream function-call subsystem that is connected to the Task Sync
block. By default, the time and input data are read when the RTOS (VxWorks) activates
the task. For this case, the data (input and time) are synchronized to the task itself.
If you select the Synchronize the data transfer of this task with the caller task
option and the Task Sync block is driven by an Async Interrupt block, the time and input
data are read when the interrupt occurs (that is, within the ISR). For this case, data is
synchronized with the caller of the Task Sync block.
Note: You can use the blocks in the vxlib1 library (Async Interrupt and Task Sync)
for simulation and code generation. These blocks provide starting point examples to help
you develop custom blocks for your target environment.
Parameters
Task name (10 characters or less)
The first argument passed to the taskSpawn system call in the RTOS. The RTOS
(VxWorks) uses this name as the task function name. This name also serves as a
debugging aid; routines use the task name to identify the task from which they are
called.
Simulink task priority (0–255)
The RTOS task priority to be assigned to the function-call subsystem task when
spawned. RTOS (VxWorks) priorities range from 0 to 255, with 0 representing the
highest priority.
Note: The Simulink software does not simulate asynchronous task behavior. The
task priority of an asynchronous task is for code generation purposes only and is not
honored during simulation.
3-35
3 Blocks — Alphabetical List
Maximum size to which the task's stack can grow. The stack size is allocated when
the RTOS (VxWorks) spawns the task. Choose a stack size based on the number of
local variables in the task. You should determine the size by examining the generated
code for the task (and functions that are called from the generated code).
Synchronize the data transfer of this task with the caller task
If not checked (the default),
• The block maintains a timer that provides absolute time values required by
the computations of downstream blocks. The timer is independent of the timer
maintained by the Async Interrupt block that calls the Task Sync block.
• A Timer resolution option appears.
• The Timer size option specifies the word size of the time counter.
If checked,
• The block does not maintain an independent timer, and does not display the
Timer resolution field.
• Downstream blocks that require timers use the timer maintained by the Async
Interrupt block that calls the Task Sync block (see “Timers in Asynchronous
Tasks”). The timer value is read at the time the asynchronous interrupt is
serviced, and data transfers to blocks called by the Task Sync block and execute
within the task associated with the Async Interrupt block. Therefore, data
transfers are synchronized with the caller.
By default, timer values are stored as 32-bit integers. However, when Timer size
is auto, you can indirectly control the word size of the counters by setting the
Application lifespan (days) option. If you set Application lifespan (days) to
3-36
Task Sync
a value that is too large for the code generator to handle as a 32-bit integer of the
specified resolution, it uses a second 32-bit integer to address overflows.
For more information, see “Control Memory Allocation for Time Counters”. See also
“Timers in Asynchronous Tasks”.
See Also
Async Interrupt
“Asynchronous Events”
Introduced in R2006a
3-37
3 Blocks — Alphabetical List
Unprotected RT
Handle transfer of data between blocks operating at different rates and maintain
determinism
Library
VxWorks (vxlib1)
Description
The Unprotected RT block is a Rate Transition block that is preconfigured to conduct
deterministic data transfers. For more information, see Rate Transition in the Simulink
Reference.
Introduced in R2006a
3-38
4
On the Configuration Parameters dialog box, the following configuration parameters are
on the Commonly Used tab, on the Code Generation pane or on the All Parameters
tab in the Code Generation category.
Parameter Description
“System target file” on page 4-5 Specify which target file configuration will
be used.
“Browse” on page 4-7 Browse file configuration options.
“Language” on page 4-8 Specify C or C++ code generation.
“Description” on page 4-10 A description of the target file.
“Toolchain” on page 4-11 Specify the toolchain to use when building
an executable or library.
“Build configuration” on page 4-13 Specify compiler optimization or debug
settings for toolchain.
“Tool/Options” on page 4-16 Display or customize build configuration
settings.
“Compiler optimization level” on page Control compiler optimizations for building
4-18 generated code.
“Custom compiler optimization flags” on Specify custom compiler optimization flags.
page 4-20
“Generate makefile” on page 4-22 Enable generation of a makefile based on a
template makefile.
“Make command” on page 4-24 Specify a make command and optionally
append makefile options.
“Template makefile” on page 4-26 Specify the template makefile from which
to generate the makefile.
“Select objective” on page 4-28 Select code generation objectives to use
with the Code Generation Advisor.
4-2
Model Configuration Parameters: Code Generation
Parameter Description
“Prioritized objectives” on page 4-30 List objectives that you specify by clicking
the Set Objectives button.
“Set Objectives” on page 4-31 Open Configuration Set Objectives dialog
box.
“Set Objectives — Code Generation Advisor Select and prioritize code generation
Dialog Box” on page 4-32 objectives.
“Check Model” on page 4-35 Check whether the model meets code
generation objectives.
“Check model before generating code” on Choose whether to run Code Generation
page 4-36 Advisor checks before generating code.
“Generate code only” on page 4-38 Specify code generation versus an
executable build.
“Package code and artifacts” on page Specify whether to automatically package
4-40 generated code and artifacts for relocation.
“Zip file name” on page 4-42 Specify the name of the .zip file in which
to package generated code and artifacts for
relocation.
The Configuration Parameters dialog box also includes other code generation:
More About
• “Model Configuration”
4-3
4 Code Generation Parameters: Code Generation
To open the Code Generation pane, in the Simulink Editor, select Simulation >
Model Configuration Parameters > Code Generation.
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
4-4
System target file
Settings
Default: grt.tlc
• Use the System Target File Browser. Click the Browse button, which lets you select
a preset target configuration consisting of a system target file, template makefile, and
make command.
• Enter the name of your system target file in this field.
Tips
• The System Target File Browser lists system target files found on the MATLAB path.
Some system target files require additional licensed products.
• Using ERT-based system target files such as ert.tlc to generate code requires an
Embedded Coder license.
• When you switch from a system target file that is not ERT-based to a file that is ERT-
based, the configuration parameter Default parameter behavior sets to Inlined
by default. However, you can change the setting of Default parameter behavior
later. For more information, see “Default parameter behavior” (Simulink).
• To configure your model for rapid simulation, select rsim.tlc.
• To configure your model for Simulink Real-Time™, select slrt.tlc.
Command-Line Information
Parameter: SystemTargetFile
Type: character vector
Value: valid system target file
Default: 'grt.tlc'
4-5
4 Code Generation Parameters: Code Generation
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
ERT based (requires Embedded Coder license)
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Compare System Target File Support”
4-6
Browse
Browse
Description
Open the System Target File Browser, which lets you select a preset target configuration
consisting of a system target file, template makefile, and make command. The value you
select is filled into “System target file” on page 4-5.
Tips
• The System Target File Browser lists system target files found on the MATLAB path.
Some system target files require additional licensed products, such as the Embedded
Coder product.
• To configure your model for rapid simulation, select rsim.tlc.
• To configure your model for Simulink Real-Time, select slrt.tlc.
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Select a System Target File”
• “Compare System Target File Support”
4-7
4 Code Generation Parameters: Code Generation
Language
Description
Specify C or C++ code generation.
Settings
Default: C
C
Generates C code and places the generated files in your build folder.
C++
Generates C++ code and places the generated files in your build folder.
On the Code Generation > Interface pane, if you additionally set the Code
interface packaging parameter to C++ class, the build generates a C++ class
interface to model code. The generated interface encapsulates required model data
into C++ class attributes and model entry point functions into C++ class methods.
If you set Code interface packaging to a value other than C++ class, the build
generates C++ compatible .cpp files containing model interfaces enclosed within an
extern "C" link directive.
You might need to configure the Simulink Coder software to use a compiler before you
build a system.
Dependencies
Selecting C++ enables and selects the value C++ class for the Code interface
packaging parameter on the Code Generation > Interface pane.
Command-Line Information
Parameter: TargetLang
Type: character vector
4-8
Language
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Select C or C++ Programming Language”
• “Select and Configure C or C++ Compiler or IDE”
• “Control Generation of Function Prototypes” (Embedded Coder)
• “Control Generation of C++ Class Interfaces” (Embedded Coder)
4-9
4 Code Generation Parameters: Code Generation
Description
Description
This field displays the description of the system target file. You can use this description
to differentiate between two system target files that have the same file name. To change
the value of this description, click the Browse button.
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Browse” on page 4-7
4-10
Toolchain
Toolchain
Description
Specify the toolchain to use when building an executable or library.
Note: This parameter only appears when the model is configured to use a toolchain-based
code generation target, as described in “Choose and Configure Build Process”.
Settings
Default: Automatically locate an installed toolchain
The list of available toolchains depends on the host computer platform, and can include
custom toolchains that you added.
Tip
Click the All Parameters > Toolchain > Validate button to verify that the registration
information for the toolchain is valid. When the validation process is complete, a separate
Validation report window opens and displays the results. The Validation report states
whether the toolchain registration Passed or Failed and provides status for each step
in the validation process. To fix a failure, edit the toolchain definition and repeat the
registration process.
Command-Line Information
Parameter: Toolchain
4-11
4 Code Generation Parameters: Code Generation
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Toolchain Configuration”
• “Adding a Custom Toolchain” (MATLAB Coder)
4-12
Build configuration
Build configuration
Description
Specify compiler optimization or debug settings for toolchain.
Note: This parameter only appears when the model is configured to use a toolchain-based
code generation target, as described in “Choose and Configure Build Process”.
Settings
Default: Faster Builds
Faster Builds
Optimize for shorter build times.
Faster Runs
Optimize for faster-running executable.
Debug
Optimize for debugging.
Specify
Selecting Specify displays a table of tools with editable options. Use this table to
customize settings for the current model. See “Tool/Options” on page 4-16.
This interaction helps synchronize the Toolchain value and manually specified
Build configuration values.
Modifying the Build configuration value can affect the Toolchain value. The
Automatically locate an installed toolchain is the only value for Toolchain
that is affected by changing the Build configuration to Specify.
• Changing the Build configuration from any value to Specify, changes the
Toolchain value Automatically locate an installed toolchain (default)
to the value of the toolchain that was located (for example, Microsoft Visual C++
2012 v11.0 |(64-bit Windows)).
4-13
4 Code Generation Parameters: Code Generation
• Changing the Build configuration from Specify to any other value has no effect on
the Toolchain value.
Tip
Click Show settings to display a table of tools with options for the current build
configuration. See “Tool/Options” on page 4-16.
Customize the toolchain options for the Specify build configuration. These options only
apply to the current project.
To extract macro definitions (including compiler optimization flags) from the generated
makefile for toolchain approach builds on Windows or UNIX systems, see the model.bat
description in “Manage Build Process Files”.
Dependencies
Selecting Specify displays a table of tools with editable options. Use this table to
customize settings for the current model. See “Tool/Options” on page 4-16.
Command-Line Information
Parameter: BuildConfiguration
Type: character vector
Value: 'Faster Builds' | 'Faster Runs' | 'Debug' | 'Specify'
Default: 'Faster Builds'
Recommended Settings
Application Setting
Debugging Debug
Traceability No impact
Efficiency Faster Runs
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
4-14
Build configuration
• “Toolchain Configuration”
• “Adding a Custom Toolchain” (MATLAB Coder)
4-15
4 Code Generation Parameters: Code Generation
Tool/Options
Description
Display or customize build configuration settings.
Note: These parameters only appear when the model is configured to use the toolchain
approach, as described in “Choose and Configure Build Process”
Settings
The tools column can include: Assembler, C Compiler, Linker, Shared Library Linker,
C++ Compiler, C++ Linker, C++ Shared Library Linker, Archiver, Download, Execute,
Make Tool. The options can vary by tool and toolchain and can contain macros. Consult
third-party toolchain documentation for more information about options you can use with
a specific tool.
Dependencies
To display a table of tools and options for the current build configuration, click Show
settings, next to Build configuration.
Command-Line Information
Parameter: CustomToolchainOptions
Type: character vector
Value: Specify the baseline toolchain settings. Use a new-line-delineated character
vector to specify each option and its values.
Default: ''
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
4-16
Tool/Options
• “Toolchain Configuration”
• “Adding a Custom Toolchain” (MATLAB Coder)
4-17
4 Code Generation Parameters: Code Generation
Note: This parameter only appears when the model is configured to use a template
makefile-based code generation target, as described in “Choose and Configure Build
Process”.
Settings
Default: Optimizations off (faster builds)
Tips
• Target-independent values Optimizations on (faster runs) and
Optimizations off (faster builds) allow you to easily toggle compiler
optimizations on and off during code development.
• Custom allows you to enter custom compiler optimization flags at Simulink GUI
level, rather than editing compiler flags into template makefiles (TMFs) or supplying
compiler flags to make commands.
• If you specify compiler options for your makefile build using OPT_OPTS, MEX_OPTS
(except MEX_OPTS="-v"), or MEX_OPT_FILE, the value of Compiler optimization
level is ignored and a warning is issued about the ignored parameter.
4-18
Compiler optimization level
Dependencies
This parameter enables Custom compiler optimization flags.
Command-Line Information
Parameter: RTWCompilerOptimization
Type: character vector
Value: 'off' | 'on' | 'custom'
Default: 'off'
Recommended Settings
Application Setting
Debugging Optimizations off (faster builds)
Traceability Optimizations off (faster builds)
Efficiency Optimizations on (faster runs)
(execution), No impact (ROM, RAM)
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Custom compiler optimization flags” on page 4-20
• “Control Compiler Optimizations”
4-19
4 Code Generation Parameters: Code Generation
Note: This parameter only appears when the model is configured to use a template
makefile-based code generation target, as described in “Choose and Configure Build
Process”.
Settings
Default: ''
Dependency
This parameter is enabled by selecting the value Custom for the parameter Compiler
optimization level.
Command-Line Information
Parameter: RTWCustomCompilerOptimizations
Type: character vector
Value: '' | user-specified flags
Default: ''
Recommended Settings
See “Compiler optimization level” on page 4-18.
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
4-20
Custom compiler optimization flags
4-21
4 Code Generation Parameters: Code Generation
Generate makefile
Description
Enable generation of a makefile based on a template makefile.
Note: This option only appears when the model is configured to use a template makefile-
based code generation target, as described in “Choose and Configure Build Process”.
Settings
Default: on
On
Generates a makefile for a model during the build process.
Off
Suppresses the generation of a makefile. You must set up post code generation build
processing, including compilation and linking, as a user-defined command.
Dependencies
This parameter enables:
• Make command
• Template makefile
Command-Line Information
Parameter: GenerateMakefile
Type: character vector
Value: 'on' | 'off'
Default: 'on'
4-22
Generate makefile
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Customize Post-Code-Generation Build Processing”
• “Customize Build Process with STF_make_rtw_hook File”
• “Target Development and the Build Process”
4-23
4 Code Generation Parameters: Code Generation
Make command
Description
Specify a make command and optionally append makefile options.
Note: This parameter only appears when the model is configured to use a template
makefile-based code generation target, as described in “Choose and Configure Build
Process”.
Settings
Default: make_rtw
An internal MATLAB command used by code generation software to control the build
process. The specified make command is invoked when you start a build.
• Each target has an associated make command, automatically supplied when you
select a target file using the System Target File Browser.
• Some third-party targets supply a make command. See the vendor's documentation.
• You can supply makefile options in the Make command field. The options are passed
to the command-line invocation of the make utility, which adds them to the overall
flags passed to the compiler. Append the options after the make command, as in the
following example:
make_rtw OPTS="-DMYDEFINE=1"
The syntax for makefile options differs slightly for different compilers.
Tip
• Most targets use the default command.
• You should not invoke make_rtw or other internal make commands directly from
MATLAB code. To initiate a model build from MATLAB code, use documented build
commands such as slbuild or rtwbuild.
4-24
Make command
Dependency
This parameter is enabled by Generate makefile.
Command-Line Information
Parameter: MakeCommand
Type: character vector
Value: valid make command MATLAB language file
Default: 'make_rtw'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Template Makefiles and Make Options”
• “Customize Build Process with STF_make_rtw_hook File”
• “Target Development and the Build Process”
4-25
4 Code Generation Parameters: Code Generation
Template makefile
Description
Specify the template makefile from which to generate the makefile.
Note: This parameter only appears when the model is configured to use a template
makefile-based code generation target, as described in “Choose and Configure Build
Process”.
Settings
Default: grt_default_tmf
The template makefile determines which compiler runs, during the make phase of the
build, to compile the generated code. You can specify template makefiles in the following
ways:
• Generate a value by selecting a target configuration using the System Target File
Browser.
• Explicitly enter a custom template makefile filename (including the extension). The
file must be on the MATLAB path.
Tips
• If you do not include a filename extension for a custom template makefile, the code
generator attempts to find and execute a MATLAB language file.
• You can customize your build process by modifying an existing template makefile or
by providing your own template makefile.
Dependency
This parameter is enabled by Generate makefile.
4-26
Template makefile
Command-Line Information
Parameter: TemplateMakefile
Type: character vector
Value: valid template makefile filename
Default: 'grt_default_tmf'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Template Makefiles and Make Options”
• “Compare System Target File Support”
4-27
4 Code Generation Parameters: Code Generation
Select objective
Description
Select code generation objectives to use with the Code Generation Advisor.
Settings
Default: Unspecified
Unspecified
No objective specified. Do not optimize code generation settings using the Code
Generation Advisor.
Debugging
Specifies debugging objective. Optimize code generation settings for debugging the
code generation build process using the Code Generation Advisor.
Execution efficiency
Specifies execution efficiency objective. Optimize code generation settings to achieve
fast execution time using the Code Generation Advisor.
Tips
For more objectives, specify an ERT-based target.
Dependency
These parameters appear only for GRT-based targets.
Command-Line Information
Parameter: 'ObjectivePriorities'
Type: cell array of character vectors
Value: {''} | {'Debugging'} | {'Execution efficiency'}
Default: {''}
4-28
Select objective
Recommended Settings
Application Setting
Debugging Debugging
Traceability Not applicable for GRT-based targets
Efficiency Execution efficiency
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Configure Model for Code Generation Objectives by Using Code Generation
Advisor” (Embedded Coder)
• “Application Objectives Using Code Generation Advisor”
4-29
4 Code Generation Parameters: Code Generation
Prioritized objectives
Description
List objectives that you specify by clicking the Set Objectives button.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Command: get_param('model', 'ObjectivePriorities')
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Configure Model for Code Generation Objectives by Using Code Generation
Advisor” (Embedded Coder)
• “Application Objectives Using Code Generation Advisor”
4-30
Set Objectives
Set Objectives
Description
Open Configuration Set Objectives dialog box.
Dependency
This button appears only for ERT-based targets.
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Configure Model for Code Generation Objectives by Using Code Generation
Advisor” (Embedded Coder)
• “Application Objectives Using Code Generation Advisor”
4-31
4 Code Generation Parameters: Code Generation
Description
Select and prioritize code generation objectives to use with the Code Generation Advisor.
Settings
1 From the Available objectives list, select objectives.
2 Click the select button (arrow pointing right) to move the objectives that you selected
into the Selected objectives - prioritized list.
3 Click the higher priority (up arrow) and lower priority (down arrow) buttons to
prioritize the objectives.
4-32
Set Objectives — Code Generation Advisor Dialog Box
Objectives
List of available objectives.
Execution efficiency — Configure code generation settings to achieve fast execution
time.
ROM efficiency — Configure code generation settings to reduce ROM usage.
RAM efficiency — Configure code generation settings to reduce RAM usage.
Traceability — Configure code generation settings to provide mapping between model
elements and code.
Safety precaution — Configure code generation settings to increase clarity,
determinism, robustness, and verifiability of the code.
Debugging — Configure code generation settings to debug the code generation build
process.
MISRA C:2012 guidelines — Configure code generation settings to increase
compliance with MISRA C:2012 guidelines.
Polyspace — Configure code generation settings to prepare the code for Polyspace®
analysis.
Note: If you select the MISRA C:2012 guidelines code generation objective, the Code
Generation Advisor checks:
• The model configuration settings for compliance with the MISRA C:2012
configuration setting recommendations.
• For blocks that are not supported or recommended for MISRA C:2012 compliant code
generation.
Priorities
After you select objectives from the Available objectives parameter, organize the
objectives in the Selected objectives - prioritized parameter with the highest priority
objective at the top.
Dependency
This dialog box appears only for ERT-based targets.
Command-Line Information
Parameter: 'ObjectivePriorities'
4-33
4 Code Generation Parameters: Code Generation
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Configure Model for Code Generation Objectives by Using Code Generation
Advisor” (Embedded Coder)
• “Application Objectives Using Code Generation Advisor”
4-34
Check Model
Check Model
Description
Run the Code Generation Advisor checks.
Settings
1 Specify code generation objectives using the Select objective parameter (available
with GRT-based targets) or in the Configuration Set Objectives dialog box, by
clicking Set Objectives (available with ERT-based targets).
2 Click Check Model. The Code Generation Advisor runs the code generation
objectives checks and provide suggestions for changing your model to meet the
objectives.
Dependency
You must specify objectives before checking the model.
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Configure Model for Code Generation Objectives by Using Code Generation
Advisor” (Embedded Coder)
• “Application Objectives Using Code Generation Advisor”
4-35
4 Code Generation Parameters: Code Generation
Description
Choose whether to run Code Generation Advisor checks before generating code.
Settings
Default: Off
Off
Generates code without checking whether the model meets code generation
objectives. The code generation report summary and file headers indicate the
specified objectives and that the validation was not run.
On (proceed with warnings)
Checks whether the model meets code generation objectives using the Code
Generation Objectives checks in the Code Generation Advisor. If the Code Generation
Advisor reports a warning, the code generator continues producing code. The code
generation report summary and file headers indicate the specified objectives and the
validation result.
On (stop for warnings)
Checks whether the model meets code generation objectives using the Code
Generation Objectives checks in the Code Generation Advisor. If the Code Generation
Advisor reports a warning, the code generator does not continue producing code.
Command-Line Information
Parameter: CheckMdlBeforeBuild
Type: character vector
Value: 'Off' | 'Warning' | 'Error'
Default: 'Off'
4-36
Check model before generating code
Recommended Settings
Application Setting
Debugging On (proceed with warnings) or On (stop
for warnings)
Traceability On (proceed with warnings) or On (stop
for warnings)
Efficiency On (proceed with warnings) or On (stop
for warnings)
Safety precaution On (proceed with warnings) or On (stop
for warnings)
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Configure Model for Code Generation Objectives by Using Code Generation
Advisor” (Embedded Coder)
• “Application Objectives Using Code Generation Advisor”
4-37
4 Code Generation Parameters: Code Generation
Description
Specify code generation versus an executable build.
Settings
Default: off
On
The build process generates code and a makefile, but it does not invoke the make
command.
Off
The build process generates and compiles code, and creates an executable file.
Tip
Generate code only generates a makefile only if you select Generate makefile.
Command-Line Information
Parameter: GenCodeOnly
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging Off
Traceability No impact
Efficiency No impact
4-38
Generate code only
Application Setting
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Customize Post-Code-Generation Build Processing”
4-39
4 Code Generation Parameters: Code Generation
Settings
Default: off
On
The build process runs the packNGo function after code generation to package
generated code and artifacts for relocation.
Off
The build process does not run packNGo after code generation.
Dependency
Selecting this parameter enables Zip file name and clearing this parameter disables
Zip file name.
Command-Line Information
Parameter: PackageGeneratedCodeAndArtifacts
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
4-40
Package code and artifacts
Application Setting
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Relocate Code to Another Development Environment”
• “packNGo Function Limitations”
4-41
4 Code Generation Parameters: Code Generation
Settings
Default: ''
You can enter the name of the zip file in which to package generated code and artifacts
for relocation. The file name can be specified with or without the .zip extension. If you
do not specify an extension or an extension other than .zip, the zip utility adds the
.zip extension. If a value is not specified, the build process uses the name model.zip,
where model is the name of the top model for which code is being generated.
Dependency
This parameter is enabled by Package code and artifacts.
Command-Line Information
Parameter: PackageName
Type: character vector
Value: valid name for a .zip file
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
4-42
Zip file name
Related Examples
• “Model Configuration Parameters: Code Generation” on page 4-2
• “Relocate Code to Another Development Environment”
• “packNGo Function Limitations”
4-43
5
On the Configuration Parameters dialog box, the following configuration parameters are
on the Commonly Used tab on the Code Generation > Report pane, or on the All
Parameters tab in the Code Generation > Report category.
Parameter Description
“Create code generation report” on page Document generated code in an HTML
5-4 report.
“Open report automatically” on page Specify whether to display code generation
5-7 reports automatically.
“Generate model Web view” on page Include the model Web view in the code
5-9 generation report to navigate between the
code and model within the same window.
“Static code metrics” on page 5-11 Include static code metrics report in the
code generation report.
See Also
“Code-to-model” on page 10-14 | “Model-to-code” on page 10-16 | “Eliminated /
virtual blocks” on page 10-19 | “Traceable Stateflow objects” on page 10-23 |
“Traceable MATLAB functions” on page 10-25
More About
• “Report Generation”
• “Model Configuration”
5-2
Code Generation: Report Tab Overview
Configuration
To create a code generation report during the build process, select the Create code
generation report parameter.
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “Generate a Code Generation Report”
• “Reports for Code Generation”
• “HTML Code Generation Report Extensions” (Embedded Coder)
5-3
5 Code Generation Parameters: Report
Description
Document generated code in an HTML report.
Settings
Default: On
On
Generates a summary of code generation source files in an HTML report. Places the
report files in an html subfolder within the build folder. In the report,
• The Summary section lists version and date information. The Configuration
Settings at the Time of Code Generation link opens a noneditable view of
the Configuration Parameters dialog that shows the Simulink model settings,
including TLC options, at the time of code generation.
• The Subsystem Report section contains information on nonvirtual subsystems
in the model.
• The Code Interface Report section provides information about the generated
code interface, including model entry point functions and input/output data
(requires an Embedded Coder license and the ERT target).
• The Traceability Report section allows you to account for Eliminated / Virtual
Blocks that are untraceable, versus the listed Traceable Simulink Blocks /
Stateflow Objects / MATLAB Scripts, providing a complete mapping between
model elements and code (requires an Embedded Coder license and the ERT
system target file).
• The Static Code Metrics Report section provides statistics of the generated
code. Metrics are estimated from static analysis of the generated code.
• The Code Replacements Report section allows you to account for code
replacement library (CRL) functions that were used during code generation,
providing a mapping between each replacement instance and the Simulink block
that triggered the replacement.
5-4
Create code generation report
In the Generated Files section, you can click the names of source code files
generated from your model to view their contents in a MATLAB Web browser
window. In the displayed source code,
Off
Does not generate a summary of files.
Dependency
This parameter enables and selects
5-5
5 Code Generation Parameters: Report
Command-Line Information
Parameter: GenerateReport
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “Reports for Code Generation”
• “HTML Code Generation Report Extensions” (Embedded Coder)
• “Configure Code Coverage with Third-Party Tools” (Embedded Coder)
5-6
Open report automatically
Description
Specify whether to display code generation reports automatically.
Settings
Default: On
On
Displays the code generation report automatically in a new browser window.
Off
Does not display the code generation report, but the report is still available in the
html folder.
Dependency
This parameter is enabled and selected by Create code generation report.
Command-Line Information
Parameter: LaunchReport
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No impact
5-7
5 Code Generation Parameters: Report
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “Reports for Code Generation”
• “HTML Code Generation Report Extensions” (Embedded Coder)
5-8
Generate model Web view
Description
Include the model Web view in the code generation report to navigate between the code
and model within the same window. You can share your model and generated code
outside of the MATLAB environment. You must have a Simulink Report Generator™
license to include a Web view (Simulink Report Generator) of the model in the code
generation report.
Settings
Default: Off
On
Include model Web view in the code generation report.
Off
Omit model Web view in the code generation report.
Dependencies
Dependencies
Command-Line Information
Parameter: GenerateWebview
Type: string
Value: 'on' | 'off'
5-9
5 Code Generation Parameters: Report
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
“Model Configuration Parameters: Code Generation Report” on page 5-2
Related Examples
• “Web View of Model in Code Generation Report” (Embedded Coder)
5-10
Static code metrics
Description
Include static code metrics report in the code generation report.
Settings
Default: Off
On
Include static code metrics report in the code generation report.
Off
Omit static code metrics report from the code generation report.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled when you select Create code generation report.
Command-Line Information
Parameter: GenerateCodeMetricsReport
Type: Boolean
Value: on | off
Default: off
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
5-11
5 Code Generation Parameters: Report
Application Setting
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “Static Code Metrics” (Embedded Coder)
5-12
6
On the Configuration Parameters dialog box, the following configuration parameters are
on the Commonly Used tab, on the Code Generation > Comments pane or on the All
Parameters tab in the Code Generation > Comments category.
Parameter Description
“Include comments” on page 6-5 Specify which comments are in generated
files.
“Simulink block / Stateflow object Specify whether to insert Simulink block
comments” on page 6-7 and Stateflow object comments.
“MATLAB source code as comments” on Specify whether to insert MATLAB source
page 6-9 code as comments.
“Show eliminated blocks” on page 6-11 Specify whether to insert eliminated block's
comments.
“Verbose comments for SimulinkGlobal Reduce code size or improve code
storage class” on page 6-13 traceability by controlling the generation of
comments.
“Operator annotations” on page 6-15 Specify whether to include operator
annotations for Polyspace in the generated
code as comments.
“Simulink block descriptions” on page Specify whether to insert descriptions of
6-17 blocks into generated code as comments.
“Simulink data object descriptions” on page Specify whether to insert descriptions of
6-19 Simulink data objects into generated code
as comments.
“Custom comments (MPT objects only)” on Specify whether to include custom
page 6-21 comments for module packaging tool (MPT)
signal and parameter data objects in
generated code.
6-2
Model Configuration Parameters: Code Generation Comments
Parameter Description
“Custom comments function” on page Specify a file that contains comments to
6-23 be included in generated code for module
packing tool (MPT) signal and parameter
data objects.
“Stateflow object descriptions” on page Specify whether to insert descriptions of
6-25 Stateflow objects into generated code as
comments.
“Requirements in block comments” on page Specify whether to include requirement
6-27 descriptions assigned to Simulink blocks in
generated code as comments.
“MATLAB function help text” on page Specify whether to include
6-29 MATLAB function help text in the function
banner.
More About
• “Code Appearance”
• “Model Configuration”
6-3
6 Code Generation Parameters: Comments
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
6-4
Include comments
Include comments
Description
Specify which comments are in generated files.
Settings
Default: On
On
Places comments in the generated files based on the selections in the Auto
generated comments pane.
Off
Omits comments from the generated files.
Note: This parameter does not apply to copyright notice comments in the generated
code.
Dependencies
This parameter enables:
Command-Line Information
Parameter: GenerateComments
Type: character vector
Value: 'on' | 'off'
6-5
6 Code Generation Parameters: Comments
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
6-6
Simulink block / Stateflow object comments
Description
Specify whether to insert Simulink block and Stateflow object comments.
Settings
Default: On
On
Inserts automatically generated comments that describe a block's code and objects.
The comments precede that code in the generated file.
Off
Suppresses comments.
Dependency
This parameter is enabled by Include comments.
Command-Line Information
Parameter: SimulinkBlockComments
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
6-7
6 Code Generation Parameters: Comments
Application Setting
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
6-8
MATLAB source code as comments
Description
Specify whether to insert MATLAB source code as comments.
Settings
Default: On
On
Inserts MATLAB source code as comments in the generated code. The comments
precede the associated generated code.
Off
Suppresses comments and does not include the function signature in the function
banner.
Dependency
This parameter is enabled by Include comments.
Command-Line Information
Parameter: MATLABSourceComments
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
6-9
6 Code Generation Parameters: Comments
Application Setting
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
• “Include MATLAB Code as Comments in Generated Code” (Simulink)
6-10
Show eliminated blocks
Settings
Default: On
On
Inserts statements in the generated code from blocks eliminated as the result of
optimizations (such as parameter inlining).
Off
Suppresses statements.
Dependency
This parameter is enabled by Include comments.
Command-Line Information
Parameter: ShowEliminatedStatement
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
6-11
6 Code Generation Parameters: Comments
Application Setting
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
6-12
Verbose comments for SimulinkGlobal storage class
Parameter objects and MATLAB variables appear in the model parameter structure
under either of these conditions:
For more information about parameter representation in the generated code, see “Block
Parameter Representation in the Generated Code”.
Settings
Default: On
On
Generate comments regardless of the number of parameter values stored in the
parameter structure. Use this setting to improve traceability between the generated
code and the parameter objects or variables that the model uses.
Off
Generate comments only if the parameter structure contains fewer than 1000
parameter values. An array parameter with n elements represents n values. For
large models, use this setting to reduce the size of the generated file.
Dependency
Include comments enables this parameter.
6-13
6 Code Generation Parameters: Comments
Command-Line Information
Parameter: ForceParamTrailComments
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
• “Block Parameter Representation in the Generated Code”
6-14
Operator annotations
Operator annotations
Description
Specify whether to include operator annotations for Polyspace in the generated code as
comments.
Settings
Default: On
On
Includes operator annotations in the generated code.
Off
Does not include operator annotations in the generated code.
Tips
• These annotations help document overflow behavior that is due to the way the code
generator implements an operation. These operators cannot be traced to an overflow
in the design.
• Justify operators that the Polyspace software cannot prove. When this option is
enabled, if the code generator uses one of these operators, it adds annotations to the
generated code to justify the operators for Polyspace.
• The code generator cannot justify operators that result from the design.
Dependency
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by Include comments.
Command-Line Information
Parameter: OperatorAnnotations
6-15
6 Code Generation Parameters: Comments
Recommended Settings
Application Setting
Debugging No impact
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
• “Annotate Code for Justifying Polyspace Checks” (Embedded Coder)
6-16
Simulink block descriptions
Description
Specify whether to insert descriptions of blocks into generated code as comments.
Settings
Default: On
On
Includes the following comments in the generated code for each block in the model,
with the exception of virtual blocks and blocks removed due to block reduction:
• The block name at the start of the code, regardless of whether you select
Simulink block / Stateflow object comments
• Text specified in the Description field of each Block Properties dialog box
For information on code generator treatment of strings that are unrepresented in the
character set encoding for the model, see “Internationalization and Code Generation”.
Off
Suppresses the generation of block name and description comments in the generated
code.
Dependency
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: InsertBlockDesc
Type: character vector
Value: 'on' | 'off'
Default: 'on'
6-17
6 Code Generation Parameters: Comments
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
• “Internationalization and Code Generation”
6-18
Simulink data object descriptions
Description
Specify whether to insert descriptions of Simulink data objects into generated code as
comments.
Settings
Default: On
On
Inserts contents of the Description field in the Model Explorer Object Properties
pane for each Simulink data object (signal, parameter, and bus objects) in the
generated code as comments.
For information on code generator treatment of strings that are unrepresented in the
character set encoding for the model, see “Internationalization and Code Generation”.
Off
Suppresses the generation of data object property descriptions as comments in the
generated code.
Dependency
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: SimulinkDataObjDesc
Type: character vector
6-19
6 Code Generation Parameters: Comments
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
6-20
Custom comments (MPT objects only)
Description
Specify whether to include custom comments for module packaging tool (MPT) signal
and parameter data objects in generated code. MPT data objects are objects of the classes
mpt.Parameter and mpt.Signal.
Settings
Default: Off
On
Inserts comments just above the identifiers for signal and parameter MPT objects in
generated code.
Off
Suppresses the generation of custom comments for signal and parameter identifiers.
Dependency
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter requires that you include the comments in a function defined in
a MATLAB language file or TLC file that you specify with Custom comments
function.
Command-Line Information
Parameter: EnableCustomComments
Type: character vector
Value: 'on' | 'off'
Default: 'off'
6-21
6 Code Generation Parameters: Comments
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
• “Add Custom Comments for Variables in the Generated Code” (Embedded Coder)
6-22
Custom comments function
Description
Specify a file that contains comments to be included in generated code for module
packing tool (MPT) signal and parameter data objects. MPT data objects are objects of
the classes mpt.Parameter and mpt.Signal.
Settings
Default: ''
Enter the name of the MATLAB language file or TLC file for the function that includes
the comments to be inserted of your MPT signal and parameter objects. You can specify
the file name directly or click Browse and search for a file.
Tip
You might use this option to insert comments that document some or all of the property
values of an object.
Dependency
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by Custom comments (MPT objects only).
Command-Line Information
Parameter: CustomCommentsFcn
Type: character vector
Value: valid file name
Default: ''
6-23
6 Code Generation Parameters: Comments
Recommended Settings
Application Setting
Debugging Valid file name
Traceability Valid file name
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
• “Add Custom Comments for Variables in the Generated Code” (Embedded Coder)
6-24
Stateflow object descriptions
Description
Specify whether to insert descriptions of Stateflow objects into generated code as
comments.
Settings
Default: On
On
Inserts descriptions of Stateflow states, charts, transitions, and graphical functions
into generated code as comments. The descriptions come from the Description field
in Object Properties pane in the Model Explorer for these Stateflow objects. The
comments appear just above the code generated for each object.
For information on code generator treatment of strings that are unrepresented in the
character set encoding for the model, see “Internationalization and Code Generation”.
Off
Suppresses the generation of comments for Stateflow objects.
Dependency
• This parameter only appears for ERT-based targets.
• This parameter requires a Stateflow license.
Command-Line Information
Parameter: SFDataObjDesc
Type: character vector
Value: 'on' | 'off'
Default: 'on'
6-25
6 Code Generation Parameters: Comments
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
• “Internationalization and Code Generation”
6-26
Requirements in block comments
Description
Specify whether to include requirement descriptions assigned to Simulink blocks in
generated code as comments.
Settings
Default: Off
On
Inserts the requirement descriptions that you assign to Simulink blocks into
the generated code as comments. The code generator includes the requirement
descriptions in the generated code in the following locations.
For information on code generator treatment of strings that are unrepresented in the
character set encoding for the model, see “Internationalization and Code Generation”.
Off
Suppresses the generation of comments for block requirement descriptions.
Dependency
• This parameter only appears for ERT-based targets.
6-27
6 Code Generation Parameters: Comments
• This parameter requires Embedded Coder and Simulink Verification and Validation™
licenses when generating code.
Tips
If you use an external .req file to store your requirement links, to avoid stale comments
in generated code, before code generation, you must save any change in your requirement
links.
Command-Line Information
Parameter: ReqsInCode
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
• “How Requirements Information Is Included in Generated Code” (Simulink
Verification and Validation)
6-28
MATLAB function help text
Description
Specify whether to include MATLAB function help text in the function banner.
Settings
Default: On
On
Inserts MATLAB function help text in the function banner.
Off
Inserts MATLAB function help text in the body of the function.
Dependency
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by Include comments.
Command-Line Information
Parameter: MATLABFcnDesc
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
6-29
6 Code Generation Parameters: Comments
Application Setting
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Comments” on page 6-2
• “Including MATLAB Function Help Text in the Function Banner” (Simulink)
6-30
7
On the Configuration Parameters dialog box, the following configuration parameters are
on the Commonly Used tab on the Code Generation > Symbols pane, or on the All
Parameters tab in the Code Generation > Symbols category.
Parameter Description
“Global variables” on page 7-5 Customize generated global variable
identifiers.
“Global types” on page 7-8 Customize generated global type
identifiers.
“Field name of global types” on page Customize generated field names of global
7-11 types.
“Subsystem methods” on page 7-13 Customize generated function names for
reusable subsystems.
“Subsystem method arguments” on page Customize generated function argument
7-16 names for reusable subsystems.
“Local temporary variables” on page Customize generated local temporary
7-18 variable identifiers.
“Local block output variables” on page Customize generated local block output
7-21 variable identifiers.
“Constant macros” on page 7-23 Customize generated constant macro
identifiers.
“Shared utilities” on page 7-26 Customize shared utility identifiers.
“Minimum mangle length” on page 7-29 Specify the minimum number of characters
for generating name-mangling text to help
avoid name collisions.
“Maximum identifier length” on page Specify maximum number of characters
7-31 in generated function, type definition,
variable names.
7-2
Model Configuration Parameters: Code Generation Symbols
Parameter Description
“System-generated identifiers” on page Specify whether the code generator
7-33 uses shorter, more consistent names
for the $N token in system-generated
identifiers.
“Generate scalar inlined parameters as” on Control expression of scalar inlined
page 7-38 parameter values in the generated code.
“Signal naming” on page 7-41 Specify rules for naming signals in
generated code.
“M-function” on page 7-43
“Parameter naming” on page 7-45 Specify rule for naming parameters in
generated code.
“M-function” on page 7-47
“#define naming” on page 7-49 Specify rule for naming #define
parameters (defined with storage class
Define (Custom)) in generated code.
“M-function” on page 7-51
“Use the same reserved names as Specify whether to use the same
Simulation Target” on page 7-53 reserved names as those specified in the
Simulation Target pane.
“Reserved names” on page 7-55 Enter the names of variables or functions
in the generated code that match the
names of variables or functions specified in
custom code.
More About
• “Code Appearance”
• “Model Configuration”
7-3
7 Code Generation Parameters: Symbols
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Construction of Generated Identifiers”
• “Identifier Name Collisions and Mangling”
• “Specify Identifier Length to Avoid Naming Collisions”
• “Specify Reserved Names for Generated Identifiers”
• “Customize Generated Identifier Naming Rules” (Embedded Coder)
7-4
Global variables
Global variables
Description
Customize generated global variable identifiers.
Settings
Default: $R$N$M
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$M Insert name-mangling text if required to avoid naming collisions.
Required.
$N Insert name of object (block, signal or signal object, state, parameter or
parameter object) for which identifier is being generated.
$R Insert root model name into identifier, replacing unsupported
characters with the underscore (_) character.
Tips
• Avoid name collisions in general. One way is to avoid using default block names (for
example, Gain1, Gain2...) when your model has many blocks of the same type.
• Where possible, increase the Maximum identifier length to accommodate the
length of the identifiers you expect to generate. Reserve at least three characters for
name-mangling text.
7-5
7 Code Generation Parameters: Symbols
• To control the case (upper or lower case) of the text that each token represents,
include decorators such as [U_] in your macro. See “Control Case with Token
Decorators” (Embedded Coder).
• If you specify $R, the value you specify for Maximum identifier length must be
large enough to accommodate full expansions of the $R and $M tokens.
• When a name conflict occurs between an identifier within the scope of a higher-level
model and an identifier within the scope of a referenced model, the code generator
preserves the identifier from the referenced model. Name mangling is performed on
the identifier in the higher-level model.
• This parameter setting only determines the name of objects, such as signals and
parameters, if the object is set to Auto.
• For referenced models, if the Global variables parameter does not contain a $R
token (which represents the name of the reference model), code generation prepends
the $R token to the identifier format.
You can use the Model Advisor to identify models in a model referencing hierarchy for
which code generation changes configuration parameter settings.
Dependency
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: CustomSymbolStrGlobalVar
Type: character vector
Value: valid combination of tokens
Default: $R$N$M
7-6
Global variables
Recommended Settings
Application Setting
Debugging No impact
Traceability Use default
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Identifier Format Control” (Embedded Coder)
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Avoid Identifier Name Collisions with Referenced Models” (Embedded Coder)
• “Identifier Format Control Parameters Limitations” (Embedded Coder)
7-7
7 Code Generation Parameters: Symbols
Global types
Description
Customize generated global type identifiers.
Settings
Default: $N$R$M_T
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$M Insert name-mangling text if required to avoid naming collisions.
Required.
$N Insert name of object (block, signal or signal object, state, parameter or
parameter object) for which identifier is being generated.
$R Insert root model name into identifier, replacing unsupported
characters with the underscore (_) character.
Tips
• Avoid name collisions in general. One way is to avoid using default block names (for
example, Gain1, Gain2...) when your model has many blocks of the same type.
• Where possible, increase the Maximum identifier length to accommodate the
length of the identifiers you expect to generate. Reserve at least three characters for
name-mangling text.
7-8
Global types
• To control the case (upper or lower case) of the text that each token represents,
include decorators such as [U_] in your macro. See “Control Case with Token
Decorators” (Embedded Coder).
• If you specify $R, the value you specify for Maximum identifier length must be
large enough to accommodate full expansions of the $R and $M tokens.
• When a name conflict occurs between an identifier within the scope of a higher-level
model and an identifier within the scope of a referenced model, the code generator
preserves the identifier from the referenced model. Name mangling is performed on
the identifier in the higher-level model.
• Name mangling conventions do not apply to type names (that is, typedef
statements) generated for global data types. The Maximum identifier length
setting does not apply to type definitions. If you specify $R, the code generator
includes the model name in the typedef.
• This option does not impact objects (such as signals and parameters) that have a
storage class other than Auto (such as ImportedExtern or ExportedGlobal).
• For referenced models, if the Global types parameter does not contain a $R token
(which represents the name of the reference model), code generation prepends the $R
token to the identifier format.
You can use the Model Advisor to identify models in a model referencing hierarchy for
which code generation changes configuration parameter settings.
Dependency
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: CustomSymbolStrType
Type: character vector
Value: valid combination of tokens
Default: $N$R$M_T
7-9
7 Code Generation Parameters: Symbols
Recommended Settings
Application Setting
Debugging No impact
Traceability Use default
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Identifier Format Control” (Embedded Coder)
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Avoid Identifier Name Collisions with Referenced Models” (Embedded Coder)
• “Identifier Format Control Parameters Limitations” (Embedded Coder)
7-10
Field name of global types
Description
Customize generated field names of global types.
Settings
Default: $N$M
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$A Insert data type acronym into signal and work vector identifiers. For
example, i32 for int32_t.
$H Insert tag indicating system hierarchy level. For root-level blocks, the
tag is the text root_. For blocks at the subsystem level, the tag is of the
form sN_, where N is a unique system number assigned by the Simulink
software.
$M Insert name-mangling text if required to avoid naming collisions.
Required.
$N Insert name of object (block, signal or signal object, state, parameter or
parameter object) for which identifier is being generated.
$U Insert text that you specify for the $U token. Use the Custom token
text parameter to specify this text. This parameter is on the All
Parameters tab of the Configuration Parameters dialog box.
Tips
• Avoid name collisions in general. One way is to avoid using default block names (for
example, Gain1, Gain2...) when your model has many blocks of the same type.
7-11
7 Code Generation Parameters: Symbols
Dependency
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: CustomSymbolStrField
Type: character vector
Value: valid combination of tokens
Default: $N$M
Recommended Settings
Application Setting
Debugging No impact
Traceability Use default
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Identifier Format Control” (Embedded Coder)
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Identifier Format Control Parameters Limitations” (Embedded Coder)
7-12
Subsystem methods
Subsystem methods
Description
Customize generated function names for reusable subsystems.
Settings
Default: $R$N$M$F
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$F Insert method name (for example, _Update for update method).
$H Insert tag indicating system hierarchy level. For root-level blocks, the
tag is the text root_. For blocks at the subsystem level, the tag is of the
form sN_, where N is a unique system number assigned by the Simulink
software.
Required.
$N Insert name of object (block, signal or signal object, state, parameter or
parameter object) for which identifier is being generated.
$R Insert root model name into identifier, replacing unsupported
characters with the underscore (_) character.
7-13
7 Code Generation Parameters: Symbols
Tips
• Avoid name collisions in general. One way is to avoid using default block names (for
example, Gain1, Gain2...) when your model has many blocks of the same type.
• Where possible, increase the Maximum identifier length to accommodate the
length of the identifiers you expect to generate. Reserve at least three characters for
name-mangling text.
• To control the case (upper or lower case) of the text that each token represents,
include decorators such as [U_] in your macro. See “Control Case with Token
Decorators” (Embedded Coder).
• If you specify $R, the value you specify for Maximum identifier length must be
large enough to accommodate full expansions of the $R and $M tokens.
• When a name conflict occurs between an identifier within the scope of a higher-level
model and an identifier within the scope of a referenced model, the code generator
preserves the identifier from the referenced model. Name mangling is performed on
the identifier in the higher-level model.
• Name mangling conventions do not apply to type names (that is, typedef
statements) generated for global data types. The Maximum identifier length
setting does not apply to type definitions. If you specify $R, the code generator
includes the model name in the typedef.
• This option does not impact objects (such as signals and parameters) that have a
storage class other than Auto (such as ImportedExtern or ExportedGlobal).
• For referenced models, if the Subsystem methods parameter does not contain a $R
token (which represents the name of the reference model), code generation prepends
the $R token to the identifier format.
You can use the Model Advisor to identify models in a model referencing hierarchy for
which code generation changes configuration parameter settings.
Dependency
• This parameter appears only for ERT-based targets.
7-14
Subsystem methods
Command-Line Information
Parameter: CustomSymbolStrFcn
Type: character vector
Value: valid combination of tokens
Default: $R$N$M$F
Recommended Settings
Application Setting
Debugging No impact
Traceability Use default
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Identifier Format Control” (Embedded Coder)
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Avoid Identifier Name Collisions with Referenced Models” (Embedded Coder)
• “Identifier Format Control Parameters Limitations” (Embedded Coder)
7-15
7 Code Generation Parameters: Symbols
Description
Customize generated function argument names for reusable subsystems.
Settings
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated argument name. The macro can include a combination of the following
format tokens.
Token Description
$I • Insert u if the argument is an input.
• Insert y if the argument is an output.
• Insert uy if the argument is an input and output.
Optional.
$M Insert name-mangling text if required to avoid naming collisions.
Required.
$N Insert name of object (block, signal or signal object, state, parameter or
parameter object) for which identifier is being generated.
Tips
• Avoid name collisions in general. One way is to avoid using default block names (for
example, Gain1, Gain2...) when your model has many blocks of the same type.
7-16
Subsystem method arguments
Dependencies
This parameter:
Command-Line Information
Parameter: CustomSymbolStrFcnArg
Type: character vector
Value: valid combination of tokens
Default: rt$I$N$M
Recommended Settings
Application Setting
Debugging No impact
Traceability Use default
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Identifier Format Control” (Embedded Coder)
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Identifier Format Control Parameters Limitations” (Embedded Coder)
7-17
7 Code Generation Parameters: Symbols
Description
Customize generated local temporary variable identifiers.
Settings
Default: $N$M
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$A Insert data type acronym (for example, i32 for integers) into signal and
work vector identifiers.
$M Insert name-mangling text if required to avoid naming collisions.
Required.
$N Insert name of object (block, signal or signal object, state, parameter, or
parameter object) for which identifier is generated.
$R Insert root model name into identifier, replacing unsupported
characters with the underscore (_) character.
Tips
• Avoid name collisions. One way is to avoid using default block names (for example,
Gain1, Gain2...) when your model has many blocks of the same type.
7-18
Local temporary variables
Dependency
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: CustomSymbolStrTmpVar
Type: character vector
Value: valid combination of tokens
Default: $N$M
Recommended Settings
Application Setting
Debugging No impact
Traceability Use default
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
7-19
7 Code Generation Parameters: Symbols
7-20
Local block output variables
Description
Customize generated local block output variable identifiers.
Settings
Default: rtb_$N$M
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$A Insert data type acronym (for example, i32 for integers) into signal and
work vector identifiers.
$M Insert name-mangling text if required to avoid naming collisions.
Required.
$N Insert name of object (block, signal or signal object, state, parameter or
parameter object) for which identifier is being generated.
$U Insert text that you specify for the $U token. Use the Custom token
text parameter to specify this text. This parameter is on the All
Parameters tab of the Configuration Parameters dialog box.
Tips
• Avoid name collisions in general. One way is to avoid using default block names (for
example, Gain1, Gain2...) when your model has many blocks of the same type.
• Where possible, increase the Maximum identifier length to accommodate the
length of the identifiers you expect to generate. Reserve at least three characters for
name-mangling text.
7-21
7 Code Generation Parameters: Symbols
• To control the case (upper or lower case) of the text that each token represents,
include decorators such as [U_] in your macro. See “Control Case with Token
Decorators” (Embedded Coder).
• This option does not impact objects (such as signals and parameters) that have a
storage class other than Auto (such as ImportedExtern or ExportedGlobal).
Dependency
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: CustomSymbolStrBlkIO
Type: character vector
Value: valid combination of tokens
Default: rtb_$N$M
Recommended Settings
Application Setting
Debugging No impact
Traceability Use default
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Identifier Format Control” (Embedded Coder)
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Identifier Format Control Parameters Limitations” (Embedded Coder)
7-22
Constant macros
Constant macros
Description
Customize generated constant macro identifiers.
Settings
Default: $R$N$M
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$M Insert name-mangling text if required to avoid naming collisions.
Required.
$N Insert name of object (block, signal or signal object, state, parameter or
parameter object) for which identifier is being generated.
$R Insert root model name into identifier, replacing unsupported
characters with the underscore (_) character.
Tips
• Avoid name collisions in general. One way is to avoid using default block names (for
example, Gain1, Gain2...) when your model has many blocks of the same type.
• Where possible, increase the Maximum identifier length to accommodate the
length of the identifiers you expect to generate. Reserve at least three characters for
name-mangling text.
7-23
7 Code Generation Parameters: Symbols
• To control the case (upper or lower case) of the text that each token represents,
include decorators such as [U_] in your macro. See “Control Case with Token
Decorators” (Embedded Coder).
• If you specify $R, the value you specify for Maximum identifier length must be
large enough to accommodate full expansions of the $R and $M tokens.
• When a name conflict occurs between an identifier within the scope of a higher-level
model and an identifier within the scope of a referenced model, the code generator
preserves the identifier from the referenced model. Name mangling is performed on
the identifier in the higher-level model.
• This option does not impact objects (such as signals and parameters) that have a
storage class other than Auto (such as ImportedExtern or ExportedGlobal).
• For referenced models, if the Constant macros parameter does not contain a $R
token (which represents the name of the reference model), code generation prepends
the $R token to the identifier format.
You can use the Model Advisor to identify models in a model referencing hierarchy for
which code generation changes configuration parameter settings.
Dependency
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: CustomSymbolStrMacro
Type: character vector
Value: valid combination of tokens
Default: $R$N$M
7-24
Constant macros
Recommended Settings
Application Setting
Debugging No impact
Traceability Use default
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Identifier Format Control” (Embedded Coder)
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Avoid Identifier Name Collisions with Referenced Models” (Embedded Coder)
• “Identifier Format Control Parameters Limitations” (Embedded Coder)
7-25
7 Code Generation Parameters: Symbols
Shared utilities
Description
Customize shared utility identifiers.
Settings
Default: $N$C
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$N Insert name of object (block, signal or signal object, state, parameter, or
parameter object) for which identifier is generated. Optional.
$C Insert eight-character conditional checksum when $N is not specified or
the Maximum identifier length does not accommodate the full length
of $N. Required.
$R Insert root model name into identifier, replacing unsupported
characters with the underscore (_) character.
$U Insert text that you specify for the $U token. Use the Custom token
text parameter to specify this text. This parameter is on the All
Parameters tab of the Configuration Parameters dialog box.
Tips
• Where possible, increase the Maximum identifier length to accommodate the
length of the identifiers that you expect to generate.
• The checksum token $C is required. If $C is specified without $N or $R, the checksum
is included in the identifier name. Otherwise, the code generator includes the
checksum when necessary to prevent name collisions.
7-26
Shared utilities
• To control the case (upper or lower case) of the text that each token represents,
include decorators such as [U_] in your macro. See “Control Case with Token
Decorators” (Embedded Coder).
• If you specify $N or $R, then the checksum is only included in the name when the
identifier length is too short to accommodate the fully expanded format text. The code
generator includes the checksum and truncates $N or $R until the length is equal to
Maximum identifier length. When necessary, an underscore is inserted to separate
tokens.
• If you specify $N and $R, then the checksum is only included in the name when the
identifier length is too short to accommodate the fully expanded format text. The
code generator includes the checksum and truncates $N until the length is equal to
Maximum identifier length. When necessary, an underscore is inserted to separate
tokens.
• Descriptive text helps make the identifier name more accessible.
• For versions prior to R2016a, the Shared utilities parameter does not support the
$R token. For a model, if the Shared utilities parameter includes a $R token, and
you export the model to a version prior to R2016a, the Shared utilities parameter
defaults to $N$C.
Dependency
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: CustomSymbolStrUtil
Type: character vector
Value: valid combination of tokens
Default: $N$C
Recommended Settings
Application Setting
Debugging No impact
Traceability Use default
Efficiency No impact
7-27
7 Code Generation Parameters: Symbols
Application Setting
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Identifier Format Control” (Embedded Coder)
• “Exceptions to Identifier Formatting Conventions” (Embedded Coder)
7-28
Minimum mangle length
Description
Increase the minimum number of characters for generating name-mangling text to help
avoid name collisions.
Settings
Default: 1
Specify an integer value that indicates the minimum number of characters the code
generator uses when generating name-mangling text. The maximum possible value is 15.
The minimum value automatically increases during code generation as a function of the
number of collisions. A larger value reduces the chance of identifier disturbance when
you modify the model.
Tips
• Minimize disturbance to the generated code during development by specifying a value
of 4. This value is conservative. It allows for over 1.5 million collisions for a particular
identifier before the mangle length increases.
• Set the value to reserve at least three characters for the name-mangling text.
The length of the name-mangling text increases as the number of name collisions
increases.
Dependency
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: MangleLength
Type: integer
Value: value between 1 and 15
7-29
7 Code Generation Parameters: Symbols
Default: 1
Recommended Settings
Application Setting
Debugging No impact
Traceability 1
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Maintain Traceability for Generated Identifiers” (Embedded Coder)
7-30
Maximum identifier length
Description
Specify maximum number of characters in generated function, type definition, variable
names.
Settings
Default: 31
Minimum: 31
Maximum: 256
You can use this parameter to limit the number of characters in function, type definition,
and variable names.
Tips
• Consider increasing identifier length for models having a deep hierarchical structure.
• When generating code from a model that uses model referencing, the Maximum
identifier length must be large enough to accommodate the root model name,
and possibly, the name-mangling text. A code generation error occurs if Maximum
identifier length is too small.
• This parameter must be the same for both top-level and referenced models.
• When a name conflict occurs between a symbol within the scope of a higher level
model and a symbol within the scope of a referenced model, the symbol from the
referenced model is preserved. Name mangling is performed on the symbol from the
higher level model.
Command-Line Information
Parameter: MaxIdLength
Type: integer
Value: valid value
Default: 31
7-31
7 Code Generation Parameters: Symbols
Recommended Settings
Application Setting
Debugging Valid value
Traceability >30
Efficiency No impact
Safety precaution >30
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Construction of Generated Identifiers”
• “Identifier Name Collisions and Mangling”
• “Identifier Format Control” (Embedded Coder)
7-32
System-generated identifiers
System-generated identifiers
Description
Specify whether the code generator uses shorter, more consistent names for the $N token
in system-generated identifiers.
Settings
Default: Shortened
Classic
Generate longer identifier names, which are used by default before R2013a, for the
$N token. For example, for a model named sym, if:
• “Global variables” on page 7-5 is $N$R$M, the block state identifier is sym_DWork.
• “Global types” on page 7-8 is $R$N$M, the block state type is a structure named
D_Work_sym.
Shortened
Shorten identifier names for the $N token to allow more space for user names. This
option provides a more predictable and consistent naming system that uses camel
case, no underscores or plurals, and consistent abbreviations for both a type and a
variable. For example, for a model named sym, if:
• “Global variables” on page 7-5 is $N$R$M, the block state identifier is sym_DW.
• “Global types” on page 7-8 is $R$N$M, the block state type is a structure named
DW_sym.
7-33
7 Code Generation Parameters: Symbols
7-34
System-generated identifiers
7-35
7 Code Generation Parameters: Symbols
Dependencies
• This parameter appears only for ERT-based targets.
• When generating code, this parameter requires an Embedded Coder license.
Command-Line Information
Parameter: InternalIdentifier
Type: character vector
Value: Classic | Shortened
Default: Shortened
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
7-36
System-generated identifiers
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Construction of Generated Identifiers”
• “Identifier Name Collisions and Mangling”
• “Specify Identifier Length to Avoid Naming Collisions”
• “Specify Reserved Names for Generated Identifiers”
• “Default Data Structures in the Generated Code”
• “Customize Generated Identifier Naming Rules” (Embedded Coder)
• “Identifier Format Control” (Embedded Coder)
7-37
7 Code Generation Parameters: Symbols
Settings
Default: Literals
Literals
Generates scalar inlined parameters as numeric constants.
Macros
Generates scalar inlined parameters as variables with #define macros. This setting
makes generated code more readable.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: InlinedPrmAccess
Type: character vector
Value: Literals | Macros
Default: Literals
Recommended Settings
Application Setting
Debugging No impact
7-38
Generate scalar inlined parameters as
Application Setting
Traceability Macros
Efficiency No impact
Safety precaution No impact
sldemo_fuelsys_dd_controller
7-39
7 Code Generation Parameters: Symbols
set_param('sldemo_fuelsys_dd_controller','InlinedPrmAccess','Macros')
The comments above the macro definitions indicate that the code generated for a Discrete
Filter block uses the macros.
rtwdemodbtype(file,'Computed Parameter: DiscreteFilter_NumCoef',...
'Referenced by: ''<S12>/Discrete Filter''',1,1)
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
7-40
Signal naming
Signal naming
Description
Specify rules for naming signals in generated code.
Settings
Default: None
None
Does not change signal names when creating corresponding identifiers in generated
code. Signal identifiers in the generated code match the signal names that appear in
the model.
Force upper case
Uses uppercase characters when creating identifiers for signal names in the
generated code.
Force lower case
Uses lowercase characters when creating identifiers for signal names in the
generated code.
Custom M-function
Uses the MATLAB function specified with the M-function parameter to create
identifiers for signal names in the generated code.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• Setting this parameter to Custom M-function enables M-function.
• This parameter must be the same for top-level and referenced models.
• If you give a value to the Alias parameter of a Simulink.Signal data object, that
value overrides the specification of the Signal naming parameter.
7-41
7 Code Generation Parameters: Symbols
Limitation
This parameter does not impact signal names that are specified by an embedded signal
object created using the Code Generation tab of a Signal Properties dialog box.
See “Programmatically Apply Custom Storage Classes Directly to Signals, States, and
Outport Blocks Using Embedded Signal Objects” (Embedded Coder) for information
about embedded signal objects.
Command-Line Information
Parameter: SignalNamingRule
Type: character vector
Value: None | UpperCase | LowerCase | Custom
Default: None
Recommended Settings
Application Setting
Debugging No impact
Traceability Force upper case
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Apply Naming Rules to Simulink Data Objects” (Embedded Coder)
• “Programming Scripts and Functions” (MATLAB)
7-42
M-function
M-function
Description
Specify rule for naming identifiers in generated code.
Settings
Default: ''
Enter the name of a MATLAB language file that contains the naming rule to be applied
to signal, parameter, or #define parameter identifiers in generated code. Examples of
rules you might program in such a MATLAB function include:
For example, the following function returns an identifier name by appending the text
_signal to a signal data object name.
revisedName = [name,text];
7-43
7 Code Generation Parameters: Symbols
Tip
The MATLAB language file must be in the MATLAB path.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by Signal naming.
• This parameter must be the same for top-level and referenced models.
Command-Line Information
Parameter: SignalNamingFcn
Type: character vector
Value: MATLAB language file
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Specify Naming Rule Using a Function” (Embedded Coder)
• “Programming Scripts and Functions” (MATLAB)
7-44
Parameter naming
Parameter naming
Description
Specify rule for naming parameters in generated code.
Settings
Default: None
None
Does not change parameter names when creating corresponding identifiers in
generated code. Parameter identifiers in the generated code match the parameter
names that appear in the model.
Force upper case
Uses uppercase characters when creating identifiers for parameter names in the
generated code.
Force lower case
Uses lowercase characters when creating identifiers for parameter names in the
generated code.
Custom M-function
Uses the MATLAB function specified with the M-function parameter to create
identifiers for parameter names in the generated code.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• Setting this parameter to Custom M-function enables M-function.
• This parameter must be the same for top-level and referenced models.
7-45
7 Code Generation Parameters: Symbols
Command-Line Information
Parameter: ParamNamingRule
Type: character vector
Value: None | UpperCase | LowerCase | Custom
Default: None
Recommended Settings
Application Setting
Debugging No impact
Traceability Force upper case
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Apply Naming Rules to Simulink Data Objects” (Embedded Coder)
• “Programming Scripts and Functions” (MATLAB)
7-46
M-function
M-function
Description
Specify rule for naming identifiers in generated code.
Settings
Default: ''
Enter the name of a MATLAB language file that contains the naming rule to be applied
to signal, parameter, or #define parameter identifiers in generated code. Examples of
rules you might program in such a MATLAB function include:
For example, the following function returns an identifier name by appending the text
_param to a parameter data object name.
revisedName = [name,text];
7-47
7 Code Generation Parameters: Symbols
Tip
The MATLAB language file must be in the MATLAB path.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by Parameter naming.
• This parameter must be the same for top-level and referenced models.
Command-Line Information
Parameter: ParamNamingFcn
Type: character vector
Value: MATLAB language file
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Specify Naming Rule Using a Function” (Embedded Coder)
• “Programming Scripts and Functions” (MATLAB)
7-48
#define naming
#define naming
Description
Specify rule for naming #define parameters (defined with storage class Define
(Custom)) in generated code.
Settings
Default: None
None
Does not change #define parameter names when creating corresponding identifiers
in generated code. Parameter identifiers in the generated code match the parameter
names that appear in the model.
Force upper case
Uses uppercase characters when creating identifiers for #define parameter names
in the generated code.
Force lower case
Uses lowercase characters when creating identifiers for #define parameter names
in the generated code.
Custom M-function
Uses the MATLAB function specified with the M-function parameter to create
identifiers for #define parameter names in the generated code.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• Setting this parameter to Custom M-function enables M-function.
• This parameter must be the same for top-level and referenced models.
Command-Line Information
Parameter: DefineNamingRule
7-49
7 Code Generation Parameters: Symbols
Recommended Settings
Application Setting
Debugging No impact
Traceability Force upper case
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Specify Naming Rule for Storage Class Define” (Embedded Coder)
• “Programming Scripts and Functions” (MATLAB)
7-50
M-function
M-function
Description
Specify rule for naming identifiers in generated code.
Settings
Default: ''
Enter the name of a MATLAB language file that contains the naming rule to be applied
to signal, parameter, or #define parameter identifiers in generated code. Examples of
rules you might program in such a MATLAB function include:
For example, the following function returns an identifier name by appending the text
_define to a data object name.
revisedName = [name,text];
7-51
7 Code Generation Parameters: Symbols
Tip
The MATLAB language file must be in the MATLAB path.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by #define naming.
• This parameter must be the same for top-level and referenced models.
Command-Line Information
Parameter: DefineNamingFcn
Type: character vector
Value: MATLAB language file
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
• “Specify Naming Rule Using a Function” (Embedded Coder)
• “Programming Scripts and Functions” (MATLAB)
7-52
Use the same reserved names as Simulation Target
Description
Specify whether to use the same reserved names as those specified in the Simulation
Target pane.
Settings
Default: Off
On
Enables using the same reserved names as those specified in the Simulation Target
pane.
Off
Disables using the same reserved names as those specified in the Simulation
Target pane.
Command-Line Information
Parameter: UseSimReservedNames
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
7-53
7 Code Generation Parameters: Symbols
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
7-54
Reserved names
Reserved names
Description
Enter the names of variables or functions in the generated code that match the names of
variables or functions specified in custom code.
Settings
Default: {}
This action changes the names of variables or functions in the generated code to avoid
name conflicts with identifiers in custom code. Reserved names must be shorter than 256
characters.
Tips
• Do not enter code generator keywords since these names cannot be changed in the
generated code. For a list of keywords to avoid, see “Reserved Keywords”.
• Start each reserved name with a letter or an underscore to prevent error messages.
• Each reserved name must contain only letters, numbers, or underscores.
• Separate the reserved names using commas or spaces.
• You can also specify reserved names by using the command line:
config_param_object.set_param('ReservedNameArray', {'abc','xyz'})
Command-Line Information
Parameter: ReservedNameArray
Type: cell array of character vectors
Value: reserved names shorter than 256 characters
Default: {}
7-55
7 Code Generation Parameters: Symbols
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Symbols” on page 7-2
7-56
8
On the Configuration Parameters dialog box, the following configuration parameters are
on the Commonly Used tab, on the Code Generation > Custom Code pane or on the
All Parameters tab in the Code Generation > Custom Code category.
Parameter Description
“Use the same custom code settings as Specify whether to use the same custom
Simulation Target” on page 8-4 code settings as those in the Simulation
Target > Custom Code pane.
“Source file” on page 8-6 Specify custom code to include near the top
of the generated model source file.
“Header file” on page 8-7 Specify custom code to include near the top
of the generated model header file.
“Initialize function” on page 8-9 Specify custom code to include in the
generated model initialize function.
“Terminate function” on page 8-10 Specify custom code to include in the
generated model terminate function.
“Include directories” on page 8-12 Specify a list of include folders to add to the
include path.
“Source files” on page 8-14 Specify a list of additional source files to
compile and link with the generated code.
“Libraries” on page 8-16 Specify a list of additional libraries to link
with the generated code.
“Defines” on page 8-18 Specify preprocessor macro definitions to
be added to the compiler command line.
More About
• “Model Configuration”
8-2
Code Generation: Custom Code Tab Overview
Configuration
1 Select the type of information to include from the list on the left side of the pane.
2 Enter custom code or enter text to identify a folder, source file, or library.
3 Click Apply.
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
• “Integrate External Code by Using Model Configuration Parameters”
8-3
8 Code Generation Parameters: Custom Code
Description
Specify whether to use the same custom code settings as those in the Simulation
Target > Custom Code pane.
Settings
Default: Off
On
Enables using the same custom code settings as those in the Simulation Target >
Custom Code pane.
Off
Disables using the same custom code settings as those in the Simulation Target >
Custom Code pane.
Command-Line Information
Parameter: RTWUseSimCustomCode
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
8-4
Use the same custom code settings as Simulation Target
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
• “Integrate External Code by Using Model Configuration Parameters”
8-5
8 Code Generation Parameters: Custom Code
Source file
Description
Specify custom code to include near the top of the generated model source file.
Settings
Default:''
The code generator places code near the top of the generated model.c or model.cpp file,
outside of any function.
Command-Line Information
Parameter: CustomSourceCode
Type: character vector
Value: C code
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
• “Integrate External Code by Using Model Configuration Parameters”
8-6
Header file
Header file
Description
Specify custom code to include near the top of the generated model header file.
Settings
Default:''
The code generator places this code near the top of the generated model.h header file.
If you are including a header file, in your custom header file add #ifndef code. This
avoids multiple inclusions. For example, in rtwtypes.h the following #include guards
are added:
#ifndef RTW_HEADER_rtwtypes_h_
#define RTW_HEADER_rtwtypes_h_
...
#endif /* RTW_HEADER_rtwtypes_h_ */
Command-Line Information
Parameter: CustomHeaderCode
Type: character vector
Value: C code
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
8-7
8 Code Generation Parameters: Custom Code
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
• “Integrate External Code by Using Model Configuration Parameters”
8-8
Initialize function
Initialize function
Description
Specify custom code to include in the generated model initialize function.
Settings
Default: ''
The code generator places code inside the model's initialize function in the model.c or
model.cpp file.
Command-Line Information
Parameter: CustomInitializer
Type: character vector
Value: C code
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
• “Integrate External Code by Using Model Configuration Parameters”
8-9
8 Code Generation Parameters: Custom Code
Terminate function
Specify custom code to include in the generated model terminate function.
Description
Specify custom code to include in the generated model terminate function.
Settings
Default: ''
Specify code to appear in the model's generated terminate function in the model.c or
model.cpp file.
Dependency
A terminate function is generated only if you select the Terminate function required
check box on the All Parameters tab.
Command-Line Information
Parameter: CustomTerminator
Type: character vector
Value: C code
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
8-10
Terminate function
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
• “Integrate External Code by Using Model Configuration Parameters”
8-11
8 Code Generation Parameters: Custom Code
Include directories
Description
Specify a list of include folders to add to the include path.
Settings
Default:''
Enter a space-separated list of include folders to add to the include path when compiling
the generated code.
Note: If you specify a Windows path containing one or more spaces, you must enclose
the path in double quotes. For example, the second and third paths in the Include
directories entry below must be double-quoted:
C:\Project "C:\Custom Files" "C:\Library Files"
Command-Line Information
Parameter: CustomInclude
Type: character vector
Value: folder path
8-12
Include directories
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
• “Integrate External Code by Using Model Configuration Parameters”
8-13
8 Code Generation Parameters: Custom Code
Source files
Description
Specify a list of additional source files to compile and link with the generated code.
Settings
Default: ''
Enter a space-separated list of source files to compile and link with the generated code.
Limitation
This parameter does not support Windows file names that contain embedded spaces.
Tip
You can specify just the file name if the file is in the current MATLAB folder or in one of
the include folders.
Command-Line Information
Parameter: CustomSource
Type: character vector
Value: file name
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
8-14
Source files
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
• “Integrate External Code by Using Model Configuration Parameters”
8-15
8 Code Generation Parameters: Custom Code
Libraries
Description
Specify a list of additional libraries to link with the generated code.
Settings
Default: ''
Enter a space-separated list of static library files to link with the generated code.
Limitation
This parameter does not support Windows file names that contain embedded spaces.
Tip
You can specify just the file name if the file is in the current MATLAB folder or in one of
the include folders.
Command-Line Information
Parameter: CustomLibrary
Type: character vector
Value: library file name
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
8-16
Libraries
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
• “Integrate External Code by Using Model Configuration Parameters”
8-17
8 Code Generation Parameters: Custom Code
Defines
Description
Specify preprocessor macro definitions to be added to the compiler command line.
Settings
Default: ''
Enter a list of macro definitions for the compiler command line. Specify the parameters
with a space-separated list of macro definitions. If a makefile is generated, these macro
definitions are added to the compiler command line in the makefile. The list can include
simple definitions (for example, -DDEF1), definitions with a value (for example, -
DDEF2=1), and definitions with a space in the value (for example, -DDEF3="my value").
Definitions can omit the -D (for example, -DFOO=1 and FOO=1 are equivalent). If the
toolchain uses a different flag for definitions, the code generator overrides the -D and
uses the appropriate flag for the toolchain.
Command-Line Information
Parameter: CustomDefine
Type: character vector
Value: preprocessor macro definition
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Custom Code” on page 8-2
8-18
Defines
8-19
9
On the Configuration Parameters dialog box, the following configuration parameters are
on the Commonly Used tab, on the Code Generation > Interface pane.
Parameter Description
“Code replacement library” on page Specify a code replacement library the code
9-6 generator uses when producing code for a
model.
“Shared code placement” on page 9-9 Specify the location for generating utility
functions, exported data type definitions,
and declarations of exported data with
custom storage class.
“Support: floating-point numbers” on page Specify whether to generate floating-point
9-11 data and operations.
“Support: non-finite numbers” on page Specify whether to generate non-finite data
9-13 and operations on non-finite data.
“Support: complex numbers” on page Specify whether to generate complex data
9-15 and operations.
“Support: absolute time” on page 9-17 Specify whether to generate and maintain
integer counters for absolute and elapsed
time values.
“Support: continuous time” on page Specify whether to generate code for blocks
9-19 that use continuous time.
“Support: variable-size signals” on page Specify whether to generate code for
9-22 models that use variable-size signals.
“Code interface packaging” on page Select the packaging for the generated C or
9-24 C++ code interface.
“Multi-instance code error diagnostic” on Select the severity level for diagnostics
page 9-28 displayed when a model violates
9-2
Model Configuration Parameters: Code Generation Interface
Parameter Description
requirements for generating multi-instance
code.
“Pass root-level I/O as” on page 9-30 Control how root-level model input
and output are passed to the reusable
model_step function.
“Remove error status field in real-time Specify whether to log or monitor error
model data structure” on page 9-32 status.
“Configure Model Functions” on page Specify whether the code generator
9-34 uses default model_initialize and
model_step function prototypes or model-
specific C prototypes.
“Parameter visibility” on page 9-35 Specify whether to generate the block
parameter structure as a public,
private, or protected data member of
the C++ model class.
“Parameter access” on page 9-37 Specify whether to generate access
methods for block parameters for the C++
model class.
“External I/O access” on page 9-39 Specify whether to generate access
methods for root-level I/O signals for the C
++ model class.
“Configure C++ Class Interface” on page Customize the C++ class interface for your
9-41 model code.
“Generate C API for: signals” on page Generate C API data interface code with a
9-42 signals structure.
“Generate C API for: parameters” on page Generate C API data interface code with
9-44 parameter tuning structures.
“Generate C API for: states” on page Generate C API data interface code with a
9-46 states structure.
“Generate C API for: root-level I/O” on page Generate C API data interface code with a
9-48 root-level I/O structure.
“ASAP2 interface” on page 9-50 Generate code for the ASAP2 data
interface.
9-3
9 Code Generation Parameters: Interface
Parameter Description
“External mode” on page 9-52 Generate code for the external mode data
interface.
“Transport layer” on page 9-54 Specify the transport protocol for
communications.
“MEX-file arguments” on page 9-56 Specify arguments to pass to an external
mode interface MEX-file for communicating
with executing targets.
“Static memory allocation” on page 9-58 Control memory buffer for external mode
communication.
“Static memory buffer size” on page Specify the memory buffer size for external
9-60 mode communication.
More About
• “Model Configuration”
9-4
Code Generation: Interface Tab Overview
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Run-Time Environment Configuration”
9-5
9 Code Generation Parameters: Interface
Description
Specify a code replacement library the code generator uses when producing code for a
model.
Settings
Default: None
None
Does not use a code replacement library.
GNU C99 extensions
Generates calls to the GNU® gcc math library, which provides C99 extensions as
defined by compiler option -std=gnu99.
AUTOSAR 4.0
Produces code that more closely aligns with the AUTOSAR standard. Requires an
Embedded Coder license.
Intel IPP for x86-64 (Windows)
Generates calls to the Intel® Performance Primitives (IPP) library for the x86-64
Windows platform.
Intel IPP/SSE for x86-64 (Windows)
Generates calls to the IPP and Streaming SIMD Extensions (SSE) libraries for the
x86-64 Windows platform.
Intel IPP for x86-64 (Windows using MinGW compiler)
Generates calls to the IPP library for the x86-64 Windows platform and MinGW
compiler.
Intel IPP/SSE for x86-64 (Windows using MinGW compiler)
Generates calls to the IPP and SSE libraries for the x86/Pentium Windows platform.
Intel IPP for x86/Pentium (Windows)
9-6
Code replacement library
Intel IPP for x86/Pentium (Windows)—Generates calls to the IPP library for the x86/
Pentium Windows platform.
Intel IPP/SSE for x86/Pentium (Windows)
Intel IPP for x86/Pentium (Windows)—Generates calls to the IPP and SSE libraries
for the x86/Pentium Windows platform.
Intel IPP for x86-64 (Linux)
Generates calls to the IPP library for the x86-64 Linux® platform.
Intel IPP/SSE with GNU99 extensions for x86-64 (Linux)
Generates calls to the GNU libraries for IPP and SSE, with GNU C99 extensions, for
the x86-64 Linux platform.
• Additional values might be listed for licensed target products and for embedded and
desktop targets. If you have created and registered code replacement libraries using
the Embedded Coder product, additional values are listed.
• The software filters the list of Code replacement library values based on
compatibility with Language, Standard math library, and Device vendor values
you select for your model.
Tips
• If you specify Shared location for the Code Generation > Interface > Shared
code placement parameter or you generate code for models in a model reference
hierarchy,
• Models that are sharing the location or are in the model hierarchy must specify the
same code replacement library (same name, tables, and table entries).
• If you change the name or contents of the code replacement library and rebuild
the model from the same folder as the previous build, the code generator
reports a checksum warning (see “Manage the Shared Utility Code Checksum”).
The warning prompts you to remove the existing folder and stop or stop code
generation.
• If both of the following conditions exist for a model that contains Stateflow charts, the
Simulink software regenerates code for the charts and recompiles the generated code.
• You do not specify Shared location for the Code Generation > Interface >
Shared code placement parameter.
• You change the code replacement library name or contents before regenerating
code.
9-7
9 Code Generation Parameters: Interface
Tip
Before setting this parameter, verify that your compiler supports the library that
you want to use. If you select a parameter value that your compiler does not support,
compiler errors can occur.
Command-Line Information
Parameter: CodeReplacementLibrary
Type: character vector
Value: 'None' | 'GNU C99 extensions' | 'Intel IPP for x86-64 (Windows)'
| 'Intel IPP/SSE for x86-64 (Windows)' | 'Intel IPP for x86-64
(Windows for MinGW compiler)' |'Intel IPP/SSE for x86-64 (Windows for
MinGW compiler)' | 'Intel IPP for x86/Pentium (Windows)' | 'Intel IPP/
SSE x86/Pentium (Windows)' | 'Intel IPP for x86-64 (Linux)' | 'Intel
IPP/SSE with GNU99 extensions for x86-64 (Linux)'
Default: 'None'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Valid library
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Run-Time Environment Configuration”
• “What Is Code Replacement Customization?” (Embedded Coder)
• “Develop a Code Replacement Library” (Embedded Coder)
9-8
Shared code placement
Description
Specify the location for generating utility functions, exported data type definitions, and
declarations of exported data with custom storage class.
Settings
Default: Auto
Auto
The code generator places utility code within the slprj/target/_sharedutils
folder for a model that contains Existing Shared Code (Embedded Coder) or at least
one of the following blocks:
• Model blocks
• Simulink Function blocks
• Function Caller blocks
• Calls to Simulink Functions from Stateflow or MATLAB Function blocks
If a model does not contain one of the above blocks or Existing Shared Code
(Embedded Coder), the code generator places utility code in the build folder
(generally, in model.c or model.cpp).
Shared location
Directs code for utilities to be placed within the slprj folder in your working folder.
Command-Line Information
Parameter: UtilityFuncGeneration
Type: character vector
Value: 'Auto' | 'Shared location'
Default: 'Auto'
9-9
9 Code Generation Parameters: Interface
Recommended Settings
Application Setting
Debugging Shared location (GRT)
No impact (ERT)
Traceability Shared location (GRT)
No impact (ERT)
Efficiency No impact (execution, RAM)
Shared location (ROM)
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Run-Time Environment Configuration”
• “Sharing Utility Code”
9-10
Support: floating-point numbers
Description
Specify whether to generate floating-point data and operations.
Settings
Default: On (GUI), 'off' (command-line)
On
Generates floating-point data and operations.
Off
Generates pure integer code. If you clear this option, an error occurs if the code
generator encounters floating-point data or expressions. The error message reports
offending blocks and parameters.
Dependencies
• This option only appears for ERT-based targets.
• This option requires an Embedded Coder license when generating code.
• Selecting this option enables Support: non-finite numbers and clearing this option
disables Support: non-finite numbers.
• This option must be the same for top-level and referenced models.
• When you select the configuration parameter MAT-File Logging, you must also
select Support: non-finite numbers and Support: floating-point numbers.
Command-Line Information
Parameter: PurelyIntegerCode
Type: character vector
Value: 'on' | 'off'
Default: 'off'
9-11
9 Code Generation Parameters: Interface
Note: The command-line values are reverse of the settings values. The value 'on' in the
command line corresponds to the description of “Off” in the settings section. The value
'off' in the command line corresponds to the description of “On” in the settings section.
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Off (GUI), 'on' (command-line) — for integer only
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-12
Support: non-finite numbers
Description
Specify whether to generate non-finite data and operations on non-finite data.
Settings
Default: on
On
Generates non-finite data (for example, NaN and Inf) and related operations.
Off
Does not generate non-finite data and operations. If you clear this option, an error
occurs if the code generator encounters non-finite data or expressions. The error
message reports offending blocks and parameters.
Note: Code generation is optimized with the assumption that non-finite data are
absent. However, if your application produces non-finite numbers through signal
data or MATLAB code, the behavior of the generated code might be inconsistent with
simulation results when processing non-finite data.
Dependencies
• For ERT-based targets, parameter Support: floating-point numbers enables
Support: non-finite numbers.
• If off for top model, can be off or off for referenced models.
9-13
9 Code Generation Parameters: Interface
Command-Line Information
Parameter: SupportNonFinite
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Off (execution, ROM), No impact (RAM)
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-14
Support: complex numbers
Settings
Default: on
On
Generates complex numbers and related operations.
Off
Does not generate complex data and related operations. If you clear this option, an
error occurs if the code generator encounters complex data or expressions. The error
message reports offending blocks and parameters.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• If off for top model, can be off or off for referenced models.
Command-Line Information
Parameter: SupportComplex
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
9-15
9 Code Generation Parameters: Interface
Application Setting
Traceability No impact
Efficiency Off (for real only)
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-16
Support: absolute time
Settings
Default: on
On
Generates and maintains integer counters for blocks that require absolute or elapsed
time values. Absolute time is the time from the start of program execution to the
present time. An example of elapsed time is time elapsed between two trigger events.
If you select this option and the model does not include blocks that use time values,
the target does not generate the counters.
Off
Does not generate integer counters to represent absolute or elapsed time values. If
you do not select this option and the model includes blocks that require absolute or
elapsed time values, an error occurs during code generation.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• Select this parameter if your model includes blocks that require absolute or elapsed
time values.
Command-Line Information
Parameter: SupportAbsoluteTime
Type: character vector
Value: 'on' | 'off'
9-17
9 Code Generation Parameters: Interface
Default: 'on'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Off
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Timers in Asynchronous Tasks”
9-18
Support: continuous time
Description
Specify whether to generate code for blocks that use continuous time.
Settings
Default: off
On
Generates code for blocks that use continuous time.
Off
Does not generate code for blocks that use continuous time. If you do not select
this option and the model includes blocks that use continuous time, an error occurs
during code generation.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license to generate code.
• This parameter must be on for models that include blocks that require absolute or
elapsed time values.
• This parameter is cleared if you select Remove error status field in real-time
model data structure.
• If both the following conditions exist, output values read from ert_main for a
continuous output port can differ from the corresponding output values in logged data
for a model:
• You customize ert_main.c or .cpp to read model outputs after each base-rate
model step.
• You select parameters Support: continuous time and Single output/update
function.
9-19
9 Code Generation Parameters: Interface
The difference occurs because, while logged data captures output at major time steps,
output read from ert_main after the base-rate model step can capture output at
intervening minor time steps. The following table lists workarounds that eliminate
the discrepancy.
Command-Line Information
Parameter: SupportContinuousTime
Type: character vector
Value: 'on' | 'off'
Default: 'off'
9-20
Support: continuous time
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Off (execution, ROM), No impact (RAM)
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Use Discrete and Continuous Time” (Embedded Coder)
9-21
9 Code Generation Parameters: Interface
Description
Specify whether to generate code for models that use variable-size signals.
Settings
Default: Off
On
Generates code for models that use variable-size signals.
Off
Does not generate code for models that use variable-size signals. If this parameter is
off and the model uses variable-size signals, an error occurs during code generation.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: SupportVariableSizeSignals
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
9-22
Support: variable-size signals
Application Setting
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-23
9 Code Generation Parameters: Interface
Description
Select the packaging for the generated C or C++ code interface.
Settings
Default: Nonreusable function if Language is set to C; C++ class if Language is
set to C++
C++ class
Generate a C++ class interface to model code. The generated interface encapsulates
required model data into C++ class attributes and model entry point functions into C
++ class methods.
Nonreusable function
Generate nonreusable code. Model data structures are statically allocated and
accessed by model entry point functions directly in the model code.
Reusable function
Generate reusable, multi-instance code that is reentrant, as follows:
• For a GRT-based model, the generated model.c source file contains an allocation
function that dynamically allocates model data for each instance of the model.
For an ERT-based model, you can use the Use dynamic memory allocation
for model initialization option to control whether an allocation function is
generated.
• The generated code passes the real-time model data structure in, by reference, as
an argument to model_step and the other model entry point functions.
• The real-time model data structure is exported with the model.h header file.
For an ERT-based model, you can use the Pass root-level I/O as parameter to
control how root-level input and output arguments are passed to the reusable
model entry-point functions. They can be included in the real-time model data
structure that is passed to the functions, passed as individual arguments, or passed
as references to an input structure and an output structure.
9-24
Code interface packaging
Tips
• Entry points are exported with model.h. To call the entry-point functions from
handwritten code, add an #include model.h directive to the code.
• When you select Reusable function, the code generator generates a pointer to the
real-time model object (model_M).
• When you select Reusable function, the code generator can generate code that
compiles but is not reentrant. For example, if a signal, DWork structure, or parameter
data has a storage class other than Auto, global data structures are generated.
Dependencies
• The value C++ class is available only if the Language parameter is set to C++ on
the Code Generation pane.
• Selecting Reusable function or C++ class enables Multi-instance code error
diagnostic.
• For an ERT target, selecting Reusable function enables Pass root-level I/O as
and Use dynamic memory allocation for model initialization.
• For an ERT target, selecting C++ class enables the following controls for
customizing the model class interface:
• Select the value Part of model data structure for Pass root-level I/O as.
• Select the option Use dynamic memory allocation for model initialization.
• For an ERT target, you cannot use Reusable function if you are using:
9-25
9 Code Generation Parameters: Interface
• Has a port that is used by multiple instances of the subsystem and has
different sample times, data types, complexity, frame status, or dimensions
across the instances
• Has output marked as a global signal
• For each instance contains identical blocks with different names or parameter
settings
• Using Reusable function does not change the code generated for function-call
subsystems.
Command-Line Information
Parameter: CodeInterfacePackaging
Type: character vector
Value: 'C++ class' | 'Nonreusable function' | 'Reusable function'
Default: 'Nonreusable function' if TargetLang is set to 'C'; 'C++ class' if
TargetLang is set to 'C++'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Reusable function or C++ class
Safety precaution No impact
See Also
model_step
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Entry-Point Functions and Scheduling”
• “Generate Reentrant Code from Top-Level Models”
• “Combine Code Generated for Multiple Models or Multiple Instances of a Model”
• “Generate Reentrant Code from Top-Level Models” (Embedded Coder)
9-26
Code interface packaging
9-27
9 Code Generation Parameters: Interface
Description
Select the severity level for diagnostics displayed when a model violates requirements for
generating multi-instance code.
Settings
Default: Error
None
Proceed with build without displaying a diagnostic message.
Warning
Proceed with build after displaying a warning message.
Error
Abort build after displaying an error message.
• Generate code that compiles but is not reentrant. For example, if a signal or DWork
structure has a storage class other than Auto, global data structures are generated.
• Be unable to generate valid and compilable code. For example, if the model contains
an S-function that is not code-reuse compliant or a subsystem triggered by a wide
function-call trigger, the code generator produces invalid code, displays an error
message, and terminates the build.
Dependencies
This parameter is enabled by setting Code interface packaging to Reusable
function or C++ class.
Command-Line Information
Parameter: MultiInstanceErrorCode
9-28
Multi-instance code error diagnostic
Recommended Settings
Application Setting
Debugging Warning or Error
Traceability No impact
Efficiency None
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Entry-Point Functions and Scheduling”
• “Generate Reentrant Code from Top-Level Models”
• “Generate C++ Class Interface to Model or Subsystem Code”
• “Code Generation of Subsystems”
• “Code Reuse Limitations for Subsystems”
• “Determine Why Subsystem Code Is Not Reused”
• “Generate Modular Function Code” (Embedded Coder)
9-29
9 Code Generation Parameters: Interface
Description
Control how root-level model input and output are passed to the reusable model_step
function.
Settings
Default: Individual arguments
Individual arguments
Passes each root-level model input and output value to model_step as a separate
argument.
Structure reference
Packs root-level model input into a struct and passes struct to model_step as an
argument. Similarly, packs root-level model output into a second struct and passes
it to model_step.
Part of model data structure
Packages root-level model input and output into the real-time model data structure.
Dependencies
• This parameter only appears for ERT-based targets with Code interface packaging
set to Reusable function.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: RootIOFormat
Type: character vector
Value: 'Individual arguments' | 'Structure reference' | 'Part of model
data structure'
Default: 'Individual arguments'
9-30
Pass root-level I/O as
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
model_step
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Entry-Point Functions and Scheduling”
• “Generate Reentrant Code from Top-Level Models” (Embedded Coder)
• “Code Generation of Subsystems”
• “Generate Modular Function Code” (Embedded Coder)
9-31
9 Code Generation Parameters: Interface
Description
Specify whether to log or monitor error status.
Settings
Default: off
On
Omits the error status field from the generated real-time model data structure
rtModel. This option reduces memory usage.
Be aware that selecting this option can cause the code generator to omit the rtModel
data structure from generated code.
Off
Includes an error status field in the generated real-time model data structure
rtModel. You can use available macros to monitor the field for error message data or
set it with error message data.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• Selecting this parameter clears Support: continuous time.
• If your application contains multiple integrated models, the setting of this option
must be the same for all of the models to avoid unexpected application behavior. For
example, if you select the option for one model but not another, an error status might
not get registered by the integrated application.
Command-Line Information
Parameter: SuppressErrorStatus
9-32
Remove error status field in real-time model data structure
Recommended Settings
Application Setting
Debugging Off
Traceability No impact
Efficiency On
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Use the Real-Time Model Data Structure”
9-33
9 Code Generation Parameters: Interface
Description
Open the Model Interface dialog box. In this dialog box, you can specify whether the code
generator uses default model_initialize and model_step function prototypes or
model-specific C prototypes. Based on your selection, you can preview and modify the
function prototypes.
Dependencies
• This button appears only for ERT-based targets with Code interface packaging set
to a value other than C++ class.
• This button requires an Embedded Coder license when generating code.
• This button is active only if your model uses an attached configuration set. If your
model uses a referenced configuration set, the button is greyed out. If you want to
configure a model-specific step function prototype for a referenced configuration
set, use the MATLAB function prototype control functions described in “Configure
Function Prototypes Programmatically” (Embedded Coder).
See Also
model_initialize | model_step
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Control Generation of Function Prototypes” (Embedded Coder)
• “Launch the Model Interface Dialog Boxes” (Embedded Coder)
9-34
Parameter visibility
Parameter visibility
Description
Specify whether to generate the block parameter structure as a public, private, or
protected data member of the C++ model class.
Settings
Default: private
public
Generates the block parameter structure as a public data member of the C++ model
class.
private
Generates the block parameter structure as a private data member of the C++
model class.
protected
Generates the block parameter structure as a protected data member of the C++
model class.
Dependencies
• This parameter appears only for ERT-based targets with Language set to C++ and
Code interface packaging set to C++ class.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: ParameterMemberVisibility
Type: character vector
Value: 'public' | 'private' | 'protected'
Default: 'private'
9-35
9 Code Generation Parameters: Interface
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Configure Code Interface Options” (Embedded Coder)
9-36
Parameter access
Parameter access
Description
Specify whether to generate access methods for block parameters for the C++ model
class.
Settings
Default: None
None
Does not generate access methods for block parameters for the C++ model class.
Method
Generates noninlined access methods for block parameters for the C++ model class.
Inlined method
Generates inlined access methods for block parameters for the C++ model class.
Dependencies
• This parameter appears only for ERT-based targets with Language set to C++ and
Code interface packaging set to C++ class.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: GenerateParameterAccessMethods
Type: character vector
Value: 'None' | 'Method' | 'Inlined method'
Default: 'None'
Recommended Settings
Application Setting
Debugging Inlined method
9-37
9 Code Generation Parameters: Interface
Application Setting
Traceability Inlined method
Efficiency Inlined method
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Configure Code Interface Options” (Embedded Coder)
9-38
External I/O access
Note: This parameter affects generated code only if you are using the default (void-void
style) step method for your model class. The parameter has no affect if you are explicitly
passing arguments for root-level I/O signals using an I/O arguments style step method.
For more information, see “Passing Default Arguments” (Embedded Coder) and “Passing
I/O Arguments” (Embedded Coder).
Settings
Default: None
None
Does not generate access methods for root-level I/O signals for the C++ model class.
Method
Generates noninlined access methods for root-level I/O signals for the C++ model
class. The software generates set and get methods for each signal.
Inlined method
Generates inlined access methods for root-level I/O signals for the C++ model class.
The software generates set and get methods for each signal.
Structure-based method
Generates noninlined, structure-based access methods for root-level I/O signals for
the C++ model class. The software generates one set method, taking the address of
the external input structure as an argument, and for external outputs (if applicable),
one get method, returning the reference to the external output structure.
Inlined structure-based method
Generates inlined, structure-based access methods for root-level I/O signals for the
C++ model class. The software generates one set method, taking the address of the
9-39
9 Code Generation Parameters: Interface
external input structure as an argument, and for external outputs (if applicable), one
get method, returning the reference to the external output structure.
Dependencies
• This parameter appears only for ERT-based targets with Language set to C++ and
Code interface packaging set to C++ class.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: GenerateExternalIOAccessMethods
Type: character vector
Value: 'None' | 'Method' | 'Inlined method' | 'Structure-based method' |
'Inlined structure-based method'
Default: 'None'
Recommended Settings
Application Setting
Debugging Inlined method
Traceability Inlined method
Efficiency Inlined method
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Configure Code Interface Options” (Embedded Coder)
9-40
Configure C++ Class Interface
Description
Open the Configure C++ class interface dialog box. In this dialog box, you can customize
the C++ class interface for your model code. Based on your selections, you can preview
and modify the model-specific C++ class interface.
Dependencies
• This button appears only for ERT-based targets with Language set to C++ and Code
interface packaging set to C++ class.
• This button requires an Embedded Coder license when generating code.
• This button is active only if your model uses an attached configuration set. If your
model uses a referenced configuration set, the button is greyed out. If you want to
configure a model-specific C++ class interface for a referenced configuration set, use
the MATLAB C++ class interface control functions described in “Customize C++ Class
Interfaces Programmatically” (Embedded Coder).
See Also
model_step
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Control Generation of C++ Class Interfaces” (Embedded Coder)
• “Configure Step Method for Your Model Class” (Embedded Coder)
9-41
9 Code Generation Parameters: Interface
Settings
Default: off
On
Generates C API interface to global block outputs.
Off
Does not generate C API signals.
Command-Line Information
Parameter: RTWCAPISignals
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact during development
Off for production code generation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-42
Generate C API for: signals
9-43
9 Code Generation Parameters: Interface
Settings
Default: off
On
Generates C API interface to global block parameters.
Off
Does not generate C API parameters.
Command-Line Information
Parameter: RTWCAPIParams
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact during development
Off for production code generation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-44
Generate C API for: parameters
9-45
9 Code Generation Parameters: Interface
Settings
Default: off
On
Generates C API interface to discrete and continuous states.
Off
Does not generate C API states.
Command-Line Information
Parameter: RTWCAPIStates
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact during development
Off for production code generation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-46
Generate C API for: states
9-47
9 Code Generation Parameters: Interface
Settings
Default: off
On
Generates a C API interface to root-level inputs and outputs.
Off
Does not generate a C API interface to root-level inputs and outputs.
Command-Line Information
Parameter: RTWCAPIRootIO
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact during development
Off for production code generation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-48
Generate C API for: root-level I/O
9-49
9 Code Generation Parameters: Interface
ASAP2 interface
Description
Generate code for the ASAP2 data interface.
Settings
Default: off
On
Generates code for the ASAP2 data interface.
Off
Does not generate code for the ASAP2 data interface.
Command-Line Information
Parameter: GenerateASAP2
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact during development
Off for production code generation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-50
ASAP2 interface
9-51
9 Code Generation Parameters: Interface
External mode
Description
Generate code for the external mode data interface.
Settings
Default: off
On
Generates code for the external mode data interface.
Off
Does not generate code for the external mode data interface.
Command-Line Information
Parameter: ExtMode
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact during development
Off for production code generation
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
9-52
External mode
9-53
9 Code Generation Parameters: Interface
Transport layer
Description
Specify the transport protocol for communications.
Settings
Default: tcpip
tcpip
Applies a TCP/IP transport mechanism. The MEX-file name is ext_comm.
serial
Applies a serial transport mechanism. The MEX-file name is
ext_serial_win32_comm.
Tip
The MEX-file name displayed next to Transport layer cannot be edited in the
Configuration Parameters dialog box. The value is specified either in matlabroot/
toolbox/simulink/simulink/extmode_transports.m, for targets provided by
MathWorks®, or in an sl_customization.m file, for custom targets and/or custom
transports.
Dependency
Selecting External mode enables this parameter.
Command-Line Information
Parameter: ExtModeTransport
Type: integer
Value: 0 for TCP/IP | 1 for serial
Default: 0
9-54
Transport layer
Recommended Settings
Application No impact
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Target Interfacing”
• “Create a Transport Layer for External Communication”
9-55
9 Code Generation Parameters: Interface
MEX-file arguments
Description
Specify arguments to pass to an external mode interface MEX-file for communicating
with executing targets.
Settings
Default: ''
Dependency
Selecting External mode enables this parameter.
Command-Line Information
Parameter: ExtModeMexArgs
Type: character vector
Value: valid arguments
Default: ''
9-56
MEX-file arguments
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Target Interfacing”
• “Choose Communication Protocol for Client and Server”
9-57
9 Code Generation Parameters: Interface
Description
Control memory buffer for external mode communication.
Settings
Default: off
On
Enables the Static memory buffer size parameter for allocating dynamic memory.
Off
Uses a static memory buffer for External mode instead of allocating dynamic memory
(calls to malloc).
Tip
To determine how much memory to allocate, select verbose mode on the target. That
selection displays the amount of memory the target tries to allocate and the amount of
memory available.
Dependencies
• Selecting External mode enables this parameter.
• This parameter enables Static memory buffer size.
Command-Line Information
Parameter: ExtModeStaticAlloc
Type: character vector
Value: 'on' | 'off'
Default: 'off'
9-58
Static memory allocation
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Configure External Mode Options for Code Generation”
9-59
9 Code Generation Parameters: Interface
Settings
Default: 1000000
Enter the number of bytes to preallocate for external mode communications buffers in
the target.
Tips
• If you enter too small a value for your application, external mode issues an out-of-
memory error.
• To determine how much memory to allocate, select verbose mode on the target. That
selection displays the amount of memory the target tries to allocate and the amount of
memory available.
Dependency
Selecting Static memory allocation enables this parameter.
Command-Line Information
Parameter: ExtModeStaticAllocSize
Type: integer
Value: valid value
Default: 1000000
Recommended Settings
Application Setting
Debugging No impact
9-60
Static memory buffer size
Application Setting
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Interface” on page 9-2
• “Configure External Mode Options for Code Generation”
9-61
10
In this section...
“Configuration Parameters for Code Generation Advanced Parameters” on page
10-2
“Configuration Parameters for Hardware Implementation Advanced Parameters” on
page 10-8
“Configuration Parameters for MathWorks Use Only ” on page 10-8
Parameter Description
“Classic call interface” on page 10-37 Specify whether to generate model function
calls compatible with the main program
module of the GRT target in models created
before R2012a.
“Code-to-model” on page 10-14 Include hyperlinks in the code generation
report that link code to the corresponding
Simulink blocks, Stateflow objects, and
MATLAB functions in the model diagram.
“Combine signal/state structures” on page Specify whether to combine global block
10-48 signals and global state data into one data
structure in the generated code
“Configure” on page 10-18 Open the Model-to-code navigation
dialog box for specifying a build folder
containing previously-generated model code
to highlight.
“Custom LAPACK library callback” on page Specify LAPACK library callback class
10-74 for LAPACK calls in code generated from
MATLAB code.
10-2
Model Configuration Parameters: Advanced Parameters
Parameter Description
“Eliminated / virtual blocks” on page Include summary of eliminated and virtual
10-19 blocks in code generation report.
“EMX array utility functions identifier Customize generated identifiers for
format” on page 10-76 emxArray utility functions. This parameter
applies to MATLAB code in a MATLAB
Function block, a Stateflow chart, or a
System object associated with a MATLAB
System block.
“EMX array types identifier format” on Customize generated identifiers for
page 10-78 emxArray types. This parameter applies
to MATLAB code in a MATLAB Function
block, a Stateflow chart, or a System object
associated with a MATLAB System block.
“Enable TLC assertion” on page 10-72 Produce the TLC stack trace.
“Generate destructor” on page 10-55 Specify whether to generate a destructor
for the C++ model class.
“Ignore custom storage classes” on page Specify whether to apply or ignore custom
10-10 storage classes.
“Ignore test point signals” on page Specify allocation of memory buffers for
10-12 test points.
“Internal data access” on page 10-53 Specify whether to generate access
methods for internal data structures, such
as Block I/O, DWork vectors, Run-time
model, Zero-crossings, and continuous
states, for the C++ model class.
“Internal data visibility” on page 10-51 Specify whether to generate internal
data structures such as Block I/O, DWork
vectors, Run-time model, Zero-crossings,
and continuous states as public,
private, or protected data members of
the C++ model class.
“MAT-file logging” on page 10-57 Specify MAT-file logging.
“MAT-file variable name modifier” on page Select the text to add to MAT-file variable
10-60 names.
10-3
10 Simulink Coder Parameters: All Parameters Tab Only
Parameter Description
“Maximum word length” on page 10-35 Specify a maximum word length, in bits,
for which the code generation process
generates system-defined multiword type
definitions.
“Model-to-code” on page 10-16 Link Simulink blocks, Stateflow objects,
and MATLAB functions in a model
diagram to corresponding code segments
in a generated HTML report so that
the generated code for a block can be
highlighted on request.
“Multiword type definitions” on page Specify whether to use system-defined or
10-33 user-defined type definitions for multiword
data types in generated code.
“Profile TLC” on page 10-66 Profile the execution time of TLC files.
“Retain .rtw file” on page 10-64 Specify model.rtw file retention.
“Single output/update function” on page Specify whether to generate the
10-43 model_step function.
“Standard math library” on page 10-29 Specify the standard math library for your
execution environment. Verify that your
compiler supports the library you want
to use; otherwise compile-time errors can
occur.
C89/C90 (ANSI) - ISO®/IEC 9899:1990 C
standard math library
C99 (ISO) - ISO/IEC 9899:1999 C
standard math library
C++03 (ISO) - ISO/IEC 14882:2003 C++
standard math library
“Start TLC coverage when generating code” Generate the TLC execution report.
on page 10-70
“Start TLC debugger when generating Specify use of the TLC debugger
code” on page 10-68
10-4
Model Configuration Parameters: Advanced Parameters
Parameter Description
“Summarize which blocks triggered code Include code replacement report
replacements” on page 10-27 summarizing replacement functions used
and their associated blocks in the code
generation report.
“Support: non-inlined S-functions” on page Specify whether to generate code for non-
10-31 inlined S-functions.
“Terminate function required” on page Specify whether to generate the
10-46 model_terminate function.
“Traceable MATLAB functions” on page Include summary of MATLAB functions in
10-25 code generation report.
“Traceable Simulink blocks” on page Include summary of Simulink blocks in
10-21 code generation report.
“Traceable Stateflow objects” on page Include summary of Stateflow objects in
10-23 code generation report.
“Use dynamic memory allocation for model Specify whether generated code uses
block instantiation” on page 10-41 the operator new, during model object
registration, to instantiate objects for
referenced models configured with a C++
class interface.
“Use dynamic memory allocation for model Control how the generated code allocates
initialization” on page 10-39 memory for model data.
“Use Simulink Coder Features” on page Enable “Simulink Coder” features for
10-80 models deployed to “Simulink Supported
Hardware” (Simulink).
“Verbose build” on page 10-62 Display code generation progress.
“Custom token text” (Embedded Coder) Custom text to replace $U in the Symbols
pane.
“Remove reset function” (Embedded Coder) Remove unreachable (dead-code) instances
of the reset functions from the generated
code for ERT-based systems that include
model referencing hierarchies.
10-5
10 Simulink Coder Parameters: All Parameters Tab Only
Parameter Description
“Remove disable function” (Embedded Remove unreachable (dead-code) instances
Coder) of the disable functions from the
generated code for ERT-based systems that
include model referencing hierarchies.
The following Code Generation > Advanced Parameters are infrequently used and have
no other documentation.
Parameter Description
CompOptLevelCompliant Set in SelectCallback for a target to
off, on indicate whether the target supports the
ability to use the Compiler optimization
level parameter on the All Parameters
tab to control the compiler optimization
level for building generated code.
10-6
Model Configuration Parameters: Advanced Parameters
Parameter Description
ParMdlRefBuildCompliant Indicates if the model is configured for
parallel builds when building a model that
includes referenced models.
PostCodeGenCommand Add the specified post code generation
character vector - '' command to the model build process.
ProfileTLC Profile the execution time of each TLC file
character vector - off, on used to generate code for this model in
HTML format.
RTWVerbose Display messages indicating code
character vector - off, on generation stages and compiler output.
RetainRTWFile Retain the model.rtw file in the current
character vector - off, on build folder.
TargetLibSuffix Control the suffix used for naming a
character vector - '' target's dependent libraries (for example,
_target.lib or _target.a). If specified,
the character vector must include a
period (.). (For generated model reference
libraries, the library suffix defaults to
_rtwlib.lib on Windows systems and
_rtwlib.a on UNIX systems.).
10-7
10 Simulink Coder Parameters: All Parameters Tab Only
Parameter Description
TLCDebug Start the TLC debugger during code
character vector - off, on generation at the beginning of the TLC
program. TLC breakpoint statements
automatically invoke the TLC debugger
regardless of this setting.
TLCOptions Specify additional TLC command line
character vector - '' options.
Parameter Description
TargetPreprocMaxBitsSint Specify the maximum number of bits
int - 32 that the target C preprocessor can use for
signed integer math.
TargetPreprocMaxBitsUint Specify the maximum number of bits
int - 32 that the target C preprocessor can use for
unsigned integer math.
“Use Embedded Coder Features” Enable “Embedded Coder” features for
(Embedded Coder) models deployed to “Simulink Supported
Hardware” (Simulink).
10-8
Model Configuration Parameters: Advanced Parameters
Parameter Description
PreserveNameWithParent For MathWorks use only.
SignalNamingFcn For MathWorks use only.
TargetFcnLib For MathWorks use only.
TargetTypeEmulationWarn- For MathWorks use only.
SuppressLevel
int - 0 When greater than or equal to 2, suppress
warning messages that the code generator
displays when emulating integer sizes in
rapid prototyping environments.
10-9
10 Simulink Coder Parameters: All Parameters Tab Only
Description
Specify whether to apply or ignore custom storage classes.
Settings
Default: off
On
Ignores custom storage classes by treating data objects that have them as if their
storage class attribute is set to Auto. Data objects with an Auto storage class do not
interface with external code and are stored as local or shared variables or in a global
data structure.
Off
Applies custom storage classes as specified. You must clear this option if the model
defines data objects with custom storage classes.
Tips
• Clear this parameter before configuring data objects with custom storage classes.
• Setting for top-level and referenced models must match.
Dependencies
• This parameter only appears for ERT-based targets.
• Clear this parameter to enable module packaging features.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: IgnoreCustomStorageClasses
Type: character vector
10-10
Ignore custom storage classes
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Custom Storage Classes” (Embedded Coder)
10-11
10 Simulink Coder Parameters: All Parameters Tab Only
Settings
Default: Off
On
Ignores test points during code generation, allowing optimal buffer allocation for
signals with test points, facilitating transition from prototyping to deployment and
avoiding accidental degradation of generated code due to workflow artifacts.
Off
Allocates separate memory buffers for test points, resulting in a loss of code
generation optimizations such as reducing memory usage by storing signals in
reusable buffers.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: IgnoreTestpoints
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging Off
10-12
Ignore test point signals
Application Setting
Traceability No impact
Efficiency On
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Signals with Test Points”
• “Test Points” (Simulink)
• “Signal Representation in Generated Code”
10-13
10 Simulink Coder Parameters: All Parameters Tab Only
Code-to-model
Description
Include hyperlinks in the code generation report that link code to the corresponding
Simulink blocks, Stateflow objects, and MATLAB functions in the model diagram.
Settings
Default: On
On
Includes hyperlinks in the code generation report that link code to corresponding
Simulink blocks, Stateflow objects, and MATLAB functions in the model diagram.
The hyperlinks provide traceability for validating generated code against the source
model.
Off
Omits hyperlinks from the generated report.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled and selected by Create code generation report.
• You must select Include comments on the Code Generation > Comments pane to
use this parameter.
Command-Line Information
Parameter: IncludeHyperlinkInReport
Type: character vector
Value: 'on' | 'off
Default: 'on'
10-14
Code-to-model
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “HTML Code Generation Report Extensions” (Embedded Coder)
10-15
10 Simulink Coder Parameters: All Parameters Tab Only
Model-to-code
Description
Link Simulink blocks, Stateflow objects, and MATLAB functions in a model diagram to
corresponding code segments in a generated HTML report so that the generated code for
a block can be highlighted on request.
Settings
Default: On
On
Includes model-to-code highlighting support in the code generation report. To
highlight the generated code for a Simulink block, Stateflow object, or MATLAB
script in the code generation report, right-click the item and select C/C++ Code >
Navigate to C/C++ Code.
Off
Omits model-to-code highlighting support from the generated report.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled when you select Create code generation report.
• You must select the following parameters to use this parameter:
• “Include comments” on page 6-5 on the Code Generation > Comments pane
• At least one of the following:
10-16
Model-to-code
Command-Line Information
Parameter: GenerateTraceInfo
Type: Boolean
Value: on | off
Default: on
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “HTML Code Generation Report Extensions” (Embedded Coder)
10-17
10 Simulink Coder Parameters: All Parameters Tab Only
Configure
Description
Open the Model-to-code navigation dialog box. This dialog box provides a way for
you to specify a build folder containing previously-generated model code to highlight.
Applying your build folder selection will attempt to load traceability information from the
earlier build, for which Model-to-code must have been selected.
Dependency
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by “Model-to-code” on page 10-16.
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “HTML Code Generation Report Extensions” (Embedded Coder)
10-18
Eliminated / virtual blocks
Description
Include summary of eliminated and virtual blocks in code generation report.
Settings
Default: On
On
Includes a summary of eliminated and virtual blocks in the code generation report.
Off
Does not include a summary of eliminated and virtual blocks.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by Create code generation report.
Command-Line Information
Parameter: GenerateTraceReport
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
10-19
10 Simulink Coder Parameters: All Parameters Tab Only
Application Setting
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “HTML Code Generation Report Extensions” (Embedded Coder)
10-20
Traceable Simulink blocks
Description
Include summary of Simulink blocks in code generation report.
Settings
Default: On
On
Includes a summary of Simulink blocks and the corresponding code location in the
code generation report.
Off
Does not include a summary of Simulink blocks.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by Create code generation report.
Command-Line Information
Parameter: GenerateTraceReportSl
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
10-21
10 Simulink Coder Parameters: All Parameters Tab Only
Application Setting
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “HTML Code Generation Report Extensions” (Embedded Coder)
10-22
Traceable Stateflow objects
Description
Include summary of Stateflow objects in code generation report.
Settings
Default: On
On
Includes a summary of Stateflow objects and the corresponding code location in the
code generation report.
Off
Does not include a summary of Stateflow objects.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by Create code generation report.
Command-Line Information
Parameter: GenerateTraceReportSf
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
10-23
10 Simulink Coder Parameters: All Parameters Tab Only
Application Setting
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “HTML Code Generation Report Extensions” (Embedded Coder)
• “Traceability of Stateflow Objects in Generated Code” (Stateflow)
10-24
Traceable MATLAB functions
Description
Include summary of MATLAB functions in code generation report.
Settings
Default: On
On
Includes a summary of MATLAB functions and corresponding code locations in the
code generation report.
Off
Does not include a summary of MATLAB functions.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by Create code generation report.
Command-Line Information
Parameter: GenerateTraceReportEml
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
10-25
10 Simulink Coder Parameters: All Parameters Tab Only
Application Setting
Traceability On
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• “HTML Code Generation Report Extensions” (Embedded Coder)
10-26
Summarize which blocks triggered code replacements
Description
Include code replacement report summarizing replacement functions used and their
associated blocks in the code generation report.
Settings
Default: Off
On
Include code replacement report in the code generation report.
Note: Selecting this option also generates code replacement trace information
for viewing in the Trace Information tab of the Code Replacement Viewer. The
generated information can help you determine why an expected code replacement did
not occur.
Off
Omit code replacement report from the code generation report.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled when you select Create code generation report.
Command-Line Information
Parameter: GenerateCodeReplacementReport
Type: Boolean
Value: on | off
10-27
10 Simulink Coder Parameters: All Parameters Tab Only
Default: off
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Code Generation Report” on page 5-2
• Analyze Code Replacements in the Generated Code (Embedded Coder)
• Trace Code Replacements Generated Using Your Code Replacement Library
(Embedded Coder)
• Determine Why Code Replacement Functions Were Not Used (Embedded Coder)
10-28
Standard math library
Description
Specify standard math library for model.
Settings
Default: C99 (ISO) or, if Language is set to C++, C++03 (ISO)
C89/C90 (ANSI)
Generates calls to the ISO/IEC 9899:1990 C standard math library.
C99 (ISO)
Generates calls to the ISO/IEC 9899:1999 C standard math library.
C++03 (ISO)
Generates calls to the ISO/IEC 14882:2003 C++ standard math library.
Tips
• Before setting this parameter, verify that your compiler supports the library you want
to use. If you select a parameter value that your compiler does not support, compiler
errors can occur.
• If you are using a compiler that does not support ISO/IEC 9899:1999 C, set this
parameter to C89/C90 (ANSI).
• The build process checks whether the specified standard math library and toolchain
are compatible. If they are not compatible, a warning occurs during code generation
and the build process continues.
Dependencies
• C++03 is available for use only if you select C++ for the Language parameter.
• When you change the value of the Language parameter, the standard math library
updates to C99 (ISO) for C and C++03 (ISO) for C++.
10-29
10 Simulink Coder Parameters: All Parameters Tab Only
Command-Line Information
Parameter: TargetLangStandard
Type: character vector
Value: 'C89/C90 (ANSI)' | 'C99 (ISO)' | 'C++03 (ISO)'
Default: For C, 'C99 (ISO)'; for C++ 'C++03 (ISO)'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Valid library
Safety precaution No impact
Related Examples
• “Specify Single-Precision Data Type for Embedded Application”
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Run-Time Environment Configuration”
10-30
Support: non-inlined S-functions
Description
Specify whether to generate code for non-inlined S-functions.
Settings
Default: Off
On
Generates code for non-inlined S-functions.
Off
Does not generate code for non-inlined S-functions. If this parameter is off and the
model includes a non-inlined S-function, an error occurs during the build process.
Tip
• Inlining S-functions is highly advantageous in production code generation, for
example, for implementing device drivers. In such cases, clear this option to enforce
use of inlined S-functions for code generation.
• Non-inlined S-functions require additional memory and computation resources, and
can result in significant performance issues. Consider using an inlined S-function
when efficiency is a concern.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• Selecting this parameter also selects Support: floating-point numbers and
Support: non-finite numbers. If you clear Support: floating-point numbers
or Support: non-finite numbers, a warning is displayed during code generation
because these parameters are required by the S-function interface.
10-31
10 Simulink Coder Parameters: All Parameters Tab Only
Command-Line Information
Parameter: SupportNonInlinedSFcns
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Off
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “S-Functions and Code Generation”
10-32
Multiword type definitions
Settings
Default: System defined
System defined
Use the default system type definitions for multiword data types in generated code.
During code generation, if multiword usage is detected, multiword type definitions
are generated into the file multiword_types.h.
User defined
Allows you to control how multiword type definitions are handled during the code
generation process. Selecting this value enables the associated parameter Maximum
word length, which allows you to specify a maximum word length, in bits, for
which the code generation process generates multiword type definitions into the file
multiword_types.h. The default maximum word length is 256. If you select 0,
multiword type definitions are not generated into the file multiword_types.h.
The maximum word length for multiword types only determines the type definitions
generated and does not impact the efficiency of the generated code. If the maximum
word length for multiword types is set to 0 or too small, an error occurs when the
generated code is compiled. This error is caused by the generated code using a type
that does not have the required type definition. To resolve the error, increase the
maximum word length and regenerate the code. If the maximum word length for
multiword types is larger than required, then multiword_types.h might contain
unused type definitions. Unused type definitions do not consume target resources.
Tips
• Adding a model to a model hierarchy or changing an existing model in the hierarchy
can result in updates to the shared multiword_types.h file during code generation.
10-33
10 Simulink Coder Parameters: All Parameters Tab Only
These updates occur when the new model uses multiword types of length greater
than those of the other models. You must then recompile and, depending on your
development process, reverify previously generated code. To prevent updates to
multiword_types.h, determine a maximum word length sufficiently big to cover the
needs of all models in the hierarchy. Configure every model in the hierarchy to use
that same maximum word length.
• The majority of embedded designs do not need multiword types. By setting maximum
word length for multiword types to 0, you can prevent use of multiword variables
on the target. If you use multiword variables with a maximum word length that is 0
or smaller than required, you are alerted with an error when the generated code is
compiled.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• Selecting the value User defined for this parameter enables the associated
parameter Maximum word length.
Command-Line Information
Parameter: ERTMultiwordTypeDef
Type: character vector
Value: 'System defined' | 'User defined'
Default: 'System defined'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
10-34
Maximum word length
Settings
Default: 256
Specify a maximum word length, in bits, for which the code generation process generates
multiword type definitions into the file multiword_types.h. All multiword type
definitions up to and including this number of bits are generated. If you select 0,
multiword type definitions are not generated into the file multiword_types.h.
The maximum word length for multiword types only determines the type definitions
generated and does not impact the efficiency of the generated code. If the maximum word
length for multiword types is set to 0 or too small, an error occurs when the generated
code is compiled. This error is caused by the generated code using a type that does not
have the required type definition. To resolve the error, increase the maximum word
length and regenerate the code. If the maximum word length for multiword types is
larger than required, then multiword_types.h might contain unused type definitions.
Unused type definitions do not consume target resources.
Tips
• Adding a model to a model hierarchy or changing an existing model in the hierarchy
can result in updates to the shared multiword_types.h file during code generation.
These updates occur when the new model uses multiword types of length greater
than those of the other models. You must then recompile and, depending on your
development process, reverify previously generated code. To prevent updates to
multiword_types.h, determine a maximum word length sufficiently big to cover the
needs of all models in the hierarchy. Configure every model in the hierarchy to use
that same maximum word length.
• The majority of embedded designs do not need multiword types. By setting maximum
word length for multiword types to 0, you can prevent use of multiword variables
10-35
10 Simulink Coder Parameters: All Parameters Tab Only
on the target. If you use multiword variables with a maximum word length that is 0
or smaller than required, you are alerted with an error when the generated code is
compiled.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
• This parameter is enabled by selecting the value User defined for the parameter
Multiword type definitions.
Command-Line Information
Parameter: ERTMultiwordLength
Type: integer
Value: valid quantity of bits representing a word size
Default: 256
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
10-36
Classic call interface
Description
Specify whether to generate model function calls compatible with the main program
module of the GRT target in models created before R2012a.
Settings
Default: off (except on for GRT models created before R2012a)
On
Generates model function calls that are compatible with the main program module of
the GRT target (grt_main.c or grt_main.cpp) in models created before R2012a.
This option provides a quick way to use code generated in the current release with
a GRT-based custom target that has a main program module based on pre-R2012a
grt_main.c or grt_main.cpp.
Off
Disables the classic call interface.
Tips
The following are unsupported:
Dependencies
• Setting Code interface packaging to C++ class disables this option.
• Selecting this option disables the incompatible option Single output/update
function. Clearing this option enables (but does not select) Single output/update
function.
10-37
10 Simulink Coder Parameters: All Parameters Tab Only
Command-Line Information
Parameter: GRTInterface
Type: character vector
Value: 'on' | 'off'
Default: 'off' (except 'on' for GRT models created before R2012a)
Recommended Settings
Application Setting
Debugging No impact
Traceability Off
Efficiency Off (execution, ROM), No impact (RAM)
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Use Discrete and Continuous Time” (Embedded Coder)
10-38
Use dynamic memory allocation for model initialization
Settings
Default: off
On
Generates a function to dynamically allocate memory (using malloc) for model data
structures.
Off
Does not generate a dynamic memory allocation function. The generated code
statically allocates memory for model data structures.
Dependencies
• This parameter only appears for ERT-based targets with Code interface packaging
set to Reusable function.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: GenerateAllocFcn
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
10-39
10 Simulink Coder Parameters: All Parameters Tab Only
Application Setting
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
See Also
model_step
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Entry-Point Functions and Scheduling”
• “Generate Reentrant Code from Top-Level Models” (Embedded Coder)
• “Code Generation of Subsystems”
• “Generate Modular Function Code” (Embedded Coder)
10-40
Use dynamic memory allocation for model block instantiation
Settings
Default: off
On
Generates code that uses dynamic memory allocation to instantiate objects for
referenced models configured with a C++ class interface. Specifically, during
instantiation of an object for the top model in a model reference hierarchy, the
generated code uses new to instantiate objects for referenced models.
Selecting this option frees a parent model from having to maintain information about
referenced models beyond its direct children.
• If you select this option, be aware that a bad_alloc exception might be thrown,
per the C++ standard, if an out-of-memory error occurs during the use of new. You
must provide code to catch and process the bad_alloc exception in case an out-
of-memory error occurs for a new call during construction of a top model object.
• If Use dynamic memory allocation for model block instantiation is
selected and the base model contains a Model block, the build process might
generate copy constructor and assignment operator functions in the private
section of the model class. The purpose of the functions is to prevent pointer
members within the model class from being copied by other code. For more
information, see “Model Class Copy Constructor and Assignment Operator”
(Embedded Coder).
Off
Does not generate code that uses new to instantiate referenced model objects.
Clearing this option means that a parent model maintains information about its
referenced models, including its direct and indirect children.
10-41
10 Simulink Coder Parameters: All Parameters Tab Only
Dependencies
• This parameter appears only for ERT-based targets with Language set to C++ and
Code interface packaging set to C++ class.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: UseOperatorNewForModelRefRegistration
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency On
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Configure Code Interface Options” (Embedded Coder)
10-42
Single output/update function
Settings
Default: on
On
Generates the model_step function for a model. This function contains the output
and update function code for the blocks in the model and is called by rt_OneStep to
execute processing for one clock period of the model at interrupt level.
Off
Does not combine output and update function code into a single function, and instead
generates the code in separate model_output and model_update functions.
Tips
Errors or unexpected behavior can occur if a Model block is part of a cycle, the Model
block is a direct feedthrough block, and an algebraic loop results. See “Model Blocks and
Direct Feed through” (Simulink) for details.
Simulink Coder ignores this parameter for a referenced model if any of the following
conditions apply to that model:
• Is multi-rate
• Has a continuous sample time
• Is logging states (using the States or Final states parameters in the Configuration
Parameters > Data Import/Export pane
Dependencies
• Setting Code interface packaging to C++ class forces on and disables this option.
10-43
10 Simulink Coder Parameters: All Parameters Tab Only
• This option and Classic call interface are mutually incompatible and cannot both
be selected through the GUI. Selecting Classic call interface forces off and disables
this option and clearing Classic call interface enables (but does not select) this
option.
• When you use this option, you must clear the option Minimize algebraic loop
occurrences on the Model Referencing pane.
• If you customize ert_main.c or .cpp to read model outputs after each base-rate
model step, selecting both parameters Support: continuous time and Single
output/update function can cause output values read from ert_main for a
continuous output port to differ from the corresponding output values in the logged
data for the model. This is because, while logged data is a snapshot of output at major
time steps, output read from ert_main after the base-rate model step potentially
reflects intervening minor time steps. The following table lists workarounds that
eliminate the discrepancy.
10-44
Single output/update function
Command-Line Information
Parameter: CombineOutputUpdateFcns
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency On
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “rt_OneStep and Scheduling Considerations” (Embedded Coder)
10-45
10 Simulink Coder Parameters: All Parameters Tab Only
Settings
Default: on
On
Generates a model_terminate function. This function contains model termination
code and should be called as part of system shutdown.
Off
Does not generate a model_terminate function. Suppresses the generation of this
function if you designed your application to run indefinitely and does not require a
terminate function.
Dependencies
• This parameter only appears for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: IncludeMdlTerminateFcn
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging No impact
10-46
Terminate function required
Application Setting
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
See Also
model_terminate
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
10-47
10 Simulink Coder Parameters: All Parameters Tab Only
Settings
Default: Off
On
Combine global block signal data (block I/O) and global state data (DWork vectors)
into one data structure in the generated code.
Off
Store global block signals and global states in separate data structures, block I/O and
DWork vectors, in the generated code.
Tips
The benefits to setting this parameter to On are:
• Enables tighter memory representation through fewer bitfields, which reduces RAM
usage
• Enables better alignment of data structure elements, which reduces RAM usage
• Reduces the number of arguments to reusable subsystem and model reference block
functions, which reduces stack usage
• Better readable data structures with more consistent element sorting
Example
10-48
Combine signal/state structures
uint_T UnitDelay1:1;
} bitsForTID0;
} BlockIO;
/* Block states (auto storage) */
typedef struct {
struct {
uint_T UnitDelay_DSTATE:1
uint_T UnitDelay1_DSTATE:1
} bitsForTID0;
} D_Work;
If you select Combine signal/state structures, the generated code now looks like this:
/* Block signals and states (auto storage)
for system */
typedef struct {
struct {
uint_T LogicalOperator:1;
uint_T UnitDelay1:1;
uint_T UnitDelay_DSTATE:1;
uint_T UnitDelay1_DSTATE:1;
} bitsForTID0;
} D_Work;
Dependencies
This parameter:
Command-Line Information
Parameter: CombineSignalStateStructs
Type: character vector
Value: 'on' | 'off'
Default: off
Recommended Settings
Application Setting
Debugging No impact
10-49
10 Simulink Coder Parameters: All Parameters Tab Only
Application Setting
Traceability No impact
Efficiency On
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Global Block I/O Structure”
• “Storage Classes for Block States”
10-50
Internal data visibility
Description
Specify whether to generate internal data structures such as Block I/O, DWork vectors,
Run-time model, Zero-crossings, and continuous states as public, private, or
protected data members of the C++ model class.
Settings
Default: private
public
Generates internal data structures as public data members of the C++ model class.
private
Generates internal data structures as private data members of the C++ model
class.
protected
Generates internal data structures as protected data members of the C++ model
class.
Dependencies
• This parameter appears only for ERT-based targets with Language set to C++ and
Code interface packaging set to C++ class.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: InternalMemberVisibility
Type: character vector
Value: 'public' | 'private' | 'protected'
Default: 'private'
10-51
10 Simulink Coder Parameters: All Parameters Tab Only
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Configure Code Interface Options” (Embedded Coder)
10-52
Internal data access
Description
Specify whether to generate access methods for internal data structures, such as Block
I/O, DWork vectors, Run-time model, Zero-crossings, and continuous states, for the C++
model class.
Settings
Default: None
None
Does not generate access methods for internal data structures for the C++ model
class.
Method
Generates noninlined access methods for internal data structures for the C++ model
class.
Inlined method
Generates inlined access methods for internal data structures for the C++ model
class.
Dependencies
• This parameter appears only for ERT-based targets with Language set to C++ and
Code interface packaging set to C++ class.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: GenerateInternalMemberAccessMethods
Type: character vector
Value: 'None' | 'Method' | 'Inlined method'
Default: 'None'
10-53
10 Simulink Coder Parameters: All Parameters Tab Only
Recommended Settings
Application Setting
Debugging Inlined method
Traceability Inlined method
Efficiency Inlined method
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Configure Code Interface Options” (Embedded Coder)
10-54
Generate destructor
Generate destructor
Description
Specify whether to generate a destructor for the C++ model class.
Settings
Default: on
On
Generates a destructor for the C++ model class.
Off
Does not generate a destructor for the C++ model class.
Dependencies
• This parameter appears only for ERT-based targets with Language set to C++ and
Code interface packaging set to C++ class.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: GenerateDestructor
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
10-55
10 Simulink Coder Parameters: All Parameters Tab Only
Application Setting
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Configure Code Interface Options” (Embedded Coder)
10-56
MAT-file logging
MAT-file logging
Description
Specify MAT-file logging
Settings
Default: on for the GRT target, off for ERT-based targets
On
Enable MAT-file logging. When you select this option, the generated code saves to
MAT-files simulation data specified in one of the following ways:
Off
Disable MAT-file logging. Clearing this option has the following benefits:
10-57
10 Simulink Coder Parameters: All Parameters Tab Only
• Omits the comparison between the current time and stop time in the
model_step, allowing the generated program to run indefinitely, regardless of
the stop time setting
Dependencies
• When you select MAT-file logging, you must also select the configuration
parameters Support: non-finite numbers and, if you use an ERT-based system
target file, Support: floating-point numbers.
• Selecting this option enables MAT-file variable name modifier.
• For ERT-based system target files, clear this parameter if you are using exported
function calls.
Limitations
MAT-file logging does not support file-scoped data, for example, data items to which you
apply the built-in custom storage class FileScope.
In a referenced model, only the following data logging features are supported:
• To File blocks
• State logging — the software stores the data in the MAT-file for the top model.
In the context of the Embedded Coder product, MAT-file logging does not support the
following IDEs: Analog Devices® VisualDSP++®, Texas Instruments™ Code Composer
Studio™, Wind River® DIAB/GCC.
MAT-file logging does not support Outport blocks to which you apply the storage class
ImportedExternPointer or custom storage classes that yield nonaddressable data in
the generated code. For example, the custom storage class GetSet causes the Outport to
appear in the generated code as a function call, which is not addressable. This limitation
applies whether you apply the storage class directly by using, for example, the Model
Data Editor, or by resolving the Outport to a Simulink.Signal object that uses the
storage class. As a workaround, apply the storage class to the signal that enters the
Outport block.
Command-Line Information
Parameter: MatFileLogging
10-58
MAT-file logging
Recommended Settings
Application Setting
Debugging On
Traceability No impact
Efficiency Off
Safety precaution Off
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Log Program Execution Results”
• “Log Data for Analysis”
• “Virtualized Output Ports Optimization” (Embedded Coder)
• “Virtualized Output Ports Optimization” (Embedded Coder)
10-59
10 Simulink Coder Parameters: All Parameters Tab Only
Description
Select the text to add to MAT-file variable names.
Settings
Default: rt_
rt_
Adds prefix text.
_rt
Adds suffix text.
none
Does not add text.
Dependency
If you have an Embedded Coder license, for the GRT target or ERT-based targets, this
parameter is enabled by MAT-file logging.
Command-Line Information
Parameter: LogVarNameModifier
Type: character vector
Value: 'none' | 'rt_' | '_rt'
Default: 'rt_'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
10-60
MAT-file variable name modifier
Application Setting
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Log Program Execution Results”
• “Log Data for Analysis”
10-61
10 Simulink Coder Parameters: All Parameters Tab Only
Verbose build
Description
Display code generation progress.
Settings
Default: on
On
The MATLAB Command Window displays progress information indicating code
generation stages and compiler output during code generation.
Off
Does not display progress information.
Command-Line Information
Parameter: RTWVerbose
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
10-62
Verbose build
• “Debug”
10-63
10 Simulink Coder Parameters: All Parameters Tab Only
Settings
Default: off
On
Retains the model.rtw file in the current build folder. This parameter is useful if
you are modifying the target files and need to look at the file.
Off
Deletes the model.rtw from the build folder at the end of the build process.
Command-Line Information
Parameter: RetainRTWFile
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging On
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
10-64
Retain .rtw file
• “Debug”
10-65
10 Simulink Coder Parameters: All Parameters Tab Only
Profile TLC
Description
Profile the execution time of TLC files.
Settings
Default: off
On
The TLC profiler analyzes the performance of TLC code executed during code
generation, and generates an HTML report.
Off
Does not profile the performance.
Command-Line Information
Parameter: ProfileTLC
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging On
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
10-66
Profile TLC
• “Debug”
10-67
10 Simulink Coder Parameters: All Parameters Tab Only
Settings
Default: Off
On
The TLC debugger starts during code generation.
Off
Does not start the TLC debugger.
Tips
• You can also start the TLC debugger by entering the -dc argument into the System
target file field.
• To invoke the debugger and run a debugger script, enter the -df filename
argument into the System target file field.
Command-Line Information
Parameter: TLCDebug
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging On
Traceability No impact
10-68
Start TLC debugger when generating code
Application Setting
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Debug”
10-69
10 Simulink Coder Parameters: All Parameters Tab Only
Settings
Default: off
On
Generates .log files containing the number of times each line of TLC code is
executed during code generation.
Off
Does not generate a report.
Tip
You can also generate the TLC execution report by entering the -dg argument into the
System target file field.
Command-Line Information
Parameter: TLCCoverage
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging On
Traceability No impact
Efficiency No impact
10-70
Start TLC coverage when generating code
Application Setting
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Debug”
10-71
10 Simulink Coder Parameters: All Parameters Tab Only
Settings
Default: off
On
The build process halts if a user-supplied TLC file contains an %assert directive
that evaluates to FALSE.
Off
The build process ignores TLC assertion code.
Command-Line Information
Parameter: TLCAssert
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging On
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
10-72
Enable TLC assertion
• “Debug”
10-73
10 Simulink Coder Parameters: All Parameters Tab Only
Settings
Default: ''
Specify the name of a LAPACK callback class that derives from coder.LAPACKCallback.
If you specify a LAPACK callback class, for certain linear algebra functions, the code
generator produces LAPACK calls by using the LAPACKE C interface to your LAPACK
library. The callback class provides the name of your LAPACKE header file and the
information required to link to your LAPACK library. If this parameter is empty, the
code generator produces code for linear algebra functions instead of a LAPACK call.
Limitation
The class definition file must be in a folder on the MATLAB path.
Tip
Specify only the name of the class. Do not specify the name of the class definition file.
Command-Line Information
Parameter: CustomLAPACKCallback
Type: character vector
Value: class name
Default: ''
Recommended Settings
Application Setting
Debugging No impact
10-74
Custom LAPACK library callback
Application Setting
Traceability No impact
Efficiency No impact
Safety precaution No impact
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Speed Up Linear Algebra in Code Generated from a MATLAB Function Block”
10-75
10 Simulink Coder Parameters: All Parameters Tab Only
Description
Customize generated identifiers for emxArray (embeddable mxArray) utility functions.
The code generator produces emxArray types for variable-size arrays that use
dynamically allocated memory. It produces emxArray utility functions that create and
interact with variables that have an emxArray type. This parameter applies to MATLAB
code in a MATLAB Function block, a Stateflow chart, or a System object™ associated
with a MATLAB System block. This parameter does not apply to:
Settings
Default: emx$M$N
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$M Insert name-mangling text if required to avoid naming collisions.
Required.
$N Insert the utility function name into identifier. For example,
Init_real.
$R Insert root model name into identifier, replacing unsupported
characters with the underscore (_) character.
10-76
EMX array utility functions identifier format
Tips
• The code generator applies the identifier format specified by this parameter before it
applies the formats specified by other identifier format control parameters.
• Where possible, increase the Maximum identifier length to accommodate the
length of the identifiers you expect to generate. Reserve at least three characters for
name-mangling text.
• If you specify $R, the value that you specify for Maximum identifier length must be
large enough to accommodate full expansions of the $R and $M tokens.
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: CustomSymbolStrEmxFcn
Type: character vector
Value: valid combination of tokens
Default: emx$M$N
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Identifier Format Control” (Embedded Coder)
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Identifier Format Control Parameters Limitations” (Embedded Coder)
10-77
10 Simulink Coder Parameters: All Parameters Tab Only
Settings
Default: emxArray_$M$N
Enter a macro that specifies whether, and in what order, certain text is to be included
in the generated identifier. The macro can include a combination of the following format
tokens.
Token Description
$M Insert name-mangling text if required to avoid naming collisions.
Required.
$N Insert type name. For example, real_T
$R Insert root model name into identifier, replacing unsupported
characters with the underscore (_) character.
Tips
• The code generator applies the identifier format specified by this parameter before it
applies the formats specified by other identifier format control parameters.
10-78
EMX array types identifier format
Dependencies
• This parameter appears only for ERT-based targets.
• This parameter requires an Embedded Coder license when generating code.
Command-Line Information
Parameter: CustomSymbolStrEmxType
Type: character vector
Value: valid combination of tokens
Default: emxArray_$M$N
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No recommendation
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
• “Identifier Format Control” (Embedded Coder)
• “Control Name Mangling in Generated Identifiers” (Embedded Coder)
• “Identifier Format Control Parameters Limitations” (Embedded Coder)
10-79
10 Simulink Coder Parameters: All Parameters Tab Only
Note: If you enable this parameter in a model where Simulink Coder is not installed or
available in the environment, a question dialog box prompts you to update the model to
build without Simulink Coder features.
Settings
On
Enable the “Model Configuration Parameters: Advanced Parameters” on page 10-2.
Off
Disable the “Model Configuration Parameters: Advanced Parameters” on page 10-2.
Indicates that this parameter is enabled. To disable it, first disable the “Use
Embedded Coder Features” (Embedded Coder) parameter.
Dependencies
This parameter requires a Simulink Coder or Embedded Coder license.
Command-Line Information
Parameter: UseSimulinkCoderFeatures
Value: 'on' or 'off'
Default: 'on'
Related Examples
• “Model Configuration Parameters: Advanced Parameters” on page 10-2
10-80
11
The Code Generation > RSim Target pane includes the following parameters when
the Simulink Coder product is installed on your system and you specify the rsim.tlc
system target file.
11-2
Code Generation Pane: RSim Target
In this section...
“Code Generation: RSim Target Tab Overview” on page 11-4
“Enable RSim executable to load parameters from a MAT-file” on page 11-5
“Solver selection” on page 11-6
“Force storage classes to AUTO” on page 11-7
11-3
11 Configuration Parameters for Simulink Models
Configuration
This tab appears only if you specify rsim.tlc as the “System target file” on page 4-5.
See Also
11-4
Code Generation Pane: RSim Target
Settings
Default: on
On
Enables RSim to load parameters from a MAT-file.
Off
Disables RSim from loading parameters from a MAT-file.
Command-Line Information
Parameter: RSIM_PARAMETER_LOADING
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
11-5
11 Configuration Parameters for Simulink Models
Solver selection
Instruct the target how to select the solver.
Settings
Default: auto
auto
Lets the code generator choose the solver. The code generator uses the Simulink
solver module if you specify a variable-step solver on the Solver pane. Otherwise, the
code generator uses a built-in solver.
Use Simulink solver module
Instructs the code generator to use the variable-step solver that you specify on the
Solver pane.
Use fixed-step solvers
Instructs the code generator to use the fixed-step solver that you specify on the
Solver pane.
Command-Line Information
Parameter: RSIM_SOLVER_SELECTION
Type: character vector
Value: 'auto' | 'usesolvermodule' | 'usefixstep'
Default: 'auto'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
11-6
Code Generation Pane: RSim Target
Settings
Default: on
On
Forces the Simulink software to determine storage classes.
Off
Causes the model to retain storage class settings.
Tips
Command-Line Information
Parameter: RSIM_STORAGE_CLASS_AUTO
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
11-7
11 Configuration Parameters for Simulink Models
11-8
Code Generation Pane: S-Function Target
In this section...
“Code Generation S-Function Target Tab Overview” on page 11-10
“Create new model” on page 11-11
“Use value for tunable parameters” on page 11-12
“Include custom source code” on page 11-13
11-9
11 Configuration Parameters for Simulink Models
Configuration
This tab appears only if you specify the S-function target (rtwsfcn.tlc) as the “System
target file” on page 4-5.
See Also
11-10
Code Generation Pane: S-Function Target
Settings
Default: on
On
Creates a new model, separate from the current model, containing the generated S-
function block.
Off
Generates code but a new model is not created.
Command-Line Information
Parameter: CreateModel
Type: character vector
Value: 'on' | 'off'
Default: 'on'
See Also
11-11
11 Configuration Parameters for Simulink Models
Settings
Default: off
On
Uses variable values for tunable parameters instead of the variable name in the
generated block mask edit fields.
Off
Uses variable names for tunable parameters in the generated block mask edit fields.
Command-Line Information
Parameter: UseParamValues
Type: character vector
Value: 'on' | 'off'
Default: 'off'
See Also
11-12
Code Generation Pane: S-Function Target
Settings
Default: off
On
Include provided custom source code in the code generated for the S-function.
Off
Do not include custom source code in the code generated for the S-function.
Command-Line Information
Parameter: AlwaysIncludeCustomSrc
Type: character vector
Value: 'on' | 'off'
Default: 'off'
See Also
11-13
11 Configuration Parameters for Simulink Models
11-14
Code Generation Pane: Tornado Target
In this section...
“Code Generation: Tornado Target Tab Overview” on page 11-16
“Standard math library” on page 11-17
“Code replacement library” on page 11-19
“Shared code placement” on page 11-21
“MAT-file logging” on page 11-23
“MAT-file variable name modifier” on page 11-25
“Code Format” on page 11-26
“StethoScope” on page 11-27
“Download to VxWorks target” on page 11-29
“Base task priority” on page 11-31
“Task stack size” on page 11-32
“External mode” on page 11-33
“Transport layer” on page 11-35
“MEX-file arguments” on page 11-36
“Static memory allocation” on page 11-37
“Static memory buffer size” on page 11-39
11-15
11 Configuration Parameters for Simulink Models
Configuration
This tab appears only if you specify tornado.tlc as the “System target file” on page 4-5.
See Also
11-16
Code Generation Pane: Tornado Target
Settings
C89/C90 (ANSI)
Generates calls to the ISO/IEC 9899:1990 C standard math library.
C99 (ISO)
Generates calls to the ISO/IEC 9899:1999 C standard math library.
C++03 (ISO)
Generates calls to the ISO/IEC 14882:2003 C++ standard math library.
Tips
• The build process checks whether the specified standard math library and toolchain
are compatible. If they are not compatible, a warning occurs during code generation
and the build process continues.
• When you change the value of the Language parameter, the standard math library
updates to ISO/IEC 9899:1999 C (C99 (ISO)) for C and ISO/IEC 14882:2003 C++ (C
++03 (ISO)) for C++.
Dependencies
The C++03 (ISO) math library is available for use only if you select C++ for the
Language parameter.
Command-Line Information
Parameter: TargetLangStandard
Type: character vector
Value: 'C89/C90 (ANSI)' | 'C99 (ISO)' | 'C++03 (ISO)'
Default: 'C99 (ISO)'
Recommended Settings
Application Setting
Debugging No impact
11-17
11 Configuration Parameters for Simulink Models
Application Setting
Traceability No impact
Efficiency Valid library
Safety precaution No impact
See Also
11-18
Code Generation Pane: Tornado Target
Settings
Default: None
None
Does not use a code replacement library.
For more information about selections for this parameter, see “Code replacement library”
on page 9-6.
Tip
Before setting this parameter, verify that your compiler supports the library you want to
use. If you select a parameter value that your compiler does not support, compiler errors
can occur.
Command-Line Information
Parameter: CodeReplacementLibrary
Type: character vector
Value: 'None' | 'GNU C99 extensions' | 'Intel IPP for x86-64 (Windows)'
| 'Intel IPP/SSE for x86-64 (Windows)' | 'Intel IPP for x86-64
(Windows for MinGW compiler)' |'Intel IPP/SSE for x86-64 (Windows for
MinGW compiler)' | 'Intel IPP for x86/Pentium (Windows)' | 'Intel IPP/
SSE x86/Pentium (Windows)' | 'Intel IPP for x86-64 (Linux)' | 'Intel
IPP/SSE with GNU99 extensions for x86-64 (Linux)'
Default: 'None'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Valid library
Safety precaution No impact
11-19
11 Configuration Parameters for Simulink Models
See Also
11-20
Code Generation Pane: Tornado Target
Settings
Default: Auto
Auto
Operates as follows:
• When the model contains Model blocks, places utility code within the slprj/
target/_sharedutils folder.
• When the model does not contain Model blocks, places utility code in the build
folder (generally, in model.c or model.cpp).
Shared location
Directs code for utilities to be placed within the slprj folder in your working folder.
Command-Line Information
Parameter: UtilityFuncGeneration
Type: character vector
Value: 'Auto' | 'Shared location'
Default: 'Auto'
Recommended Settings
Application Setting
Debugging Shared location
Traceability Shared location
Efficiency No impact (execution, RAM)
Shared location (ROM)
Safety precaution No impact
See Also
11-21
11 Configuration Parameters for Simulink Models
11-22
Code Generation Pane: Tornado Target
MAT-file logging
Specify whether to enable MAT-file logging.
Settings
Default: off
On
Enables MAT-file logging. When you select this option, the generated code saves to
MAT-files simulation data specified in one of the following ways:
Off
Disables MAT-file logging. Clearing this option has the following benefits:
Dependencies
11-23
11 Configuration Parameters for Simulink Models
Limitation
MAT-file logging does not support file-scoped data, for example, data items to which you
apply the built-in custom storage class FileScope.
MAT-file logging does not work in a referenced model, and code is not generated to
implement it.
Command-Line Information
Parameter: MatFileLogging
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging On
Traceability No impact
Efficiency Off
Safety precaution Off
See Also
11-24
Code Generation Pane: Tornado Target
Settings
Default: rt_
rt_
Adds prefix text.
_rt
Adds suffix text.
none
Does not add text.
Dependency
If you have an Embedded Coder license, this parameter is enabled by MAT-file logging.
Command-Line Information
Parameter: LogVarNameModifier
Type: character vector
Value: 'none' | 'rt_' | '_rt'
Default: 'rt_'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
11-25
11 Configuration Parameters for Simulink Models
Code Format
Specify the code format (generated code features).
Settings
Default: RealTime
RealTime
Specifies the Real-Time code generation format.
RealTimeMalloc
Specifies the Real-Time Malloc code generation format.
Command-Line Information
Parameter: CodeFormat
Type: character vector
Value: 'RealTime' | 'RealTimeMalloc'
Default: 'RealTime'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
11-26
Code Generation Pane: Tornado Target
StethoScope
Specify whether to enable StethoScope, an optional data acquisition and data monitoring
tool.
Settings
Default: off
On
Enables StethoScope.
Off
Disables StethoScope.
Tips
You can optionally monitor and change the parameters of the executing real-time
program using either StethoScope or Simulink External mode, but not both with the
same compiled image.
Dependencies
Command-Line Information
Parameter: StethoScope
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging On
Traceability No impact
Efficiency Off
Safety precaution Off
11-27
11 Configuration Parameters for Simulink Models
See Also
11-28
Code Generation Pane: Tornado Target
Settings
Default: off
On
Automatically downloads the generated program to VxWorks after each build.
Off
Does not automatically download to VxWorks, you must downloaded generated
programs manually.
Tips
• Automatic download requires specifying the target name and host name in the
makefile.
• Before every build, reset VxWorks by pressing Ctrl+X on the host console or power-
cycling the VxWorks chassis. This clears dangling processes or stale data that exists
in VxWorks when the automatic download occurs.
Command-Line Information
Parameter: DownloadToVxWorks
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution Off
11-29
11 Configuration Parameters for Simulink Models
See Also
11-30
Code Generation Pane: Tornado Target
Settings
Default: 30
Tips
• For a multirate, multitasking model, the code generator increments the priority of
each subrate task by one.
• The value you specify for this option will be overridden by a base priority specified in
a call to the rt_main() function spawned as a task.
Command-Line Information
Parameter: BasePriority
Type: integer
Value: valid value
Default: 30
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Might impact efficiency, depending on other task's
priorities
Safety precaution No impact
See Also
11-31
11 Configuration Parameters for Simulink Models
Settings
Default: 16384
Command-Line Information
Parameter: TaskStackSize
Type: integer
Value: valid value
Default: 16384
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency Larger stack may waste space
Safety precaution Larger stack reduces the possibility of overflow
See Also
11-32
Code Generation Pane: Tornado Target
External mode
Specify whether to enable communication between the Simulink model and an
application based on a client/server architecture.
Settings
Default: on
On
Enables External mode. The client (Simulink model) transmits messages requesting
the server (application) to accept parameter changes or to upload signal data. The
server responds by executing the request.
Off
Disables External mode.
Dependencies
• Transport layer
• MEX-file arguments
• Static memory allocation
Command-Line Information
Parameter: ExtMode
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
11-33
11 Configuration Parameters for Simulink Models
See Also
11-34
Code Generation Pane: Tornado Target
Transport layer
Specify the transport protocol for External mode communications.
Settings
Default: tcpip
tcpip
Applies a TCP/IP transport mechanism. The MEX-file name is ext_comm.
Tip
The MEX-file name displayed next to Transport layer cannot be edited in the
Configuration Parameters dialog box. For targets provided by MathWorks, the value is
specified in matlabroot/toolbox/simulink/simulink/extmode_transports.m.
Dependency
Command-Line Information
Parameter: ExtModeTransport
Type: integer
Value: 0
Default: 0
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
“Target Interfacing”
11-35
11 Configuration Parameters for Simulink Models
MEX-file arguments
Specify arguments to pass to an External mode interface MEX-file for communicating
with executing targets.
Settings
Default: ''
Dependency
Command-Line Information
Parameter: ExtModeMexArgs
Type: character vector
Value: valid arguments
Default: ''
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
• “Target Interfacing”
• “Choose Communication Protocol for Client and Server”
11-36
Code Generation Pane: Tornado Target
Settings
Default: off
On
Enables the Static memory buffer size parameter for allocating allocate dynamic
memory.
Off
Uses a static memory buffer for External mode instead of allocating dynamic memory
(calls to malloc).
Tip
To determine how much memory you need to allocate, select verbose mode on the target
to display the amount of memory it tries to allocate and the amount of memory available.
Dependencies
Command-Line Information
Parameter: ExtModeStaticAlloc
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
11-37
11 Configuration Parameters for Simulink Models
See Also
11-38
Code Generation Pane: Tornado Target
Settings
Default: 1000000
Enter the number of bytes to preallocate for External mode communications buffers in
the target.
Tips
• If you enter too small a value for your application, External mode issues an out-of-
memory error.
• To determine how much memory you need to allocate, select verbose mode on the
target to display the amount of memory it tries to allocate and the amount of memory
available.
Dependency
Command-Line Information
Parameter: ExtModeStaticAllocSize
Type: integer
Value: valid value
Default: 1000000
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
11-39
11 Configuration Parameters for Simulink Models
In this section...
“Code Generation: Coder Target Pane Overview (previously “IDE Link Tab Overview”)”
on page 11-42
“Coder Target: Tool Chain Automation Tab Overview” on page 11-43
“Build format” on page 11-45
“Build action” on page 11-47
“Overrun notification” on page 11-50
“Function name” on page 11-52
“Configuration” on page 11-53
11-40
Code Generation: Coder Target Pane
In this section...
“Compiler options string” on page 11-55
“Linker options string” on page 11-56
“System stack size (MAUs)” on page 11-57
“Profile real-time execution” on page 11-59
“Profile by” on page 11-61
“Number of profiling samples to collect” on page 11-62
“Maximum time allowed to build project (s)” on page 11-64
“Maximum time allowed to complete IDE operation (s)” on page 11-65
“Export IDE link handle to base workspace” on page 11-65
“IDE link handle name” on page 11-67
“Source file replacement” on page 11-68
11-41
11 Configuration Parameters for Simulink Models
Code Generation: Coder Target Pane Overview (previously “IDE Link Tab
Overview”)
Configure the parameters for:
• Tool Chain Automation — How the code generator interacts with third-party software
build toolchains.
• Target Hardware Resources — The IDE toolchain and properties of the physical
hardware, such as board, operating system, memory, and peripherals.
See Also
11-42
Code Generation: Coder Target Pane
The Tool Chain Automation Tab is only visible under the Coder Target pane.
The following table lists the parameters on the Tool Chain Automation Tab.
11-43
11 Configuration Parameters for Simulink Models
11-44
Code Generation: Coder Target Pane
Build format
Defines how the code generator responds when you press Ctrl+B to build your model.
Settings
Default: Project
Project
Builds your model as an IDE project.
Makefile
Creates a makefile and uses it to build your model.
Dependencies
• Code Generation
Command-Line Information
Parameter: buildFormat
Type: character vector
Value: 'Project' | 'Makefile'
Default: 'Build_and_execute'
Recommended Settings
Application Setting
Debugging Project
11-45
11 Configuration Parameters for Simulink Models
Application Setting
Traceability Project
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-46
Code Generation: Coder Target Pane
Build action
Defines how the code generator responds when you press Ctrl+B to build your model.
Settings
Default: Build_and_execute
If you set Build format to Project, select one of the following options:
Build_and_execute
Builds your model, generates code from the model, and then compiles and links the
code. After the software links your compiled code, the build process downloads and
runs the executable on the processor.
Create_project
Directs the code generator to create a new project in the IDE. The command line
equivalent for this setting is Create.
Archive_library
Invokes the IDE Archiver to build and compile your project, but It does not run the
linker to create an executable project. Instead, the result is a library project.
Build
Builds a project from your model. Compiles and links the code. Does not download
and run the executable on the processor.
Create_processor_in_the_loop_project
Directs the code generator to create PIL algorithm object code as part of the project
build.
If you set Build format to Makefile, select one of the following options:
Create_makefile
Creates a makefile. For example, “.mk”. The command line equivalent for this setting
is Create.
Archive_library
Creates a makefile and an archive library. For example, “.a” or “.lib”.
Build
Creates a makefile and an executable. For example, “.exe”.
11-47
11 Configuration Parameters for Simulink Models
Build_and_execute
Creates a makefile and an executable. Then it evaluates the execute instruction
under the Execute tab in the current XMakefile configuration.
Dependencies
• Overrun notification
• Function name
• Profile real-time execution
• Number of profiling samples to collect
• Linker options string
• Get from IDE
• Reset
• Export IDE link handle to base workspace
• Overrun notification
• Function name
• Profile real-time execution
• Number of profiling samples to collect
• Linker options string
• Get from IDE
• Reset
• Export IDE link handle to base workspace with the option set to export the
handle
Command-Line Information
Parameter: buildAction
Type: character vector
Value: 'Build' | 'Build_and_execute' | 'Create' | 'Archive_library' |
'Create_processor_in_the_loop_project'
Default: 'Build_and_execute'
11-48
Code Generation: Coder Target Pane
Recommended Settings
Application Setting
Debugging Build_and_execute
Traceability Archive_library
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
For more information about PIL and its uses, refer to the “Verifying Generated Code via
Processor-in-the-Loop” topic.
11-49
11 Configuration Parameters for Simulink Models
Overrun notification
Specifies how your program responds to overrun conditions during execution.
Settings
Default: None
None
Your program does not notify you when it encounters an overrun condition.
Print_message
Your program prints a message to standard output when it encounters an overrun
condition.
Call_custom_function
When your program encounters an overrun condition, it executes a function that you
specify in Function name.
Tips
Dependencies
Command-Line Information
Parameter: overrunNotificationMethod
Type: character vector
Value: 'None' | 'Print_message' | 'Call_custom_function'
Default: 'None'
Recommended Settings
Application Setting
Debugging Print_message or Call_custom_function
Traceability Print_message
11-50
Code Generation: Coder Target Pane
Application Setting
Efficiency None
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-51
11 Configuration Parameters for Simulink Models
Function name
Specifies the name of a custom function your code runs when it encounters an overrun
condition during execution.
Settings
No Default
Dependencies
Command-Line Information
Parameter: overrunNotificationFcn
Type: character vector
Value: no default
Default: no default
Recommended Settings
Application Setting
Debugging String
Traceability String
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-52
Code Generation: Coder Target Pane
Configuration
Sets the Configuration for building your project from the model.
Settings
Default: Custom
Custom
Lets the user apply a specialized combination of build and optimization settings.
Custom applies the same settings as the Release project configuration in IDE, except:
Debug
Applies the Debug Configuration defined by the IDE to the generated project and
code.
Release
Applies the Release project configuration defined by the IDE to the generated
project and code.
Dependencies
• Selecting Custom disables the reset options for Compiler options string and
Linker options string.
• Selecting Release sets the Compiler options string to the settings defined by the
IDE.
• Selecting Debug sets the Compiler options string to the settings defined by the
IDE.
Command-Line Information
Parameter: projectOptions
Type: character vector
Value: 'Custom' | 'Debug' | 'Release'
Default: 'Custom'
11-53
11 Configuration Parameters for Simulink Models
Recommended Settings
Application Setting
Debugging Custom or Debug
Traceability Custom, Debug, Release
Efficiency Release
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-54
Code Generation: Coder Target Pane
Settings
Default: No default
Tips
Command-Line Information
Parameter: compilerOptionsStr
Type: character vector
Value: 'Custom' | 'Debug' | 'Release'
Default: 'Custom'
Recommended Settings
Application Setting
Debugging Custom
Traceability Custom
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-55
11 Configuration Parameters for Simulink Models
Settings
Default: No default
Tips
Dependencies
Command-Line Information
Parameter: linkerOptionsStr
Type: character vector
Value: valid linker option
Default: none
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-56
Code Generation: Coder Target Pane
This parameter is used in targets to allocate the stack size for the generated application.
For example, with embedded processors that are not running an operating system,
this parameter determines the total stack space that can be used for the application.
For operating systems such as Linux or Windows , this value specifies the stack space
allocated per thread.
This parameter also affects the “Maximum stack size (bytes)” (Simulink) parameter,
located in the Optimization > Signals and Parameters pane.
Settings
Default: 8192
Minimum: 0
• Enter the stack size in minimum addressable units (MAUs). An MAU is typically 1
byte, but its size can vary by target processor.
• The software does not verify the value you entered is valid.
Dependencies
When you set the System target file parameter on the Code Generation pane to
idelink_ert.tlc or idelink_grt.tlc, the software sets the Maximum stack size
parameter on the Optimization > Signals and Parameters pane to Inherit from
target and makes it non-editable. In that case, the Maximum stack size parameter
compares the value of (System stack size/2) with 200,000 bytes and uses the smaller of
the two values.
Command-Line Information
Parameter: systemStackSize
Type: int
Default: 8192
11-57
11 Configuration Parameters for Simulink Models
Recommended Settings
Application Setting
Debugging int
Traceability int
Efficiency int
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-58
Code Generation: Coder Target Pane
Settings
Default: Off
On
Adds instrumentation to the generated code to support execution profiling and
generate the profiling report.
Off
Does not instrument the generated code to produce the profile report.
Dependencies
This parameter adds Number of profiling samples to collect and Profile by.
Selecting this parameter enables Export IDE link handle to base workspace and
makes it non-editable, since the code generator must create a handle.
Command-Line Information
Parameter: ProfileGenCode
Type: character vector
Value: 'on' | 'off'
Default: 'off'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No impact
11-59
11 Configuration Parameters for Simulink Models
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
For more information about using profiling, refer to the “profile” and “Profiling Code
Execution in Real-Time” topics..
11-60
Code Generation: Coder Target Pane
Profile by
Defines which execution profiling technique to use.
Settings
Default: Task
Task
Profiles model execution by the tasks in the model.
Atomic subsystem
Profiles model execution by the atomic subsystems in the model.
Dependencies
Command-Line Information
Parameter: profileBy
Type: character vector
Value: Task | Atomic subsystem
Default: Task
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
For more information about PIL and its uses, refer to the “Verifying Generated Code via
Processor-in-the-Loop” topic.
For more information about using profiling, refer to the “profile” and “Profiling Code
Execution in Real-Time” topics.
11-61
11 Configuration Parameters for Simulink Models
Each task or subsystem execution instance represents one profiling sample. Each
sample requires two memory locations, one for the start time and one for the end time.
Consequently, the size of the buffer is twice the number of samples.
Sample collection begins with the start of code execution and ends when the buffer is full.
The profiling data is held in a statically sited buffer on the target processor.
Settings
Default: 100
Minimum: 2
Tips
• Data collection stops when the buffer is full, but the application and processor
continue running.
• Real-time task execution profiling works with hardware only. Simulators do not
support the profiling feature.
Dependencies
Command-Line Information
Parameter:ProfileNumSamples
Type: int
Value: Positive integer
Default: 100
Recommended Settings
Application Setting
Debugging 100
11-62
Code Generation: Coder Target Pane
Application Setting
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-63
11 Configuration Parameters for Simulink Models
Settings
Default: 1000
Minimum: 1
Maximum: No limit
Tips
• The build process continues even if MATLAB does not receive the completion message
in the allotted time.
• This timeout value does not depend on the global timeout value in a IDE_Obj object
or the Maximum time allowed to complete IDE operation timeout value.
Dependency
Command-Line Information
Parameter:ideObjBuildTimeout
Type: int
Value: Integer greater than 0
Default: 100
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-64
Code Generation: Coder Target Pane
Settings
Default: 10
Minimum: 1
Maximum: No limit
Tips
• The IDE operation continues even if MATLAB does not receive the message in the
allotted time.
• This timeout value does not depend on the global timeout value in a IDE_Obj object
or the Maximum time allowed to build project (s) timeout value
Command-Line Information
Parameter:'ideObjTimeout'
Type: int
Value:
Default: 10
Recommended Settings
Application Setting
Debugging No impact
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-65
11 Configuration Parameters for Simulink Models
Settings
Default: On
On
Directs the build process to export the IDE_Obj object created to your MATLAB
workspace. The new object appears in the workspace browser. Selecting this option
enables the IDE link handle name option.
Off
prevents the build process from exporting the IDE_Obj object to your MATLAB
software workspace.
Dependency
Selecting Profile real-time execution enables Export IDE link handle to base
workspace and makes it non-editable, since the code generator must create a handle.
Selecting Export IDE link handle to base workspace enables IDE link handle
name.
Command-Line Information
Parameter: exportIDEObj
Type: character vector
Value: 'on' | 'off'
Default: 'on'
Recommended Settings
Application Setting
Debugging On
Traceability On
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-66
Code Generation: Coder Target Pane
Settings
Default: IDE_Obj
Dependency
Command-Line Information
Parameter: ideObjName
Type: character vector
Value:
Default: IDE_Obj
Recommended Settings
Application Setting
Debugging Enter a valid C program variable name, without
spaces
Traceability No impact
Efficiency No impact
Safety precaution No impact
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-67
11 Configuration Parameters for Simulink Models
Settings
Default: warn
none
Does not generate warnings or errors when it finds conflicts.
warning
Displays a warning.
error
Terminates the build process and displays an error message that identifies which file
has the problem and suggests how to resolve it.
Tips
• The build operation continues if you select warning and the software detects custom
code replacement. You see warning messages as the build progresses.
• Select error the first time you build your project after you specify custom code to
use. The error messages can help you diagnose problems with your custom code
replacement files.
• Select none when you do not want to see multiple messages during your build.
• The messages apply to code generator Custom Code replacement options as well.
Command-Line Information
Parameter: DiagnosticActions
Type: character vector
Value: none | warning | error
Default: warning
Recommended Settings
Application Setting
Debugging error
Traceability error
11-68
Code Generation: Coder Target Pane
Application Setting
Efficiency warning
Safety precaution error
See Also
For more information, refer to the “Code Generation Pane: Coder Target” topic.
11-69
11 Configuration Parameters for Simulink Models
In this section...
“Code Generation Pane” on page 11-71
“Scheduler options” on page 11-72
“Build Options” on page 11-73
“Clocking” on page 11-74
“I2C0 and I2C1” on page 11-75
“Timer/PWM” on page 11-77
“UART0, UART1, and UART2” on page 11-78
“PIL” on page 11-80
“External mode” on page 11-81
11-70
Hardware Implementation Pane
11-71
11 Configuration Parameters for Simulink Models
Scheduler options
Scheduler interrupt source
Select the source of the scheduler interrupt.
11-72
Hardware Implementation Pane
Build Options
To specify how the build process takes place during code generation, select build options.
Build action
Specify whether you want only a build action or build, load, and run actions during
code generation.
• Build — Select this option if you want to build the code during the build process.
• Build, load and run — Select this option to build, load, and run the
generated code during the build process.
11-73
11 Configuration Parameters for Simulink Models
Clocking
Note: This parameter appears dimmed. The value of this parameter is set to 48 MHz.
11-74
Hardware Implementation Pane
SCL Pin
Select an SCL pin for I2C communication.
I2C0
Default: PTB0
I2C1
Default: PTE1
I2C0
11-75
11 Configuration Parameters for Simulink Models
Default: PTB1
I2C1
Default: PTE0
11-76
Hardware Implementation Pane
Timer/PWM
Default: 4166 Hz
TPM1 Frequency (in Hz)
Specify the frequency for the TPM1 timer.
Default: 50 Hz
TPM2 Frequency (in Hz)
Specify the frequency for the TPM2 timer.
Default: 4166 Hz
11-77
11 Configuration Parameters for Simulink Models
Default: 115200
Tx Pin
Select a Tx pin for serial communication.
UART0
UART1
Default: PTC4
11-78
Hardware Implementation Pane
UART2
Default: PTD5
UART0
UART1
Default: PTC3
UART2
Default: PTD4
11-79
11 Configuration Parameters for Simulink Models
PIL
Default: UART0
Serial port
Enter the serial port for PIL communication.
Default: COM1
11-80
Hardware Implementation Pane
External mode
Communication interface
Use the serial option to run your model in the external mode with serial
communication.
Default: serial
Select hardware UART
Select the target UART port for external mode communication. After selecting an
UART port, go to the selected UART in Configuration Parameters > Hardware
Implementation pane > UARTx and select the Tx and the Rx pins.
Default: UART0
Note: The target UART0 port for external mode communication works only in
Windows and Mac OS X El Capitan operating systems.
Serial port
11-81
11 Configuration Parameters for Simulink Models
Default: COM27
Verbose
Select this check box to view the external mode execution progress and updates in the
Diagnostic Viewer or in the MATLAB Command Window.
11-82
Hardware Implementation Pane
11-83
11 Configuration Parameters for Simulink Models
Configuration
3 Set the Hardware board parameter to match your target hardware board.
4 Apply the changes.
11-84
Hardware Implementation Pane
Build options
To specify how the build process takes place during code generation, select build options.
Build action
Specify whether you want only a build action or build, load, and run actions during
code generation.
• Build — Select this option if you want to build the code during the build process.
• Build, load and run — Select this option to build, load, and run the
generated code during the build process.
Firmware
This is the firmware chosen during the setup to run your model on the FRDM-K64F
board.
11-85
11 Configuration Parameters for Simulink Models
Clocking
Note: This parameter appears dimmed. The value of this parameter is set to 120
MHz.
11-86
Hardware Implementation Pane
DAC
Default: DACREF_1
DACREF_2
11-87
11 Configuration Parameters for Simulink Models
Default: 115200
Tx Pin
Specify a transmitting pin of UARTx.
UART0
UART1
11-88
Hardware Implementation Pane
No connection
UART2
No connection
UART3
UART0
UART1
No connection
UART2
No connection
UART3
11-89
11 Configuration Parameters for Simulink Models
Default: None
Even, Odd
Stop bits
Select the number of Stop bits used to indicate end of a packet.
Default: 1
11-90
Hardware Implementation Pane
Ethernet
Default: FRDM_K64F
MAC address
Specify the Media Access Control (MAC) address, the physical network address of the
board.
Under most circumstances, you do not need to change the MAC address. If you
connect more than one board to a single computer so that each address is unique,
change the MAC address. (You must have a separate network interface card (NIC)
for each board.)
To change the MAC address, specify an address that is different from the address
that belongs to any other device attached to your computer. To obtain the MAC
11-91
11 Configuration Parameters for Simulink Models
address for a specific board, refer to the label affixed to the board or consult the
product documentation.
The MAC address must be in the six octet format. For example, DE-AD-BE-EF-FE-
ED
Default: 00-CF-52-35-00-01
Enable DHCP for local IP address assignment
Select this check box to configure the board to get an IP address from the local DHCP
server on the network.
Default: off
on
Board IP address
Use this option for setting the IP address of the board. Change the IP address of your
computer to a different subnet when you set up the network adapter. You would need
to change the address if the default board IP address is in use by another device.
• The subnet address, typically the first 3 bytes of the board IP address, must be
the same as those of the host IP address.
• The last byte of the board IP address must be different from the last byte of the
host IP address.
• The board IP address must not conflict with the IP addresses of other computers.
For example, if the host IP address is 192.168.8.2, then you can use
192.168.8.3, if available.
Default: 192.168.1.102
Subnet mask
Specify the subnet mask for the board. The subnet mask is a mask that designates a
logical subdivision of a network.
The value of the subnet mask must be the same for all devices on the network.
Default: 255.255.255.0
11-92
Hardware Implementation Pane
Gateway
Set the serial gateway to the gateway required to access the target computer.
For example, when you set this parameter to 255.255.255.255, it means that
you do not use a gateway to connect to your target computer. If you connect your
computers with a crossover cable, leave this property as 255.255.255.255.
If you communicate with the target computer from within your LAN, you do not need
not change this setting.
If you communicate from a host located in a LAN different from your target computer
(especially via the Internet), you must define a gateway and specify its IP address in
this parameter.
Default: 192.168.1.1
11-93
11 Configuration Parameters for Simulink Models
External mode
Communication interface
Use the serial option to run your model in the external mode with serial
communication.
Default: Serial
Baudrate
Specify the baud for UARTx serial interfaces.
Default: 115200
Verbose
Select this check box to view the external mode execution progress and updates in the
Diagnostic Viewer or in the MATLAB Command Window.
11-94
Hardware Implementation Pane
11-95
11 Configuration Parameters for Simulink Models
11-96
Hardware Implementation Pane
Hardware board
Select the type of hardware upon which to run your model.
After installing support for your target hardware, reopen the Configuration Parameters
dialog and select your target hardware.
To run the model on your VEX device, select ARM Cortex-based VEX
Microcontroller.
Settings
Default: None
None
This setting means your model has not been configured to run on target hardware.
Choose your target hardware from the list of options.
Get more...
Select this option to start Support Package Installer and install support for
additional hardware.
11-97
11 Configuration Parameters for Simulink Models
Clocking
11-98
Hardware Implementation Pane
Build options
Build action
This is the option to specify, if you want only build action, or build, load and run
actions during code generation.
• Build, load and run — Select this option to build, load, and to run the
generated code.
• Build — Select this option to only build the code.
11-99
11 Configuration Parameters for Simulink Models
External mode
Communication interface
The ‘serial’ option uses serial communication for external mode.
Set host COM port
• Automatically — Select this option to set the host COM port automatically.
This is the default option.
• Manually — Select this option to manually set the host COM port.
COMPort
Enter the COMPort used by the target hardware. This parameter appears, only if you
have selected Manually option in the Set host COM port parameter.
Verbose
11-100
Hardware Implementation Pane
Select this check box to view the External Mode execution progress and updates in
the Diagnostic Viewer or in the MATLAB command window.
11-101
11 Configuration Parameters for Simulink Models
In this section...
“Hardware Implementation Pane Overview” on page 11-103
“Build options” on page 11-104
“Clocking” on page 11-106
“I2C” on page 11-107
“PIL” on page 11-108
“SPI” on page 11-109
“External mode” on page 11-110
11-102
Hardware Implementation Pane
11-103
11 Configuration Parameters for Simulink Models
Build options
Use the build option to specify how the build process should take place during code
generation.
Build action
Specify if you want only build or build, load and run actions during code generation.
• Build – Select this option if you want to build the code during the build process.
• Build, load and run – Select this option to build, load, and to run the
generated code during the build process.
11-104
Hardware Implementation Pane
11-105
11 Configuration Parameters for Simulink Models
Clocking
Use the clocking option to achieve the CPU Clock rate specified.
11-106
Hardware Implementation Pane
I2C
11-107
11 Configuration Parameters for Simulink Models
PIL
11-108
Hardware Implementation Pane
SPI
11-109
11 Configuration Parameters for Simulink Models
External mode
Communication interface
Use the ‘serial’ option to run your model in the External mode with serial
communication.
Serial port
Enter the serial port used by the target hardware.
Verbose
Select this check box to view the External Mode execution progress and updates in
the Diagnostic Viewer or in the MATLAB command window.
11-110
Recommended Settings Summary for Model Configuration Parameters
For parameters that are available only when an ERT target is specified, see
“Recommended Settings Summary for Model Configuration Parameters” (Embedded
Coder).
For additional details, click the links in the Configuration Parameter column.
11-111
11 Configuration Parameters for Simulink Models
Off (for
production
code
generation)
11-112
Recommended Settings Summary for Model Configuration Parameters
11-113
11 Configuration Parameters for Simulink Models
Off
(otherwise)
Application No impact No impact Finite inf auto
lifespan (days) value
(Simulink)
Use floating- No impact No impact On (when No Off
point target recommendation
multiplication hardware
to handle net supports
slope corrections efficient
(Simulink) multiplication)
Off
(otherwise)
Remove code Off Off On No Off
from floating- (execution, recommendation
point to integer ROM)
conversions that
wraps out-of- No impact
range values (RAM)
(Simulink)
*The command-line value is reverse of the listed value.
Mapping Application Requirements to the Optimization Pane: Signals and Parameters Tab
11-114
Recommended Settings Summary for Model Configuration Parameters
11-115
11 Configuration Parameters for Simulink Models
On (RAM)
11-116
Recommended Settings Summary for Model Configuration Parameters
11-117
11 Configuration Parameters for Simulink Models
11-118
Recommended Settings Summary for Model Configuration Parameters
11-119
11 Configuration Parameters for Simulink Models
11-120
Recommended Settings Summary for Model Configuration Parameters
11-121
11 Configuration Parameters for Simulink Models
11-122
Recommended Settings Summary for Model Configuration Parameters
none (for
production
code
generation)
“Unexpected warning No impact No impact error warning
backtracking”
(Simulink)
“Invalid input warning No impact No impact error warning
data access
in chart
initialization”
(Simulink)
“No warning No impact No impact error warning
unconditional (for
default simulation
transitions” and during
(Simulink) development)
none (for
production
code
generation)
“Transition warning No impact No impact error warning
outside natural (for
parent” simulation
(Simulink) and during
development)
11-123
11 Configuration Parameters for Simulink Models
11-124
Recommended Settings Summary for Model Configuration Parameters
11-125
11 Configuration Parameters for Simulink Models
11-126
Recommended Settings Summary for Model Configuration Parameters
11-127
11 Configuration Parameters for Simulink Models
11-128
Recommended Settings Summary for Model Configuration Parameters
11-129
11 Configuration Parameters for Simulink Models
If you use
the Never
setting,
11-130
Recommended Settings Summary for Model Configuration Parameters
11-131
11 Configuration Parameters for Simulink Models
11-132
Recommended Settings Summary for Model Configuration Parameters
Mapping Application Requirements to the Simulation Target Pane: Custom Code Tab
Configuration Settings for Building Code Factory Default
Parameter Debugging Traceability Efficiency Safety
precaution
“Parse custom On No impact No impact On On
code symbols”
(Simulink)
“Source file” No No No No ''
(Simulink) recommendation
recommendation
recommendation
recommendation
“Header file” No No No No ''
(Simulink) recommendation
recommendation
recommendation
recommendation
“Initialize No No No No ''
function” recommendation
recommendation
recommendation
recommendation
(Simulink)
“Terminate No No No No ''
function” recommendation
recommendation
recommendation
recommendation
(Simulink)
“Include No impact No impact No impact No ''
directories” recommendation
(Simulink)
“Source files” No impact No impact No impact No ''
(Simulink) recommendation
“Libraries” No impact No impact No impact No ''
(Simulink) recommendation
“Defines” No impact No impact No impact No ''
(Simulink) recommendation
11-133
11 Configuration Parameters for Simulink Models
ERT based
(ERT)
Language No impact No impact No impact No impact C
Compiler OptimizationsNo impact
OptimizationsOptimizations Optimizations
optimization off (faster off on (faster off (faster
level builds) (faster runs) builds)
builds) (execution)
No impact
(ROM, RAM)
Custom OptimizationsNo impact
OptimizationsOptimizations Optimizations
compiler off (faster off on (faster off (faster
optimization builds) (faster runs) builds)
flags builds)
Generate No impact No impact No impact No impact On
makefile
Make command No impact No impact No impact No make_rtw
recommendation
Template No impact No impact No impact No impact grt_default_tmf
makefile
“Select Debugging Not Execution No Unspecified
objective” on applicable for efficiency recommendation
page 4-28 GRT-based
targets
“Check On (proceed On On (proceed On Off
model before with (proceed with (proceed
generating warnings) with warnings) with
code” on page or On warnings) or On warnings)
4-36 (stop for or On (stop for or On
warnings) warnings)
11-134
Recommended Settings Summary for Model Configuration Parameters
11-135
11 Configuration Parameters for Simulink Models
Mapping Application Requirements to the Code Generation Pane: Custom Code Tab
11-136
Recommended Settings Summary for Model Configuration Parameters
Mapping Application Requirements (for Debugging) to the All Parameters Tab: Code Generation Category
11-137
11 Configuration Parameters for Simulink Models
No impact
(RAM)
Code interface No impact No impact Reusable No impact Nonreusable
packaging on page function function if
9-24 or C++ Language is set
class to C; C++ class if
Language is set to C
++
Multi-instance Warning or No impact None No impact Error
code error Error
diagnostic on page
9-28
Classic call No impact Off Off No Off (except On for
interface on page (execution, recommendationGRT models created
10-37 ROM), No before R2012a)
impact
(RAM)
11-138
Recommended Settings Summary for Model Configuration Parameters
Off (ERT)
MAT-file variable No impact No impact No impact No impact rt_
name modifier
Generate C API No impact No impact No impact No impact Off
for: signals (development)
Off
(production)
Generate C API No impact No impact No impact No impact Off
for: parameters (development)
Off
(production)
Generate C API No impact No impact No impact No impact Off
for: states (development)
Off
(production)
Generate C API No impact No impact No impact No impact Off
for: root-level I/O (development)
Off
(production)
ASAP2 interface No impact No impact No impact No impact Off
(development)
Off
(production)
External mode No impact No impact No impact No impact Off
(development)
11-139
11 Configuration Parameters for Simulink Models
11-140
12
12-2
Simulink Coder Checks
See Also
12-3
12 Model Advisor Checks
Description
Zero-based indexing is more efficient in the generated code than one-based indexing.
You can:
See Also
12-4
Simulink Coder Checks
Description
Incorrect configuration settings can stop the code generator from producing code.
Underspecifying sample times can lead to undesired results. Avoid generating code that
might corrupt data or produce unpredictable behavior.
Tips
You do not have to modify the solver settings to generate code from a subsystem. The
build process automatically changes Solver type to fixed-step when you select Code
Generation > Build Subsystem or Code Generation > Generate S-Function from
the subsystem context menu.
12-5
12 Model Advisor Checks
See Also
12-6
Simulink Coder Checks
Description
This check partially identifies model constructs that are not suited for code generation
as identified in the Simulink Block Support tables for Simulink Coder and Embedded
Coder. If you are using blocks with support notes for code generation, review the
information and follow the given advice.
You can:
See Also
12-7
12 Model Advisor Checks
Description
Checks whether the model uses the template makefile approach or the toolchain
approach to build the generated code.
When you open a model created before R2013b that has System target file set to
ert.tlc, ert_shrlib.tlc, or grt.tlc the software automatically tries to upgrade the
model from using the template makefile approach to using the toolchain approach.
If the software did not upgrade the model, this check determines the cause, and if
available, recommends actions you can perform to upgrade the model.
To determine which approach your model is using, you can also look at the Code
Generation pane in the Configuration Parameters dialog box. The toolchain approach
uses the following parameters to build generated code:
The template makefile approach uses the following settings to build generated code:
12-8
Simulink Coder Checks
Action Results
Clicking Update model upgrades the model to use the toolchain approach to build
generated code.
12-9
12 Model Advisor Checks
See Also
12-10
Simulink Coder Checks
Check and update embedded target model to use ert.tlc system target file
Check ID: mathworks.codegen.codertarget.check
Check and update the embedded target model to use ert.tlc system target file.
Description
Check and update models whose System target file is set to idelink_ert.tlc
or idelink_grt.tlc and whose target hardware is one of the supported Texas
Instruments C2000™ processors to use ert.tlc and similar settings.
Action Results
Clicking Update model automatically sets the following parameters on the Code
Generation pane in the model Configuration Parameters dialog box:
This action also sets the parameters on the Coder Target pane to match the previous
parameter values under the Peripherals tab.
The new workflow uses the toolchain approach, which relies on enhanced makefiles to
build generated code. It does not provide an equivalent to setting the Build format
12-11
12 Model Advisor Checks
parameter to Project in the previous configuration. Therefore, the new workflow cannot
automatically generate IDE projects within the CCS 3.3 IDE.
See Also
“Toolchain Configuration”
12-12
Simulink Coder Checks
Check and update models that are using targets that have changed
significantly across different releases of MATLAB
Check ID:
mathworks.codegen.realtime2CoderTargetInfoUpgradeAdvisor.check
Check and update models with Simulink targets that have changed significantly across
different releases of MATLAB.
Description
Save a model that you have updated to work with the current installation of MATLAB.
Action Results
Clicking Save model updates the model to work with the current installation of
MATLAB and saves the model.
12-13
12 Model Advisor Checks
See Also
12-14
Simulink Coder Checks
Description
Lookup Table blocks have strict constraints when they are tunable. If you violate lookup
table block restrictions, the generated code produces incorrect answers.
12-15
12 Model Advisor Checks
If you have a Simulink Verification and Validation license, you can exclude blocks and
charts from this check.
See Also
12-16
Simulink Coder Checks
Identify referenced model configuration parameter settings that do not match the top
model configuration parameter settings.
Description
The code generator cannot create code for top models that contain referenced models with
different, incompatible configuration parameter settings.
See Also
12-17
12 Model Advisor Checks
Set up the sample time and tasking mode for your system.
Description
Incorrect tasking mode can result in inefficient code execution or incorrect generated
code.
See Also
Check for code generation identifier formats used for model reference
Check ID: mathworks.codegen.ModelRefRTWConfigCompliance
Checks for referenced models in a model referencing hierarchy for which code generation
changes configuration parameter settings that involve identifier formats.
Description
12-18
Simulink Coder Checks
the name of the reference model), code generation prepends the $R token to the identifier
format.
• Global variables
• Global types
• Subsystem methods
• Constant macros
12-19
12 Model Advisor Checks
The Code Generation Advisor includes the following checks from Simulink, Simulink
Coder, and Embedded Coder for each of the code generation objectives. Two checks
unique to the Code Generation Advisor are included below the list.
12-20
Simulink Coder Checks
12-21
12 Model Advisor Checks
12-22
Simulink Coder Checks
12-23
12 Model Advisor Checks
12-24
Simulink Coder Checks
Note: When the Code Generation Advisor checks your model against the MISRA C:2012
guidelines objective, the tool does not consider all of the configuration parameter settings
that are checked by the MISRA C:2012 guidelines checks in the Model Advisor. For a
complete check of configuration parameter settings, run the checks under the By Task >
Modeling Guidelines for MISRA C:2012 node in the Model Advisor.
See Also
12-25
12 Model Advisor Checks
Description
The code generator creates code only for the blocks that it supports. Some blocks are not
recommended for production code deployment.
You can:
See Also
12-26
Simulink Coder Checks
Description
Each parameter in the Configuration Parameters dialog box might have different
recommended settings for code generation based on your objectives. This check helps you
identify the recommended setting for each parameter so that you can achieve optimized
code based on your objective.
Action Results
See Also
12-27
12 Model Advisor Checks
The Code Generation Advisor includes the following checks from Simulink, Simulink
Coder, and Embedded Coder for each of the code generation objectives. Two checks
unique to the Code Generation Advisor are included below the list.
12-28
Code Generation Advisor Checks
12-29
12 Model Advisor Checks
12-30
Code Generation Advisor Checks
12-31
12 Model Advisor Checks
12-32
Code Generation Advisor Checks
Note: When the Code Generation Advisor checks your model against the MISRA C:2012
guidelines objective, the tool does not consider all of the configuration parameter settings
that are checked by the MISRA C:2012 guidelines checks in the Model Advisor. For a
complete check of configuration parameter settings, run the checks under the By Task >
Modeling Guidelines for MISRA C:2012 node in the Model Advisor.
12-33
12 Model Advisor Checks
See Also
Description
The code generator creates code only for the blocks that it supports. Some blocks are not
recommended for production code deployment.
You can:
12-34
Code Generation Advisor Checks
• Exclude blocks and charts from this check if you have a Simulink Verification and
Validation license.
See Also
Description
Each parameter in the Configuration Parameters dialog box might have different
recommended settings for code generation based on your objectives. This check helps you
identify the recommended setting for each parameter so that you can achieve optimized
code based on your objective.
Action Results
See Also
12-35
12 Model Advisor Checks
12-36
13
In this section...
“Create Protected Model: Overview” on page 13-2
“Open read-only view of model” on page 13-4
“Simulate” on page 13-5
“Use generated code” on page 13-6
“Code interface” on page 13-7
“Content type” on page 13-8
“Create protected model in” on page 13-8
“Create harness model for protected model” on page 13-10
13-2
Create Protected Model
To open the Create Protected Model dialog box, right-click the model block that
references the model for which you want to generate protected model code. From the
context menu, select Subsystem & Model Reference > Create Protected Model for
Selected Model Block.
See Also
13-3
13 Parameters for Creating Protected Models
Settings
Default: Off
On
Share a Web view of the protected model. For password protection, create and verify
a password with a minimum of four characters.
Off
Do not share a Web view of the protected model.
Alternatives
Simulink.ModelReference.protect
See Also
13-4
Create Protected Model
Simulate
Allow user to simulate a protected model with optional password protection. Selecting
Simulate:
Settings
Default: On
On
User can simulate the protected model. For password protection, create and verify a
password with a minimum of four characters.
Off
User cannot simulate the protected model.
Alternatives
Simulink.ModelReference.protect
See Also
13-5
13 Parameters for Creating Protected Models
• Enables Simulation Report and Code Generation Report for the protected model.
• Enables code generation.
• Enables support for simulation.
Settings
Default: Off
On
User can generate code for the protected model. For password protection, create and
verify a password with a minimum of four characters.
Off
User cannot generate code for the protected model.
Dependencies
• To generate code, you must also select the Simulate check box.
• This parameter enables Code interface and Content type.
Alternatives
Simulink.ModelReference.protect
See Also
13-6
Create Protected Model
Code interface
Specify the interface for the generated code.
Settings
Model reference
Specifies the model reference interface, which allows use of the protected model
within a model reference hierarchy. Users of the protected model can generate code
from a parent model that contains the protected model. In addition, users can run
Model block software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulations to
verify code.
Top model
Specifies the standalone interface. Users of the protected model can run Model block
SIL or PIL simulations to verify the protected model code.
Dependencies
Alternatives
Simulink.ModelReference.protect
See Also
13-7
13 Parameters for Creating Protected Models
Content type
Select the appearance of the generated code.
Settings
Binaries
Includes only binaries for the generated code.
Obfuscated source code
Includes obfuscated headers and binaries for the generated code.
Readable source code
Includes readable source code.
Dependencies
This parameter is enabled by selecting the Use generated code check box.
Alternatives
Simulink.ModelReference.protect
See Also
Settings
Dependencies
13-8
Create Protected Model
Alternatives
Simulink.ModelReference.protect
See Also
13-9
13 Parameters for Creating Protected Models
Settings
Default: Off
On
Create a harness model for the protected model.
Off
Do not create a harness model for the protected model.
Alternatives
Simulink.ModelReference.protect
See Also
• “Harness Model”
• “Test the Protected Model”
13-10
14
Description
The Code Replacement Viewer displays the content of code replacement libraries. Use
the tool to explore and choose a library. If you develop a custom code replacement library,
use the tool to verify table entries.
If you specify a library name when you open the viewer, the viewer displays the code
replacement tables that the library contains. When you select a code replacement table,
the viewer displays function and operator code replacement entries that are in that table.
Field Description
Name Name or identifier of the function or operator being replaced
(for example, cos or RTW_OP_ADD).
Implementation Name of the implementation function, which can match or
differ from Name.
NumIn Number of input arguments.
In1Type Data type of the first conceptual input argument.
In2Type Data type of the second conceptual input argument.
OutType Data type of the conceptual output argument.
14-2
Code Replacement Viewer
Field Description
Priority The entry's match priority, relative to other entries of the
same name and to the conceptual argument list within the
selected code replacement library. The priority can range from
0 to 100, with 0 being the highest priority. The default is 100.
If the library provides two implementations for a function
or operator, the implementation with the higher priority
shadows the one with the lower priority.
UsageCount Not used.
Field Description
Description Text description of the table entry (can be empty).
Key Name or identifier of the function or operator being replaced (for
example, cos or RTW_OP_ADD), and the number of conceptual
input arguments.
Implementation Name of the implementation function, and the number of
implementation input arguments.
Implementation Type of implementation: FCN_IMPL_FUNCT for function or
type FCN_IMPL_MACRO for macro.
Saturation mode Saturation mode that the implementation function supports. One
of:
RTW_SATURATE_ON_OVERFLOW
RTW_WRAP_ON_OVERFLOW
RTW_SATURATE_UNSPECIFIED
Rounding modes Rounding modes that the implementation function supports. One
or more of:
RTW_ROUND_FLOOR
RTW_ROUND_CEILING
RTW_ROUND_ZERO
RTW_ROUND_NEAREST
RTW_ROUND_NEAREST_ML
RTW_ROUND_SIMPLEST
14-3
14 Tools — Alphabetical List
Field Description
RTW_ROUND_CONV
RTW_ROUND_UNSPECIFIED
GenCallback file Not used.
Implementation Name of the header file that declares the implementation function.
header
Implementation Name of the implementation source file.
source
Priority The entry's match priority, relative to other entries of the same
name and to the conceptual argument list within the selected
code replacement library. The priority can range from 0 to 100,
with 0 being the highest priority. The default is 100. If the library
provides two implementations for a function or operator, the
implementation with the higher priority shadows the one with the
lower priority.
Total Usage Not used.
Count
Entry class Class from which the current table entry is instantiated.
Conceptual Name, I/O type (RTW_IO_OUTPUT or RTW_IO_INPUT), and data
arguments type for each conceptual argument.
Implementation Name, I/O type (RTW_IO_OUTPUT or RTW_IO_INPUT), data type,
and alignment requirement for each implementation argument.
Field Description
Net slope Slope adjustment factor (F) part of the net slope factor, F2E ,
adjustment factor for net slope table entries. You use this factor with fixed-point
F multiplication and division replacement to map a range of slope
and bias values to a replacement function.
Net fixed exponent Fixed exponent (E) part of the net slope factor, F2E, for net
E slope table entries. You use this fixed exponent with fixed-point
14-4
Code Replacement Viewer
Field Description
multiplication and division replacement to map a range of slope
and bias values to a replacement function.
Slopes must be the Indicates whether code replacement request processing must
same check that the slopes on arguments (input and output) are
equal. You use this information with fixed-point addition and
subtraction replacement to disregard specific slope and bias
values, and map relative slope and bias values to a replacement
function.
Must have zero net Indicates whether code replacement request processing
bias must check that the net bias on arguments is zero. You use
this information with fixed-point addition and subtraction
replacement to disregard specific slope and bias values, and map
relative slope and bias values to a replacement function.
Examples
Display Contents of Code Replacement Library
crviewer('ARM Cortex-A')
14-5
14 Tools — Alphabetical List
crviewer(clr_table_ne10)
14-6
Code Replacement Viewer
Programmatic Use
crviewer(library) opens the Code Replacement Viewer and displays the contents of
library, where library is a character vector that names a registered code replacement
library. For example, 'GNU 99 extensions'.
crviewer(table) opens the Code Replacement Viewer and displays the contents of
table, where table is a MATLAB file that defines code replacement tables. The file
must be in the current folder or on the MATLAB path.
See Also
Topics
“Choose a Code Replacement Library”
14-7
14 Tools — Alphabetical List
Introduced in R2014b
14-8