User`s guide
6 Program Architecture
6-28
Model Execution
• Execute a background task, for example, communicate with the host during
external mode simulation or introduce a wait state until the next sample
interval.
• Execute model (initiated by interrupt).
• Log data to buffer (if data logging is used).
• Return from interrupt.
Program Termination
• Call a function to terminate the program if it is designed to run for a finite
time — destroy the
SimStruct, deallocate memory, and write data to a file.
Rapid Prototyping Application Modules for System Dependent
Components
The application modules contained in the system dependent components
generally include a main module such as
rt_main.c containing the main entry
point for C. There may also be additional application modules for such things
as I/O support and timer handling.
Rapid Prototyping System Independent
Components
These components are collectively called system independent because all
environments use the same application modules to implement these
operations. This section steps through the model code (and if the model has
continuous states, calls one of the numerical integration routines). This section
also includes the code that defines, creates, and destroys the Simulink data
structure (
SimStruct). The model code and all S-functions included in the
program define their own
SimStruct.
The model code execution driver calls the functions in the model code to
compute the model outputs, update the discrete states, integrate the
continuous states (if applicable), and update time. These functions then write
their calculated data to the
SimStruct.