User`s guide

6 Program Architecture
6-32
Initialize a vector of sample times and sample time offsets and store this
vector in the
SimStruct.
Store the values of the block initial conditions and program parameters in
the
SimStruct.
Compute the block and system outputs.
Update the discrete state vector.
Compute derivatives for continuous models.
Perform an orderly termination at the end of the program (when the current
time equals the final time, if a final time is specified).
Collect block and scope data for data logging (either with the Real-Time
Workshop or third-party tools).
The SimStruct Data Structure
The generated code includes the file simstruc.h, which contains the definition
of the
SimStruct data structure. Each instance of a model (or an S-function) in
the program creates its own
SimStruct, which it uses for reading and writing
data.
All functions in the generated code are public. For this reason, there can be only
one instance of a model in a real-time program. This function, which always
has the same name as the model, is called during program initialization to
return a pointer to the
SimStruct and initialize any S-functions.
Rapid Prototyping Model Code Functions
The functions defined by the model code are called at various stages of program
execution (i.e., initialization, model execution, or program termination).
The following diagram illustrates the functions defined in the generated code
and shows what part of the program executes each function.