Generate Inlined Subsystem Code - MATLAB & Simulink (original) (raw)

Main Content

To inline subsystem code with your model code, configure a nonvirtual subsystem. In the Subsystem Block Parameters dialog box, the Function packaging parameter specifies the format of the subsystem generated code. This parameter has these settings:

The code generator can generate inlined code for theAuto and Inline settings. The inline setting directs the code generator to inline the subsystem code unconditionally.

The default Auto setting directs the code generator to generate the most efficient code for the subsystem based on the type and number of instances of the subsystem that exist in the model. When there is only one instance of a subsystem, theAuto setting inlines the subsystem code. In Embedded Coder®, when there are multiple instances of a subsystem that are not too complex, theAuto setting inlines the code for each subsystem. Otherwise, theAuto setting generates a single copy of the function (as a reusable function). For a function-call subsystem that has multiple callers, theAuto setting generates subsystem code that is consistent with theNonreusable function setting.

Configure Subsystem to Inline Code

  1. Open a model with a subsystem, such as SubsystemAtomic.
    openExample('SubsystemAtomic')
  2. Open Simulink® Coder™ or Embedded Coder.
    If you are using Embedded Coder, from the tab, click View Code to open the Code View editor.
  3. Right-click the Subsystem block. From the context menu, select .
  4. In the Subsystem Parameters dialog box, verify thatTreat as atomic unit is selected. This option makes the subsystem nonvirtual. When the subsystem is nonvirtual, the Function packaging option is available on the Code Generation tab.
  5. Click the Code Generation tab and selectAuto or Inline from theFunction packaging parameter.
  6. Click Apply and close the dialog box.
    The border of the subsystem thickens, indicating that it is nonvirtual.
  7. Generate code from the model. The code generator inlines subsystem code withinSubsystemAtomic.c. You can identify this code by system and block identification tags, such as:
    /* Atomic SubSystem Block: /AtomicSubsys1 */

Exceptions to Inlining

There are certain cases in which the code generator does not inline a nonvirtual subsystem, even though you select the Inline setting.

The Function packaging parameter is disabled in Simulink Function blocks.

See Also


1 VxWorks is a registered trademark of Wind River® Systems, Inc.