Main Content

Generate Inlined Subsystem Code

You can configure a nonvirtual subsystem to inline the subsystem code with the model code. In the Subsystem Parameters dialog box, the Function packaging parameter specifies the format of the subsystem’s generated code. This parameter has four settings: Auto, Inline, Nonreusable function, and Reusable function. The code generator can generate inlined code for the Auto or Inline settings.

The Inline setting explicitly 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, the Auto setting inlines the subsystem code. When there are multiple instances of a subsystem, that is not too complex, the Auto setting inlines the code for each subsystem. Otherwise, the Auto setting generates a single copy of the function (as a reusable function). For a function-call subsystem with multiple callers, the Auto setting generates subsystem code that is consistent with the Nonreusable function setting.

Configure Subsystem to Inline Code

To configure your subsystem for inlining:

  1. Right-click the Subsystem block. From the context menu, select Block Parameters (Subsystem).

  2. In the Subsystem Parameters dialog box, if the subsystem is virtual, select Treat as atomic unit. This option makes the subsystem nonvirtual. On the Code Generation tab, the Function packaging option is now available.

  3. Click the Code Generation tab and select Auto or Inline from the Function packaging parameter.

  4. Click Apply and close the dialog box.

    The border of the subsystem thickens, indicating that it is nonvirtual.

When you generate code from your model, the code generator inlines subsystem code within model.c or model.cpp (or in its parent system's source file). You can identify this code by system/block identification tags, such as:

/* Atomic SubSystem Block: <Root>/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.

  • If a noninlined S-function calls a function-call subsystem, the code generator ignores the Inline setting. Because noninlined S-functions use function pointers to make function calls, the code generator must generate a function with all arguments present.

  • In a feedback loop involving function-call subsystems, the code generator generates a function instead of inlined code for one of the subsystems. Based on the internal, sorted order of the subsystems, the code generator selects which subsystem to generate a function.

  • If an S-function, an Async Interrupt, or a Task Sync block with the option SS_OPTION_FORCE_NONINLINED_FCNCALL set to TRUE calls a subsystem, the code generator generates a function instead of inlined code for the subsystem. The VxWorks® block library (vxlib1), contains the user-defined Async Interrupt and Task Sync blocks.[1]

See Also

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