Preserve Subsystem Boundaries in Generated Code

This model shows how to preserve the boundary of a virtual subsystem. By selecting the Subsystem Parameters option Treat as atomic unit, you guarantee that the code for that subsystem executes as an atomic unit. Once a system is marked as atomic, you can specify how the subsystem is represented in code via the Subsystem Parameters option Code Generation Function Packaging. You can specify that the subsystem is translated to any of the following types of implementation:

  • Inline: Inline the subsystem code at the call sites

  • Function: A void/void function with I/O and internal data in global data structure

  • Reusable Function: A re-entrant function with data passed in as part of function arguments

  • Auto: Let Simulink Coder optimize the implementation based on context

Note: Simulink and Simulink Coder can avoid "artificial" algebraic loops when the subsystem is made atomic via the subsystem option Minimize algebraic loop occurrences. See the Simulink documentation for information on minimizing occurrences of algebraic loops.

Example Model

model = 'rtwdemo_atomic';

Was this topic helpful?