Real-Time Workshop |
 |
Generating Code and Executables from Subsystems
Real-Time Workshop can generate code and build an executable from any subsystem within a model. The code generation and build process uses the code generation and build parameters of the root model.
To generate code and build an executable from a subsystem:
- Set up the desired code generation and build parameters in the Simulation Parameters dialog, just as you would for code generation from a model.
- Select the desired subsystem block.
- Right-click on the subsystem block and select Build Subsystem from the Real-Time Workshop submenu of the subsystem block's context menu.
- Alternatively, you can select Build Subsystem from the Real-Time Workshop submenu of the Tools menu. This menu item is enabled when a subsystem is selected in the current model.
Note
If the model is operating in external mode when you select Build Subsystem, Real-Time Workshop automatically turns off external mode for the duration of the build, then restores external mode upon its completion.
|
- The Build Subsystem window opens. This window displays a list of the subsystem parameters. The upper pane displays the name, class, and storage class of each variable (or data object) that is referenced as a block parameter in the subsystem.When you select a parameter in the upper pane, the lower pane shows all the blocks that reference the parameter, and the parent system of each such block.
- The StorageClass column contains a popup menu for each row. The menu lets you set the storage class of any parameter, or inline the parameter. To inline a parameter, select the Inline option from the menu. To declare a parameter to be tunable, set the storage class to any value other than Inline.)
In the illustration above, the parameter K2
is inlined, while the other parameters are tunable and have various storage classes.
See Parameters: Storage, Interfacing, and Tuning and Simulink Data Objects and Code Generation for further information on tunable and inlined parameters and storage classes.
- After selecting tunable parameters, click the Proceed button. This initiates the code generation and build process.
- The build process displays status messages in the MATLAB command window. When the build completes, the generated executable is in your working directory. The name of the generated executable is
subsystem
.exe
(PC) or subsystem
(UNIX), where subsystem
is the name of the source subsystem block.
- The generated code is in a build subdirectory, named
subsystem
_
target
_rtw
, where subsystem
is the name of the source subsystem block and
target
is the name of the target configuration.
Note
You can generate subsystem code using any target configuration available in the System Target File Browser. However, if the S-function target is selected, Build Subsystem behaves identically to Generate S-function. (See Automated S-Function Generation.)
|
| Modularity of Subsystem Code | | Working with Data Structures |  |