User`s guide

6 Program Architecture
6-4
Model Execution
Before looking at the two styles of generated code, you need to have a high-level
understanding of how the generated model code is executed. The Real-Time
Workshop generates algorithmic code as defined by your model. You may
include your own code into your model via S-functions. S-functions can range
from high-level signal manipulation algorithms to low level device drivers.
The Real-Time Workshop also provides a run-time interface that executes the
generated model code. The run-time interface and model code are compiled
together to create the model executable. The diagram below shows a high-level
object-oriented view of the executable.
Figure 6-1: The Object-Oriented View of a Real-time Program
In general, the model execution driver does not change in concept between the
rapid prototyping and embedded style of generated code. The following sections
describe model execution for singletasking and multitasking environments
both for simulation (nonreal-time) and for real-time. For most models, the
multitasking environment will provide the most efficient model execution (i.e.,
fastest sample rate). See Chapter 7, “Models with Multiple Sample Rates,” for
more information on singletasking and multitasking execution.
The following concepts are useful in describing how models execute:
Initialization — Initializing the run-time interface code and the model code.
ModelOutputs Calling all blocks in your model that have a time hit at the
current point in time and having them produce their output. ModelOutputs
can be done in major or minor time steps. In major time steps, the output is
Model code
and S-functions
Run-Time Interface
Execution driver for model code,
operating system interface routines,
I/O dependent routines,
solver and data logging routines.