| Stateflow User's Guide |
 |
Configuring a Custom Target in Stateflow
A Stateflow custom target (named anything but sfun or rtw) is a convenience for collecting the generated code for the Stateflow charts in a model. After you collect the code, you can use this code at your own discretion in building your own applications. You configure a custom target in the Model Explorer with the following procedure:
- From the Stateflow diagram editor toolbar, select Explore
.
- The Model Explorer appears with the Stateflow chart highlighted in the Model Hierarchy pane.

- In the Model Explorer, in the left Model Hierarchy pane, select the Simulink model with the custom target.

- The custom target (in this example,
ctarg) appears as a child of the Simulink model. Custom targets have names other than sfun or rtw.
If you need to create a custom target in the Model Explorer, see Adding a Target in the Model Explorer.
- In the Contents pane, click the row for the custom target
ctarg.
- The Stateflow Target Builder dialog appears in the dynamic dialog on the right, as shown.

- In the Stateflow Target Builder dynamic dialog, in the long field below the Target Language descriptor, select one of the following build options:
- Generate code only (non-incremental) to regenerate code for all charts in the model.
- Rebuild All (including libraries) to rebuild the target, including chart libraries, from scratch.
- Make without generating code to invoke the Make process without generating code. This is useful when you have custom source files that need to be recompiled within a Stateflow incremental build mechanism that does not detect changes in custom software files.
- To specify code generation options for a custom target, select the Coder Options.
- The Coder Options dialog box for the custom target appears as follows:

- Select any or all of the following options:
- The following options are unique to custom targets:
- I/O Format Options -- Can be any one of the following:
-
Select Use global input/output data to generate chart input and output data as global variables.
Select Pack input/output data into structures to generate structures for chart input data and chart output data.
The Separate argument for input/output data generates input and output data as separate arguments to a function.
- Generate chart initializer function -- Generates a function initializer of data.
- Multiinstance capable code -- Generates multiply instantiable chart objects instead of a static definition.
The following options are also available for RTW targets. See Configuring Real-Time Workshop for Stateflow for a description.
- Comments in generated code
- Use bitsets for storing state configuration
- Use bitsets for storing boolean data
- Compact nested if-else using logical AND/OR operators
- Recognize if-elseif-else in nested if-else statements
- Replace constant expressions by a single constant
- Minimize array reads using temporary variables
- Preserve symbol names
- Append symbol names with parent names
- Use chart names with no mangling
Custom code options are selected through the Target Options button. To specify custom code options for your rtw target, see Integrating Custom Code with Stateflow Targets.
- Select (check) the Use settings for all libraries option if you want the settings that you specify for this target to apply to all the Stateflow charts contributed by library models as well, s.
- To specify custom code options for the simulation target, select Target Options.
- See Integrating Custom Code with Stateflow Targets for details on using the custom target to integrate custom code with generated code for the Stateflow diagrams in the model.
- To finish configuring the custom target, do one of the following:
- Click Apply to apply the selected options.
- Click OK to apply the options and close the dialog.
- Click Build to build the RTW target.
| Configuring the Stateflow Blocks in Library Models for Real-Time Workshop | | Integrating Custom Code with Stateflow Targets |  |
© 1994-2005 The MathWorks, Inc.