Real-Time Workshop User's Guide | ![]() ![]() |
Nonvirtual Subsystem Code Generation Options
For any nonvirtual subsystem, you can choose the following code generation options from the RTW system code pop-up menu in the subsystem Block parameters dialog:
Auto
: This is the default option. See Auto Option below.Inline
: This option explicitly directs the Real-Time Workshop to inline the subsystem.Function
: This option explicitly directs the Real-Time Workshop to generate a separate function and (optionally) a separate file for the subsystem. In this case you can choose further options to control the naming of the generated function and file.The sections below discuss the Auto
, Inline
, and Function
options.
Auto Option
In the current release, the Auto
option causes the Real-Time Workshop to inline the subsystem, unless it is a function-call subsystem with multiple callers. In that case, a function is generated.
In a future release, the Auto
option will also create functions when multiple instances of a subsystem are detected. If there are multiple instances or multiple callers of the subsystem, the subsystem will not be inlined. To take advantage of this capability, you should choose the Auto
option. Choose Inline
or Function
when you want specifically to inline a subsystem or generate a separate function and code module.
Alternatively, you can open the Block Parameters dialog by:
If the system is already nonvirtual, the RTW system code option is already enabled.
Figure 3-7: Auto Code Generation Option for a Nonvirtual Subsystem
Inline Option
As noted above, subsystem code can be inlined only if the subsystem is nonvirtual.
Exceptions to Inlining. Note that there are certain cases in which the Real-Time Workshop will not inline a nonvirtual subsystem, even though the Inline option is selected. These cases are:
SS_OPTION_FORCE_NONINLINED_FCNCALL
to TRUE
, it will not be inlined. This may be the case when user-defined Asynchronous Interrupt blocks or Task Synchronization blocks are required. Such blocks must be generated as functions. The VxWorks Asynchronous Interrupt and Task Synchronization blocks, shipped with the Real-Time Workshop, use the SS_OPTION_FORCE_NONINLINED_FCNCALL
option.To generate inlined subsystem code:
Alternatively, you can open the Block Parameters dialog by:
If the system is already nonvirtual, the RTW system code menu is already enabled.
Figure 3-8: Inlined Code Generation for a Nonvirtual Subsystem
When you generate code from your model, the Real-Time Workshop writes inline code within model
.c
to perform subsystem computations. You can identify this code by system/block identification tags, such as the following.
/* Atomic SubSystem Block: <Root>/AtomicSubsys1 */
See Tracing Generated Code Back to Your Simulink Model for further information on system/block identification tags.
Function Option
This option lets you direct the Real-Time Workshop to generate a separate function and (optionally) a separate file for the subsystem. When you select the Function
option, two additional options are enabled:
Figure 3-9 shows the Block Parameters dialog with the Function
option selected.
RTW Function Name Options Menu. This menu offers the following choices:
Auto
: the Real-Time Workshop assigns a unique function name using the default naming convention: model
_
systemid
()
, where systemid
is a sequential identifier (s0, s1,...s
n
) assigned by Simulink.UseSubSystemName
: the Real-Time Workshop uses the subsystem name as the function name.UserSpecified
: When this option is selected, the RTW function name text entry field is enabled. Enter any legal function name. Note that the function name must be unique.RTW File Name Options Menu. This menu offers the following choices:
UseSubSystemName
: the Real-Time Workshop generates a separate file, using the subsystem name as the filename.UseFunctionName
: the Real-Time Workshop generates a separate file, using the function name (as specified by the RTW function name options) as the filename.UserSpecified
: When this option is selected, the RTW file name (no extension) text entry field is enabled. The Real-Time Workshop generates a separate file, using the name you enter as the filename. Enter any filename desired, but do not include the .c
(or any other) extension. Note that this filename should be unique.Auto
: the Real-Time Workshop does not generate a separate file for the subsystem. Code generated from the subsystem is generated within the code module generated from the subsystem's parent system. If the subsystem's parent is the model itself, code generated from the subsystem is generated within model
.c
.To generate both a separate subsystem function and a separate file:
Alternatively, you can open the Block Parameters dialog by:
If the system is already nonvirtual, the RTW system code menu is already enabled.
Auto
(options are described in RTW File Name Options Menu).
Figure 3-9 shows the use of the UserSpecified
filename option.
Figure 3-9: Subsystem Function Code Generation
with Separate User-Defined File Name
![]() | Nonvirtual Subsystem Code Generation | Modularity of Subsystem Code | ![]() |