Main Content

Code Generation Configuration Sets

Configure models for simulation and code generation

The model configuration parameters for code generation define how the code generator produces code and builds an executable from your model.

Model Settings

expand all

Shared coder dictionaryEmbedded Coder Dictionary that contains code interface configuration for code generation (Since R2022b)
Generate Halide codeGenerate Halide code for faster array computation (Since R2023b)
Prioritized objectivesPrioritized list of Code Generation Advisor objectives to apply for reviewing model configuration parameter settings

Data initialization

Remove root level I/O zero initializationControl generation of initialization code for root-level inports and outports set to zero
Remove internal data zero initializationControl generation of Initialization code for internal work structures, such as block states and block outputs, to zero

Optimization levels

LevelOptimization level for generated code
PriorityControl application of optimizations based on priority
Specify custom optimizationsEnable option to choose individual optimization parameters
Simplify array indexingReplace multiply operations in array indices when accessing arrays in a loop
Generate parallel for-loopsOptimization for parallel for-loops (Since R2019a)
Pack Boolean data into bitfieldsControl storing Boolean signals
Reuse buffers of different sizes and dimensionsReuse buffers to store data of different sizes and dimensions
Optimize global data accessOptimize global variable usage
Optimize block operation order in generated codeSpecify to reorder block operations for improved code execution speed
Reuse global block outputsOptimization to reuse global variables
Reuse output buffers of Model blocksReuse referenced model buffers if possible (Since R2022b)
Perform in-place updates for Assignment and Bus Assignment blocksReuse the input and output variables of Bus Assignment and Assignment blocks
Reuse buffers for Data Store Read and Data Store Write blocksEliminate temporary buffers for Data Store Read and Data Store Write blocks
Bitfield declarator type specifierSpecify bitfield type
Pass reusable subsystem outputs asControl how a reusable subsystem passes outputs

Advanced parameters

Optimize using the specified minimum and maximum valuesOptimize using minimum and maximum values for signals and parameters
Remove Code from Tunable Parameter Expressions That Saturate Out-of-Range ValuesControl generation of protective code that saturates out-of-range tunable parameter expression values (Since R2019b)
Remove code that protects against division arithmetic exceptionsControl generation of protective code for division arithmetic exceptions
Use signal labels to guide buffer reuseReuse buffers by using signal labels
Operator to represent Bitwise and Logical Operator blocksSpecify operator type in generated code (Since R2020a)
Code-to-modelInclude hyperlinks in the code generation report that link to the model diagram
Model-to-codeEnable code highlighting in the code generation report when you click on Simulink blocks, Stateflow objects, and MATLAB functions
Eliminated / virtual blocksInclude a summary of eliminated and virtual blocks in the code generation report
Traceable Simulink blocksInclude a summary of Simulink blocks and the corresponding code locations in the code generation report
Traceable Stateflow objectsInclude a summary of Stateflow objects and the corresponding code locations in the code generation report
Traceable MATLAB functionsInclude a summary of MATLAB functions and corresponding code locations in the code generation report
Summarize which blocks triggered code replacementsInclude a summary of replacement functions used and their associated blocks in the code generation report
Generate model Web viewInclude the model Web view in the code generation report
Static code metricsGenerate static code metrics report
Trace to model usingSpecify format of comments
Operator annotationsInclude operator annotations for Polyspace in generated comments
Simulink block descriptionsInsert descriptions of blocks as comments in generated code
Simulink data object descriptionsInclude descriptions of Simulink data objects as comments in generated code
Custom comments (MPT objects only)Include comments for MPT signal and parameter data in generated code
Custom comments functionSpecify a file that contains comments for MPT signal and parameter data objects
Stateflow object descriptionsInclude descriptions of Stateflow objects in generated comments
Requirements in block commentsInclude requirement descriptions in generated comments
MATLAB user commentsInclude MATLAB user comments in generated code
Insert Polyspace commentsInclude code comments for Polyspace block annotations
Comment styleSpecify comment style in generated code

Auto-generated identifier naming rules

Global variablesCustomize generated global variable identifiers
Global typesCustomize generated global type identifiers
Field name of global typesCustomize generated field names of global types
Subsystem methodsCustomize generated function names for reusable subsystems
Subsystem method argumentsCustomize generated function argument names for reusable subsystems
Local temporary variablesCustomize generated local temporary variable identifiers
Local block output variablesCustomize generated local block output variable identifiers
Constant macrosCustomize generated constant macro identifiers
Minimum mangle lengthSpecify the minimum number of characters for name-mangling
System-generated identifiersSpecify whether to use shorter names for the $N token in system-generated identifiers
Generate scalar inlined parameter asExpress scalar inlined parameter values in the generated code as literals or macros

Advanced parameters

Shared checksum lengthSpecify character length of $C token
EMX array utility functions identifier formatCustomize generated identifiers for emxArray utility functions
EMX array types identifier formatCustomize generated identifiers for emxArray types
Shared utilities identifier formatCustomize shared utility identifiers
Custom token textSpecify text to insert for $U token
Signal namingSpecify rules for naming mpt signals in generated code
M-functionSpecify rules for naming identifiers in generated code
#define namingSpecify rule for naming #define parameters in generated code
M-functionSpecify rule for naming identifiers in generated code
Parameter namingSpecify rules for naming mpt parameters in generated code
M-functionSpecify rules for naming identifiers in generated code

Software environment

Code replacement librariesLibraries that define code optimizations for specific target environment
Support: floating-point numbersCode generation for floating-point data
Support: complex numbersCode generation for complex data
Support: absolute timeCode generation for integer counters for absolute and elapsed time values
Support: continuous timeCode generation for blocks that use continuous time
Support: variable-size signalsCode generation for signals that vary in size

Code interface

Remove error status field in real-time model data structureWhether to log error status
Pass root-level I/O asHow generated code passes root-level input and output to reusable execution entry-point function
Include model types in model classWhether code generator places model type definitions in model class (Since R2020a)

Advanced parameters

Support non-inlined S-functionsWhether to generate code for noninlined S-functions
Multiword type definitionsWhether to define multiword data types as system- or user-defined types (Since R2020a)
Use dynamic memory allocation for model initializationWhether to allocate dynamic memory for initializing model data
Terminate function requiredWhether to generate terminate entry-point function
Combine signal/state structuresWhether to combine global block signal and state data into one structure
Generate separate internal data per entry-point functionWhether to place variables representing signals and states operated on at same rate in same data structure (Since R2021a)
MAT-file variable name modifierPrefix or suffix to add to MAT-file variable names
Existing shared codeFolder that contains shared code to use instead of generated shared utility code
Remove disable functionRemoval of unreachable instances of disable functions from generated code
Remove reset functionRemoval of unreachable instances of reset functions from generated code
Ignore custom storage classesWhether to apply predefined storage classes
Ignore test point signalsWhether to allocate memory buffers for test points
Implement each data store block as a unique access pointWhether to generate unique variable for each read and write operation on Data Store Memory block
Parentheses levelParenthesization style for generated code
Preserve operand order in expressionPreserve order of operands in expressions
Preserve condition expression in if statementPreserve empty primary conditions in if statements
Convert if-elseif-else patterns to switch-case statementsGenerate code for if-elseif-else logic as switch-case statements
Preserve extern keyword in function declarationsInclude extern keyword in function declarations
Preserve static keyword in function declarationsInclude static keyword in function declarations
Suppress generation of default cases for Stateflow switch statements if unreachableWhether to generate default cases for switch-case statements for Stateflow charts
Replace multiplications by powers of two with signed bitwise shiftsReplace multiplications by powers of two with signed bitwise shifts
Allow right shifts on signed integersAllow right bitwise shifts on signed integers
Casting modesMethod of casting data types for variables
Array container typeContainer type for arrays (Since R2020a)
Indent styleStyle for placement of braces
Indent sizeSize for indents in generated code
Newline styleNewline character in generated code
Maximum line widthMaximum line width for wrapping generated code (Since R2019a)
Measure task execution timeExecution-time profiling of generated code
Measure function execution timesExecution-time profiling of functions in generated code
Workspace variableWorkspace variable for execution-time measurements
Save optionsOptions for saving execution-time measurements
Measure task stack usageStack usage profiling of generated code (Since R2022a)
Stack workspace variableWorkspace variable for stack usage measurements (Since R2022a)
Third-party toolTool for code coverage analysis
Enable portable word sizesPortability across development computer and target processors
Enable source-level debugging for SILGenerated code debugging during SIL or PIL simulation
Create blockSIL or PIL block creation
Code templates: Source file (*.c) templateSource code file template
Code templates: Header file (*.h) templateTemplate for generated code header
Data templates: Source file (*.c) templateTemplate for generated data source file
Data templates: Header file (*.h) templateTemplate for generated data header file
File customization templateTemplate for custom file processing
Generate an example main programControl generation of example main program
Target operating systemTarget operating system for example main program
Generate full file bannerInclude code generation information in header file banner
Enable custom file bannerControl whether to use configurations for code and data templates
Data definitionPlacement of global variable definitions
Data definition filenameFile to contain data definitions
Data declarationLocation for data declarations
Data declaration filenameFile to contain deta declarations
#include file delimiterType of delimiter for include file
Use owner from data object for data definition placementWhether to use data ownership setting for definition in code
Signal display levelPersistence level for MPT signal data objects
Parameter tune levelPersistence level for MPT parameter data objects
File packaging formatMethod of file packaging for generated code files
Header filesCustom name for header files
Source filesCustom name for source files
Data filesCustom name for data files
Rate Transition block codeFormat for rate transition block code and data
Data type replacementMethod for replacing built-in data type names in generated code (Since R2023a)
Specify custom data type namesOption to replace built-in data type names in generated code
Replacement Name: doubleName for double data type in generated code
Replacement Name: singleName for single data type in generated code
Replacement Name: int32Name for int32 data type in generated code
Replacement Name: int16Name for int16 data type in generated code
Replacement Name: int8Name for int8 data type in generated code
Replacement Name: uint32Name for uint32 data type in generated code
Replacement Name: uint16Name for uint16 data type in generated code
Replacement Name: uint8Name for uint8 data type in generated code
Replacement Name: booleanName for boolean data type in generated code
Replacement Name: intName for int data type in generated code
Replacement Name: uintName for uint data type in generated code
Replacement Name: charName for char data type in generated code
Replacement Name: uint64Name for uint64 data type in generated code
Replacement Name: int64Name for int64 data type in generated code
Implement images using OpenCV Mat classOption to represent images as OpenCV Mat class (Since R2021b)
Coder typedefs compatibilityOption to force generation of rtwtypes.h (Since R2023a)

Classic Platform

Generate XML file for schema versionGenerate AUTOSAR XML files for specified schema version
Maximum SHORT-NAME lengthMaximum length for SHORT-NAME elements generated in XML files
Use AUTOSAR compiler abstraction macrosUse compiler abstraction macros
Support root-level matrix I/O using one-dimensional arraysUse one-dimensional C arrays to support root-level matrix I/O

Adaptive Platform

Generate XML file for schema versionGenerate AUTOSAR XML files for specified schema version
Maximum SHORT-NAME lengthMaximum length for SHORT-NAME elements generated in XML files
Transport layerTransport layer used by XCP (Since R2020a)
IP addressIP address of the machine on which the AUTOSAR adaptive application (XCP Server) executes (Since R2020a)
PortNetwork port on which the AUTOSAR adaptive application (XCP Server) serves XCP Client commands (Since R2020a)
VerboseEnable verbose messages for XCP Server (Since R2020a)
Use custom XCP ServerUse custom or default XCP Server (Since R2020a)

Objects

expand all

rtw.codegenObjectives.ObjectiveCustom code generation objective

Blocks

expand all

Custom MATLAB fileUpdate active configuration parameters of parent model by using file containing custom MATLAB code
ERT (optimized for fixed-point)Update active configuration parameters of parent model for ERT fixed-point code generation
ERT (optimized for floating-point)Update active configuration parameters of parent model for ERT floating-point code generation
GRT (debug for fixed/floating-point)Update active configuration parameters of parent model for GRT fixed-point or floating-point code generation
GRT (optimized for fixed/floating-point)Update active configuration parameters of parent model for GRT fixed-point or floating-point code generation

Topics

Code Generation Configuration

Model Configuration Parameters: Code Generation