Main Content

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

模型配置集自定义

自定义代码生成器生成代码的方式

模型配置集包含控制代码生成器如何从模型生成代码的参数。要控制生成代码的代码优化、接口、代码样式、编译选项和其他方面,请使用配置参数。当您要对许多模型使用相同的设置时,可以在这些模型之间共享同一个配置集。您还可以使用脚本以编程方式配置模型的代码生成。

模型设置

全部展开

目标选择

系统目标文件控制编译过程的代码生成阶段的文件
语言生成代码的编程语言
语言标准Language standard supported by compiler

编译过程

仅生成代码生成代码与可执行程序
工具链编译可执行程序或库时使用的工具链
工具链详细信息Baseline toolchain settings
代码和工件打包在 ZIP 文件中打包生成的代码和工件
编译配置Build configuration defined by toolchain
编译器优化级别Control application of compiler optimizations
自定义编译器优化标志Compiler optimization flags
生成联编文件启用生成联编文件以用于编译生成的代码
make 命令Make command and options for initiating build process
模板联编文件Template makefile to use to generate makefile for specified system target file

代码生成目标

选择目标Code generation objective
生成代码前检查模型Choose whether to run Code Generation Advisor checks

高级

内置 FFTW 库回调Use built-in callback for FFTW library usage (自 R2023a 起)
自定义 FFT 库回调Callback for custom FFT library usage
自定义 BLAS 库回调Callback for custom BLAS library usage
自定义 LAPACK 库回调Callback for custom LAPACK library usage
详尽编译启用编译过程阶段和编译器输出的显示
保留 .rtw 文件Retain generated model.rtw file
探查 TLCProfile execution of TLC files used to generate code for model
启用 TLC 断言Produce TLC stack trace
生成代码时启动 TLC 覆盖率报告Log coverage of TLC code during code generation
生成代码时启动 TLC 调试器During code generation, start TLC debugger
Zip 文件名Name of ZIP file
在 Simulink 工具条中显示自定义硬件 AppShow Custom Hardware App in Simulink Toolstrip (自 R2019b 起)
在 Simulink 工具条中显示嵌入式硬件 AppShow Embedded Hardware App in Simulink Toolstrip (自 R2019b 起)
默认参数行为在生成的代码中表示数值模块参数
使用 memcpy 进行向量赋值Optimize code generated for vector assignments
Memcpy 阈值(字节)Specify minimum array size for which memcpy and memset function calls replace for loops for vector assignments
循环展开阈值 Specify minimum array size width for generating for loops
最大堆栈大小(字节)Specify maximum stack size for local variables in model
内联不变信号在生成的代码中转换不变信号的符号名称
信号存储重用Reuse signal memory
启用局部模块输出Declare block signals locally or globally
重用局部模块输出Reuse local output variables
消除多余的局部变量(表达式折叠)Specify to fold expressions into single expression
使用 memset 将浮点和双精度初始化为 0.0Control generation of code that explicitly initializes floating-point data to 0.0
删除涉及饱和处理的从浮点到整数转换中将 NaN 映射至零的代码Control generation of protective code that handles floating-point to integer conversion for NaN values
删除从浮点到整数转换中将超出范围值绕回的代码Control generation of wrapping code that handles out-of-range floating-point to integer conversion values
可重用子系统的缓冲区Buffers to enhance reuse of subsystems
使用位集来存储状态配置Bitsets for storing state configuration variables
使用位集来存储布尔数据Bitsets to store Boolean data
自动创建的枚举的基本存储类型Specify storage type and size of enumerations for state outputs
创建代码生成报告Document generated code in an HTML report
自动打开报告Display code generation reports automatically
包括注释在生成的代码中包括注释
Simulink 模块注释包括 Simulink 模块注释
Stateflow 对象注释Include Stateflow object comments
MATLAB 源代码作为注释包括 MATLAB 源代码作为注释
显示已消除模块Include eliminated blocks' comments
为 '模型默认' 存储类提供详尽注释Reduce code size or improve code traceability
最大标识符长度Specify maximum number of characters in identifiers
使用与仿真目标相同的保留名称Specify whether to use reserved names from the Simulation Target pane
保留名称Avoid name conflicts with custom code
重复的枚举成员名称Specify the action to take if the code generator detects two enumeration types with same member names (自 R2019b 起)
使用与仿真目标相同的自定义代码设置使用“仿真目标”>“自定义代码”窗格中的自定义代码设置
包含头文件在生成的模型头文件中包含自定义代码
包含目录将文件夹添加到包含路径
源文件用生成的代码编译和链接其他源文件
用生成的代码链接附加库
定义向编译器命令行添加预处理器宏定义
初始化代码在生成的模型初始化函数中包含自定义代码
终止代码Include custom code in the generated model terminate function
其他代码在生成的模型源文件中包含自定义代码

软件环境

代码替换库Library that defines code optimizations for specific target environment
共享代码放置共享的生成代码的位置
支持: 非有限数Code generation for nonfinite data

代码接口

代码接口打包Package generated code interface as reusable or nonreusable functions or as a C++ class
多实例代码错误诊断Severity level of diagnostics for when model violates requirements for generating multi-instance code

数据交换接口

数组布局代码生成器对数组数据使用的布局(列优先或行优先)
外部函数的行优先代码生成兼容性Diagnostic action for functions that use multidimensional arrays and do not specify array layout
生成用于信号的 C APIGenerated C API interface code for signals in signal structure
生成用于参量的 C APIGenerated C API interface code for tunable parameters in parameter structure
生成用于状态的 C APIGenerated C API interface code for states in state structure
生成用于根级 I/O 的 C APIGenerated C API interface code for root-level inports and outports in root-level I/O structure
ASAP2 接口生成的 ASAP2 数据接口
外部模式生成的外部模式数据接口
传输层Transport protocol for external mode communication
MEX 文件参量Arguments to pass to external mode interface MEX-file
静态内存分配Dynamic or static memory allocation for external mode communication
静态内存缓冲区大小Size of static memory buffer for external mode communication
自动分配静态内存Automatic static memory buffer allocation for external model communication (自 R2022b 起)
最大持续时间Maximum number of base rate steps for which external mode logs data after trigger event (自 R2022b 起)

深度学习

目标库Deep learning library to use during code generation for target environment (自 R2020b 起)
可学习参数压缩Compression type, specified as "none" or "bfloat16" (自 R2023b 起)
ARM Compute Library 版本Version of ARM Compute Library to use during code generation (自 R2020b 起)
ARM Compute Library 架构ARM architecture supported by target hardware (自 R2020b 起)
自动调整Code generation that uses cuDNN library with auto tuning enabled (自 R2021a 起)

高级参数

最大字长Maximum word length for generated multiword type definitions
动态大小字符串的缓冲区大小(以字节为单位)Size of buffer for signals that have dynamic string data type
生成完整文件前注Include code generation information in file banner
经典调用接口(To be removed) For models created before R2012a and configured with GRT system target file, generated model function calls that are compatible with main program module
单一输出/更新函数Execution entry-point function that includes code for output and update functions
MAT 文件记录Exported data saved in MAT-file
等间距设定的 LUT 对象结构体顺序Order of fields in structure generated for lookup table object with even spacing breakpoint specification
显式值设定的 LUT 对象结构体顺序Order of fields in structure generated for lookup table object with explicit values breakpoint specification
动态大小字符串的缓冲区大小(以字节为单位)Size of buffer for signals that have dynamic string data type
外部函数的行优先代码生成兼容性Diagnostic action for functions that use multidimensional arrays and do not specify array layout
从 slrealtime 派生的目标Indicates whether or not the currently selected target is derived from the slrealtime target (自 R2022b 起)

主题

代码生成配置集

模型配置参数:代码生成

代码注释

标识符

  • 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.