Main Content

Model Configuration Set Customization

Customize how the code generator produces code

The model configuration set contains parameters that control how the code generator produces code from your model. To control code optimizations, interfaces, code style, build options, and other aspects of the generated code, use configuration parameters. When you want to use the same settings for many models, you can share one configuration set among the models. You can also use scripts to programmatically configure models for code generation.

Model Settings

expand all

Target Selection

System target fileFile that controls code generation stage of build process
LanguageProgramming language of generated code
Language standardLanguage standard supported by compiler

Build Process

Generate code onlyGenerate code versus an executable program
ToolchainToolchain to use when building executable program or library
Toolchain detailsBaseline toolchain settings
Package code and artifactsPackage generated code and artifacts in ZIP file
Build configurationBuild configuration defined by toolchain
Compiler optimization levelControl application of compiler optimizations
Custom compiler optimization flagsCompiler optimization flags
Generate makefileEnable generation of makefile to use for compiling generated code
Make commandMake command and options for initiating build process
Template makefileTemplate makefile to use to generate makefile for specified system target file

Code Generation Objectives

Select objectiveCode generation objective
Check model before generating codeChoose whether to run Code Generation Advisor checks

Advanced

Built-in FFTW library callbackUse built-in callback for FFTW library usage (Since R2023a)
Custom FFT library callbackCallback for custom FFT library usage
Custom BLAS library callbackCallback for custom BLAS library usage
Custom LAPACK library callbackCallback for custom LAPACK library usage
Verbose buildEnable display of build process stages and compiler output
Retain .rtw fileRetain generated model.rtw file
Profile TLCProfile execution of TLC files used to generate code for model
Enable TLC assertionProduce TLC stack trace
Start TLC coverage when generating codeLog coverage of TLC code during code generation
Start TLC debugger when generating codeDuring code generation, start TLC debugger
Zip file nameName of ZIP file
Large constant generation in MATLAB functionsWhether to write large deep learning constants to binary data files (Since R2024a)
Large constant threshold in MATLAB functions (bytes)Threshold above which the code generator writes DNN constants to binary data files (Since R2024a)
Show Custom Hardware App in Simulink ToolstripShow Custom Hardware App in Simulink Toolstrip
Show Embedded Hardware App in Simulink ToolstripShow Embedded Hardware App in Simulink Toolstrip
Default parameter behaviorRepresent numeric block parameters in generated code
Use memcpy for vector assignmentOptimize code generated for vector assignments
Memcpy threshold (bytes)Specify minimum array size for which memcpy and memset function calls replace for loops for vector assignments
Loop unrolling threshold Specify minimum array size width for generating for loops
Maximum stack size (bytes)Specify maximum stack size for local variables in model
Inline invariant signalsTransform symbolic names of Invariant signals in generated code
Signal storage reuseReuse signal memory
Enable local block outputsDeclare block signals locally or globally
Reuse local block outputsReuse local output variables
Eliminate superfluous local variables (Expression folding)Specify to fold expressions into single expression
Use memset to initialize floats and doubles to 0.0Control generation of code that explicitly initializes floating-point data to 0.0
Remove code from floating-point to integer conversions with saturation that maps NaN to zeroControl generation of protective code that handles floating-point to integer conversion for NaN values
Remove code from floating-point to integer conversions that wraps out-of-range valuesControl generation of wrapping code that handles out-of-range floating-point to integer conversion values
Buffer for reusable subsystemsBuffers to enhance reuse of subsystems
Use bitsets for storing state configurationBitsets for storing state configuration variables
Use bitsets for storing Boolean dataBitsets to store Boolean data
Base storage type for automatically created enumerationsSpecify storage type and size of enumerations for state outputs
Create code generation reportDocument generated code in an HTML report
Open report automaticallyDisplay code generation reports automatically
Include commentsInclude comments in generated code
Simulink block commentsInclude Simulink block comments
Stateflow object commentsInclude Stateflow object comments
MATLAB source code as commentsInclude MATLAB source code as comments
Show eliminated blocksInclude eliminated blocks' comments
Verbose comments for 'Model default' storage classReduce code size or improve code traceability
Maximum identifier lengthSpecify maximum number of characters in identifiers
Use the same reserved names as Simulation TargetSpecify whether to use reserved names from the Simulation Target pane
Reserved namesAvoid name conflicts with custom code
Header guard prefixCustom text to prepend to generated header guards (Since R2024a)
Duplicate enumeration member namesSpecify the action to take if the code generator detects two enumeration types with same member names
Use the same custom code settings as Simulation TargetUse custom code settings from the Simulation Target > Custom Code pane
Include headersInclude custom code in the generated model header file
Include directoriesAdd folders to the include path
Source filesCompile and link additional source files with the generated code
LibrariesLink additional libraries with the generated code
DefinesAdd preprocessor macro definitions to the compiler command line
Initialize codeInclude custom code in the generated model initialize function
Terminate codeInclude custom code in the generated model terminate function
Additional codeInclude custom code in the generated model source file

Software environment

Code replacement libraryLibrary that defines code optimizations for specific target environment
Shared code placementLocation of generated code that is shared
Support: non-finite numbersCode generation for nonfinite data

Code interface

Code interface packagingPackage generated code interface as reusable or nonreusable functions or as a C++ class
Multi-instance code error diagnosticSeverity level of diagnostics for when model violates requirements for generating multi-instance code

Data exchange interface

Array layoutLayout (column-major or row-major) code generator uses for array data
External functions compatibility for row-major code generationDiagnostic action for functions that use multidimensional arrays and do not specify array layout
Generate C API for: signalsGenerated C API interface code for signals in signal structure
Generate C API for: parametersGenerated C API interface code for tunable parameters in parameter structure
Generate C API for: statesGenerated C API interface code for states in state structure
Generate C API for: root-level I/OGenerated C API interface code for root-level inports and outports in root-level I/O structure
ASAP2 interfaceGenerated ASAP2 data interface
External modeGenerated external mode data interface
Transport layerTransport protocol for external mode communication
MEX-file argumentsArguments to pass to external mode interface MEX-file
Static memory allocationDynamic or static memory allocation for external mode communication
Static memory buffer sizeSize of static memory buffer for external mode communication
Automatically allocate static memoryAutomatic static memory buffer allocation for external model communication (Since R2022b)
Maximum durationMaximum number of base rate steps for which external mode logs data after trigger event (Since R2022b)
Log signals to MDF fileLog signal and output data from generated code to MDF file (Since R2024a)

Deep learning

Target libraryDeep learning library to use during code generation for target environment (Since R2020b)
Learnables CompressionCompression type, specified as "none" or "bfloat16" (Since R2023b)
ARM Compute Library versionVersion of ARM Compute Library to use during code generation (Since R2020b)
ARM Compute Library architectureARM architecture supported by target hardware (Since R2020b)
Auto tuningCode generation that uses cuDNN library with auto tuning enabled (Since R2021a)

Advanced parameters

Maximum word lengthMaximum word length for generated multiword type definitions
Buffer size of dynamically-sized string (bytes)Size of buffer for signals that have dynamic string data type
Generate full file bannerInclude code generation information in file banner
Single output/update functionExecution entry-point function that includes code for output and update functions
MAT-file loggingExported data saved in MAT-file
Suppress generation of fixed-point word size checksControl generation of preprocessor directives that perform fixed-point word size checks (Since R2024a)
LUT object struct order for even spacing specificationOrder of fields in structure generated for lookup table object with even spacing breakpoint specification
LUT object struct order for explicit value specificationOrder of fields in structure generated for lookup table object with explicit values breakpoint specification
Buffer size of dynamically-sized string (bytes)Size of buffer for signals that have dynamic string data type
External functions compatibility for row-major code generationDiagnostic action for functions that use multidimensional arrays and do not specify array layout
Target derived from slrealtimeIndicates whether or not the currently selected target is derived from the slrealtime target (Since R2022b)

Topics

Code Generation Configuration Sets

Model Configuration Parameters: Code Generation

Code Comments

Identifiers

  • Construction of Generated Identifiers
    For generic real-time (GRT) and rapid simulation (RSim) targets, the code generator automatically constructs identifiers for variables and functions in the generated code.
  • Reserved Keywords
    If you use the code generator to produce C or C++ code, your model must not contain keywords that are reserved for internal use.

Featured Examples