Technical data
3
Writing Target Language Files
3-18
Start(block, system)
Include a Start function to place code into MdlStart. The code inside MdlStart
executes once and only once. Typically, you include a
Start function to execute
code once at the beginning of the simulation (e.g., initialize values in the work
vectors; see
backlash.tlc,) or code that does not need to be re-executed when
the subsystem in which it resides enables. See
constant.tlc for an example of
the
Start function.
InitializeConditions(block, system)
TLC code that is generated from the block’s InitializeConditions function
ends up in one of two places. The code is placed into
MdlStart if the Simulink
block does not reside in a nonvirtual subsystem that requires an
Initialize
function. That is, a nonvirtual subsystem contains an
Initialize function
when it is configured to reset states on enable. If this is the case, the TLC code
generated from this block function is placed in the subsystem
Initialize
function, and
MdlStart will call this Initialize function. However, if the
Simulink block resides in root or a nonvirtual subsystem that does not require
an
Initialize function, the code generated from this block function is placed
directly (inlined) into
MdlStart.
There is a subtle difference between the block functions
Start and
InitializeConditions. Typically, you include a Start function to execute code
that does not need to re-execute when the subsystem in which it resides
enables, and you include an
InitializeConditions function to execute code
that must re-execute when the subsystem in which it resides enables. See
delay.tlc for an example of the InitializeConditions function.
Outputs(block, system)
A block should generally include an Outputs function. The TLC code generated
by a block’s
Outputs function is placed in one of two places. The code is placed
directly in
MdlOutputs if the Simulink block does not reside in a nonvirtual
subsystem. The code is placed in a subsystem’s
Outputs function if the
Simulink block resides in a nonvirtual subsystem. See
gain.tlc for an
example of the
Outputs function.
Note: Zero-crossing reset code is placed in the Outputs function.