| Stateflow® | ![]() |
| On this page… |
|---|
Directory Structure of Generated Files Code Files for a Simulation Target Code Files for an Embeddable Target |
If you have a Simulink model named mainModel.mdl, which contains two Stateflow blocks named chart1 and chart2, you have a machine named mainModel that parents two charts named chart1 and chart2.
When you simulate the Stateflow chart for mainModel.mdl, you generate code for mainModel.mdl that compiles into an S-function MEX-file. MEX-file extensions are platform-specific, as described in the MATLAB software documentation. For example, on 32-bit Windows PC platforms, you generate a MEX-file for mainModel named mainModel_sfun.mexw32. On Linux® x86-64 platforms, you generate mainModel_sfun.mexa64.
S-function MEX files appear in the current MATLAB directory. You can change this location at the MATLAB command prompt with a cd command.
Most of the code files that you generate reside in a subdirectory of the current MATLAB directory. This table summarizes the directory structure for different targets.
| Target Type | Model Type | Directory Under <cwd>/slprj/_sfprj/<mainModel> |
|---|---|---|
| Simulation | Main (nonlibrary) | /_self/sfun/src |
| Simulation | Library | /<libModel>/sfun/src |
| Embeddable | Main (nonlibrary) | /_self/rtw/<sys_targ>/src |
| Embeddable | Library | /<libModel>/rtw/<sys_targ>/src |
| Custom | Main (nonlibrary) | /_self/<custom>/src |
| Custom | Library | /<libModel>/<custom>/src |
These definitions apply to the table:
<cwd> is the current MATLAB directory.
<mainModel> is the name of the main model.
<libModel> is the name of the library model.
<sys_targ> is the type of embeddable target (for example, grt or ert).
<custom> is the name of the custom target.
Note For embeddable targets, the integrated C code for the entire model resides in the subdirectory <mainModel>_<sys_targ>_rtw of the current MATLAB directory. The executable file generated for the entire model resides in the current MATLAB directory. |
For a simulation target, you generate these files:
<model>_sfun.h is the machine header file. It contains:
All the defined global variables needed for the generated code
Type definition of the Stateflow machine-specific data structure that holds machine-parented local data
External declarations of any Stateflow machine-specific global variables and functions
Custom code strings that you specify
<model>_sfun.c is the machine source file. It includes the machine header file and all the chart header files (described below) and contains:
All the machine-parented event broadcast functions
Simulink interface code
<model>_sfun_registry.c is a machine registry file that contains Simulink interface code.
cn_<model>.h is the chart header file for the chart chartn, where n = 1, 2, 3, and so on, depending on how many charts your model has (see the following note). This header file contains type definitions of the chart-specific data structures that hold chart-parented local data and states.
cn_<model>.c is the chart source file for chartn, where n = 1, 2, 3, and so on, depending on how many charts your model has (see the following note). This source file includes the machine header file and the corresponding chart header file and also contains:
Chart-parented data initialization code
Chart execution code (state entry, during, and exit actions, and so on)
Chart-specific Simulink interface code
For library models, a static library file named <libModel>_sfun resides in the same directory as the source code. The file extension depends on the platform. (On a Windows operating system, it is <libModel>_sfun.lib, but on a UNIX operating system, it is <libModel>_sfun.a.)
For an embeddable target, you generate integrated C code for the entire model:
<model>.h
<model>.c
You also generate intermediate code files during the target building process:
<model>_rtw.tlh
<model>_rtw.tlc
cn_<model>.tlh, where n = 1, 2, 3, and so on, depending on how many charts your model has
cn_<model>.tlc, where n = 1, 2, 3, and so on, depending on how many charts your model has
Other auxiliary files can appear depending on the type of embeddable target you choose for Real-Time Workshop code generation.
For a custom target, you generate these files:
<model>_<custom>.h where <custom> is the name of the custom target.
<model>_<custom>.c where <custom> is the name of the custom target.
cn_<model>.h is the chart header file for the chart chartn, where n = 1, 2, 3, and so on, depending on how many charts your model has. This file contains type definitions of the chart-specific data structures that hold chart-parented local data and states.
cn_<model>.c is the chart source file for chartn, where n = 1, 2, 3, and so on, depending on how many charts your model has. This chart source file includes the machine header file and the corresponding chart header file.
You generate makefiles for your model that are platform and compiler-specific. On UNIX platforms, you generate a gmake-compatible makefile named <mainModel>_sfun.mku that compiles all your generated code into an executable. On PC platforms, you generate an ANSI-C compiler-specific makefile based on your C-MEX setup:
| Compiler | Makefile | Symbol Definition File |
|---|---|---|
| Microsoft® Visual C++® | <mainModel>_sfun.mak | <mainModel>_sfun.def (required to build S-function MEX-files) |
| Open Watcom | <mainModel>_sfun.wmk | None |
| lcc-win32 (default ANSI-C compiler) | <mainModel>_sfun.lmk | None |
Note For an updated list of supported PC compilers, go to: http://www.mathworks.com/support/compilers/current_release/ |
![]() | Error Messages When Parsing Charts and Generating Code | Traceability of Stateflow Objects in Real-Time Workshop Generated Code | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |