Procedure data, Pre-init phase, Init, output, and state phases – National Instruments AutoCode NI MATRIX User Manual

Page 118: Copy back and duplicates, Procedure data -10

Advertising
background image

Chapter 5

Generated Code Architecture

AutoCode Reference

5-10

ni.com

Procedure Data

Procedure SuperBlocks have inputs, outputs and states independent of the
subsystem from which the procedure is called. This is required to properly
implement the characteristics of a procedure; those characteristics include
reusability and reentrancy. Therefore, for each instance of a call to a
procedure SuperBlock within a subsystem, a set of static variables is
created for each of the structures that describe the definition of the
procedure.

Pre-init Phase

The purpose of the pre-init phase is to initialize all of the subsystem’s static
data. This phase is called for each subsystem before the simulation begins,
that is, before time = 0.0.

Init, Output, and State Phases

A subsystem has three phases that can be easily seen in the generated code.
The code related to these phases is guarded by If-statements or comments.
The subsystem can be in multiple phases at the same time.

Init Phase—Is executed only once at the first time the subsystem is
called. This might be at time = 0.0 but might be later if the subsystem
is skewed, triggered, or enabled. Each block can have code for its
initialization. Activities such as setting initial state and output data are
typical.

Output Phase—Occurs for each time point for the subsystem. The
purpose of this phase is for each block to compute its outputs for the
current time point. The output phase always occurs before the state
phase.

State Phase—Occurs for each time point for a discrete subsystem and
can be multiple times for a continuous subsystem. The purpose of this
phase is for each block to compute the value of next state to be used by
the block at the next time point. This phase always occurs after the
output phase.

Copy Back and Duplicates

After all of the code for the three phases has had a chance to execute, there
might be additional code to perform what is called a copy-back, or to deal
with duplicates. This only applies to subsystem external outputs. A
copy-back occurs only in vectorizing code in which part of an array is used
as a subsystem external output. Duplicates can only occur in a single-rate

Advertising