Subsystems
生成和重用子系统的代码
您可以将若干模块组合到一个 Subsystem 模块中,以降低模型的大小和复杂度。要为各个子系统生成模块化代码和单元测试代码,您可以配置原子子系统来将代码生成到一个单独的函数和文件。
子系统可以是虚拟子系统或原子子系统。虚拟子系统提供模型中的图形层次结构,并且不影响模型的执行。原子子系统作为模型中的单个单元执行。代码生成器支持条件执行子系统。
主题
代码生成
- 将子系统代码生成为单独的函数和文件
配置子系统以在单独的文件中生成函数,并指定这些函数和文件的名称。 - Generate Predictable Function Interface to Match Graphical Block Interface
Generate a nonreusable subsystem function interface that does not change. - Generate Code for Variant Subsystem Blocks
Generate code for specific implementation of component represented using Variant Subsystem block. - Specify Generated Code Function Packaging for Subsystems
This example shows how to configure how the code generator generates code for an atomic subsystem. - 生成代码的建模规范
概述有关模型和生成代码的规范,包括编码规范、组件部署建模规范和 MathWorks 咨询委员会规范 (MAB)。
代码优化
- Generate Inlined Subsystem Code
Configure nonvirtual subsystems to generate inlined code.
代码重用
- Generate Reentrant Code from Subsystems
Reduce generated code size by configuring subsystems to generate shared and reentrant functions. - Resolve Issues with Reusable Subsystems Generating Separate Functions
Troubleshoot reusable subsystems generating separate functions or producing name collision errors. - Use Signal Conversion or Bias Blocks to Resolve Issues with Reusable Code Generation
Place blocks to prevent the code generator from considering reusable subsystems to be unequal. - Compare Checksums to Determine Why Generated Code Is Not Reused
Programmatically compute differences between reusable subsystem interfaces and contents.