Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

代码生成配置集

配置模型以进行仿真和代码生成

涉及代码生成的模型配置参数定义代码生成器如何从模型中生成代码并编译可执行文件。

模型设置

全部展开

共享代码生成器字典Embedded Coder 字典,包含用于代码生成的代码接口配置 (自 R2022b 起)
生成 Halide 代码Generate Halide code for faster array computation (自 R2023b 起)
优先目标Prioritized list of Code Generation Advisor objectives to apply for reviewing model configuration parameter settings

数据初始化

删除根级 I/O 零初始化Control generation of initialization code for root-level inports and outports set to zero
删除内部数据零初始化Control generation of Initialization code for internal work structures, such as block states and block outputs, to zero

优化级别

级别Optimization level for generated code
优先级Control application of optimizations based on priority
指定自定义优化Enable option to choose individual optimization parameters
简化数组索引Replace multiply operations in array indices when accessing arrays in a loop
生成并行 for 循环Optimization for parallel for-loops
将布尔数据打包到位域中控制存储布尔信号
重用不同大小和维度的缓冲区Reuse buffers to store data of different sizes and dimensions
优化全局数据访问优化全局变量使用
优化生成代码中的模块运算顺序Specify to reorder block operations for improved code execution speed
重用全局模块输出重用全局变量的优化
重用 Model 模块的输出缓冲区Reuse referenced model buffers if possible (自 R2022b 起)
为 Assignment 和 Bus Assignment 模块执行就地更新Reuse the input and output variables of Bus Assignment and Assignment blocks
重用 Data Store Read 和 Data Store Write 模块的缓冲区Eliminate temporary buffers for Data Store Read and Data Store Write blocks
位域声明符类型设定符Specify bitfield type
可重用子系统输出的传递方式Control how a reusable subsystem passes outputs

高级参数

使用指定的最小值和最大值进行优化Optimize using minimum and maximum values for signals and parameters
从可调参数表达式中删除对超出范围值进行饱和处理的代码Control generation of protective code that saturates out-of-range tunable parameter expression values (自 R2019b 起)
删除防止除法算术异常的代码Control generation of protective code for division arithmetic exceptions
使用信号标签来指导缓冲区重用Reuse buffers by using signal labels
用于表示 Bitwise Operator 和 Logical Operator 模块的运算符Specify operator type in generated code (自 R2020a 起)
代码到模型Include hyperlinks in the code generation report that link to the model diagram
模型到代码Enable code highlighting in the code generation report when you click on Simulink blocks, Stateflow objects, and MATLAB functions
已消除模块/虚拟模块Include a summary of eliminated and virtual blocks in the code generation report
可追溯的 Simulink 模块Include a summary of Simulink blocks and the corresponding code locations in the code generation report
可追溯的 Stateflow 对象Include a summary of Stateflow objects and the corresponding code locations in the code generation report
可追溯的 MATLAB 函数Include a summary of MATLAB functions and corresponding code locations in the code generation report
摘要显示哪些模块触发了代码替换Include a summary of replacement functions used and their associated blocks in the code generation report
生成模型 Web 视图Include the model Web view in the code generation report
静态代码度量生成静态代码度量报告
使用以下方式追溯至模型Specify format of comments
运算符注释Include operator annotations for Polyspace in generated comments
Simulink 模块描述Insert descriptions of blocks as comments in generated code
Simulink 数据对象描述Simulink 数据对象的描述作为注释包含在生成的代码中
自定义注释(仅限 MPT 对象)Include comments for MPT signal and parameter data in generated code
自定义注释函数Specify a file that contains comments for MPT signal and parameter data objects
Stateflow 对象描述Include descriptions of Stateflow objects in generated comments
在模块注释中包含需求描述Include requirement descriptions in generated comments
MATLAB 用户注释在生成的代码中包含 MATLAB 用户注释
插入 Polyspace 注释包含 Polyspace 模块注释的代码注释
注释样式指定生成代码中的注释样式

自动生成的标识符命名规则

全局变量Customize generated global variable identifiers
全局类型Customize generated global type identifiers
全局类型的字段名称Customize generated field names of global types
子系统方法Customize generated function names for subsystems and Simulink functions
子系统方法参数Customize generated function argument names for subsystems and Simulink functions
局部临时变量Customize generated local temporary variable identifiers
局部模块输出变量Customize generated local block output variable identifiers
常量宏Customize generated constant macro identifiers
代码生成 > 标识符 > 最小修饰长度Specify the minimum number of characters for name-mangling
系统生成的标识符Specify whether to use shorter names for the $N token in system-generated identifiers
生成标量内联参数作为Express scalar inlined parameter values in the generated code as literals or macros

高级参数

共享校验和长度Specify character length of $C token
EMX 数组工具函数标识符格式Customize generated identifiers for emxArray utility functions
EMX 数组类型标识符格式Customize generated identifiers for emxArray types
共享实用工具标识符格式Customize shared utility identifiers
自定义标记文本指定要为 $U 标记插入的文本
信号命名Specify rules for naming mpt signals in generated code
M 函数Specify rules for naming identifiers in generated code
#define 命名Specify rule for naming #define parameters in generated code
M 函数Specify rule for naming identifiers in generated code
参数命名Specify rules for naming mpt parameters in generated code
M 函数Specify rules for naming identifiers in generated code

软件环境

代码替换库Libraries that define code optimizations for specific target environment
支持: 浮点数Code generation for floating-point data
支持: 复数Code generation for complex data
支持: 绝对时间Code generation for model that includes blocks that depend on absolute or elapsed time
支持: 连续时间Code generation for blocks that use continuous time
支持: 可变大小信号可变大小信号的代码生成

代码接口

删除实时模型数据结构体中的错误状态字段Whether to log error status
根级 I/O 传递方式How generated code passes root-level input and output to reusable execution entry-point function
在模型类中包含模型类型Whether code generator places model type definitions in model class (自 R2020a 起)

高级参数

支持非内联 S-FunctionWhether to generate code for noninlined S-functions
多字类型定义Whether to define multiword data types as system- or user-defined types (自 R2020a 起)
使用动态内存分配进行模型初始化是否为初始化模型数据分配动态内存
需要终止函数Whether to generate terminate entry-point function
组合信号/状态结构体Whether to combine global block signal and state data into one structure
为每个入口函数生成单独的内部数据Whether to place variables representing signals and states operated on at same rate in same data structure (自 R2021a 起)
MAT 文件变量名称修饰符Prefix or suffix to add to MAT-file variable names
现有共享代码Folder that contains shared code to use instead of generated shared utility code
删除 disable 函数Removal of unreachable instances of disable functions from generated code
删除 reset 函数Removal of unreachable instances of reset functions from generated code
忽略自定义存储类Whether to apply predefined storage classes
忽略测试点信号Whether to allocate memory buffers for test points
将每个数据存储模块实现为唯一访问点Whether to generate unique variable for each read and write operation on Data Store Memory block
括号层级Parenthesization style for generated code
保留表达式中的操作数顺序Preserve order of operands in expressions
保留 if 语句中的条件表达式Preserve empty primary conditions in if statements
将 if-elseif-else 模式转换为 switch-case 语句为作为 switch-case 语句的 if-elseif-else 逻辑生成代码
在函数声明中保留 extern 关键字Include extern keyword in function declarations
在函数声明中保留静态关键字Include static keyword in function declarations
禁止为 Stateflow switch 语句生成不可达的默认 caseWhether to generate default cases for switch-case statements for Stateflow charts
将二次幂的乘法替换为有符号按位移位Replace multiplications by powers of two with signed bitwise shifts
允许有符号整数右移Allow right bitwise shifts on signed integers
强制转换模式Method of casting data types for variables
数组容器类型Container type for arrays (自 R2020a 起)
缩进样式Style for placement of braces
缩进大小Size for indents in generated code
换行样式Newline character in generated code
最大行宽Maximum line width for wrapping generated code
测量任务执行时间Execution-time profiling of generated code
测量函数执行时间Execution-time profiling of functions in generated code
工作区变量用于执行时间测量的工作区变量
保存选项Options for saving execution-time measurements
测量任务堆栈使用情况Stack usage profiling of generated code (自 R2022a 起)
堆栈工作区变量Workspace variable for stack usage measurements (自 R2022a 起)
第三方工具Tool for code coverage analysis
启用可移植字长Portability across development computer and target processors
对 SIL 启用源代码级别调试Generated code debugging during SIL or PIL simulation
创建模块SIL or PIL block creation
代码模板:源文件(*.c)模板源代码文件模板
代码模板:头文件(*.h)模板生成的代码头文件的模板
数据模板:源文件(*.c)模板Template for generated data source file
数据模板:头文件(*.h)模板Template for generated data header file
文件自定义模板Template for custom file processing
生成示例主程序Control generation of example main program
目标操作系统Target operating system for example main program
生成完整文件前注Include code generation information in header file banner
启用自定义文件前注Control whether to use configurations for code and data templates
Data definitionPlacement of global variable definitions
Data definition filename要包含数据定义的文件
Data declarationLocation for data declarations
Data declaration filename要包含数据声明的文件
#include file delimiter包括文件的分隔符类型
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
数据类型替换Method for replacing built-in data type names in generated code (自 R2023a 起)
指定自定义数据类型名称Option to replace built-in data type names in generated code
替换名称: 双精度Name for double data type in generated code
替换名称: 单精度Name for single data type in generated code
替换名称: int32Name for int32 data type in generated code
替换名称: int16Name for int16 data type in generated code
替换名称: int8Name for int8 data type in generated code
替换名称: uint32Name for uint32 data type in generated code
替换名称: uint16Name for uint16 data type in generated code
替换名称: uint8Name for uint8 data type in generated code
替换名称: booleanName for boolean data type in generated code
替换名称: intName for int data type in generated code
替换名称: uintName for uint data type in generated code
替换名称: charName for char data type in generated code
替换名称: uint64Name for uint64 data type in generated code
替换名称: int64Name for int64 data type in generated code
使用 OpenCV Mat 类实现图像Option to represent images as OpenCV Mat class (自 R2021b 起)
代码生成器 typedef 兼容性Option to force generation of rtwtypes.h (自 R2023a 起)

Classic 平台

为架构版本生成 XML 文件Generate AUTOSAR XML files for specified schema version
短名称最大长度Maximum length for SHORT-NAME elements generated in XML files
使用 AUTOSAR 编译器抽象宏使用编译器抽象宏
使用一维数组支持根级矩阵 I/OUse one-dimensional C arrays to support root-level matrix I/O

Adaptive 平台

为架构版本生成 XML 文件Generate AUTOSAR XML files for specified schema version
短名称最大长度Maximum length for SHORT-NAME elements generated in XML files
传输层Transport layer used by XCP (自 R2020a 起)
IP 地址IP address of the machine on which the AUTOSAR adaptive application (XCP Server) executes (自 R2020a 起)
端口Network port on which the AUTOSAR adaptive application (XCP Server) serves XCP Client commands (自 R2020a 起)
详尽对 XCP 服务器启用详尽消息 (自 R2020a 起)
使用自定义 XCP 服务器Use custom or default XCP Server (自 R2020a 起)

对象

全部展开

rtw.codegenObjectives.Objective自定义代码生成目标

模块

全部展开

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

主题

代码生成配置

模型配置参数:代码生成