Generated Code Files for Targets You Build

S-Function MEX-Files

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.

Directory Structure of Generated Files

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 TypeModel TypeDirectory Under <cwd>/slprj/_sfprj/<mainModel>
SimulationMain (nonlibrary)/_self/sfun/src
SimulationLibrary/<libModel>/sfun/src
EmbeddableMain (nonlibrary)/_self/rtw/<sys_targ>/src
EmbeddableLibrary/<libModel>/rtw/<sys_targ>/src
CustomMain (nonlibrary)/_self/<custom>/src
CustomLibrary/<libModel>/<custom>/src

These definitions apply to the table:

Code Files for a Simulation Target

For a simulation target, you generate these files:

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.)

Code Files for an Embeddable Target

For an embeddable target, you generate integrated C code for the entire model:

You also generate intermediate code files during the target building process:

Other auxiliary files can appear depending on the type of embeddable target you choose for Real-Time Workshop code generation.

Code Files for a Custom Target

For a custom target, you generate these files:

Makefiles

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:

CompilerMakefileSymbol Definition File
Microsoft® Visual C++®<mainModel>_sfun.mak<mainModel>_sfun.def (required to build S-function MEX-files)
Open Watcom<mainModel>_sfun.wmkNone
lcc-win32 (default ANSI-C compiler)<mainModel>_sfun.lmkNone

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS