User`s guide
Model Execution
6-17
name, parameter and signal storage class are included as part of the API for
the embedded style of code.
The single largest difference between the rapid prototyping and embedded
style of generated code is that the embedded code does not contain the
SimStruct data structure. The SimStruct defines a common API that the rapid
prototyping style of generated code relies heavily on. However, the
SimStruct
data structure supports many options and therefore consumes memory that is
notneededinanembeddedapplication.
The next major difference between the rapid prototyping and embedded style
of generated code is that the latter contains fewer entry-point functions. The
embedded style of code can be configured to have only one run-time function
model_step. You can define a single run-time function because the embedded
target:
• Can only be used with models that do not have continuous sample time (and
therefore no continuous states)
• Requires that all S-functions must be inlined with the Target Language
Compiler, which means that they do not access the
SimStruct data structure
Thus, when looking at the model execution pseudo-code presented earlier in
this chapter, you can eliminate the
Loop...EndLoop statements, and group the
ModelOutputs, LogTXY, and ModelUpdate into a single statement,
model_step.
Rapid Prototyping Model Functions
The rapid prototyping code defines the following functions that interface with
the run-time interface:
•
Model() — The model registration function. This is responsible for
initializing the work areas (e.g. allocating and setting pointers to various
data structures) needed by the model. The model registration function calls
the
MdlInitializeSizes and MdlInitializeSampleTimes functions. These
two functions are very similar to the S-function
mdlInitializeSizes and
mdlInitializeSampleTimes methods.
•
MdlStart(void) — After the model registration functions,
MdlInitializeSizes and MdlInitializeSampleTimes (located in