Subsystems
Generate and reuse code for subsystems
You can group blocks into a Subsystem block to reduce the size and complexity of a model. To generate modular code and unit test code for individual subsystems, you can configure an atomic subsystem to generate code to a separate function and file.
A subsystem can be virtual or atomic. A virtual subsystem provides graphical hierarchy in a model and does not impact the execution of a model. An atomic subsystem executes as a single unit within a model. The code generator supports conditionally executed subsystems.
Topics
Code Generation
- Generate Subsystem Code as Separate Function and Files
Configure subsystems to generate functions in separate files and specify the names of those functions and files. - Specify Generated Code Function Packaging for Subsystems (Embedded Coder)
This example shows how to configure how the code generator generates code for an atomic subsystem.
Code Optimization
- Generate Inlined Subsystem Code
Configure nonvirtual subsystems to generate inlined code.
Code Reuse
- 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 (Embedded Coder)
Troubleshoot reusable subsystems generating separate functions or producing name collision errors. - Use Signal Conversion or Bias Blocks to Resolve Issues with Reusable Code Generation (Embedded Coder)
Place blocks to prevent the code generator from considering reusable subsystems to be unequal. - Compare Checksums to Determine Why Generated Code Is Not Reused (Embedded Coder)
Programmatically compute differences between reusable subsystem interfaces and contents.