User`s guide

Overview of the C MEX S-Function Routines
3-17
The following sections discuss each of these routines and give an overview of
themorecommonmacrosusedtoaccessthe
SimStruct data structure. A full
list of the macros is given in “The C MEX S -Function SimStruct” on page 3–9 7.
Alternate Calling Structure for the Real Time Workshop
If you use the Real-Time Workshop to generate code for a model that contains
S-functions, Simulink does not go through the entire calling sequence outlined
above. Initialization proceeds as outlined above until Simulink reaches the
mdlInitializeConditions routine. After calling mdlInitializeConditions,
Simulink calls
mdlRTW, an S-function routine unique to the Real-Time
Workshop,
mdlTerminate, and exits. This picture shows the calling sequence:
Figure 3-2: S-Function Calling Sequence when Simulink is Used with the
Real-Time Workshop
For more information aboutthe Re al-Time Workshop and how it interacts with
S-functions, see The Real-Time Workshop User’s Guide and The Target
Language Compiler Reference Guide.
mdlRTW
For code generation only
p. 3-54
mdlTerminate
p. 3-53
mdlSetInputPortWidth/mdlSetOutputPortWidth
mdlInitializeSizes
mdlInitializeSampleTimes
mdlSetWorkWidths
mdlStart
p. 3-28
p. 3-35
p. 3-46
p. 3-48
p. 3-36
mdlSetInputPortSampleTime/mdlSetOutputPortSampleTime
p. 3-33
mdlInitializeConditions
p. 3-48