Chapter 5
Generated Code Architecture
5-8
ni.com
Discrete Subsystem Interface Layer
This layer comes in two variations to allow for both an optimized and
general solution. The external interface to a discrete subsystem is
represented by two structures, one representing the subsystem external
inputs and the other the subsystem external outputs. These structures are
generically referred to as the
U
-structure for the inputs and
Y
-structure for
the outputs. Within the subsystem, pointers to the
U
and
Y
structures are
defined as formal parameters to the subsystem procedure with the names
U
and
Y
, respectively.
Single-Rate System
A single-rate system, (that is, a system that contains only one subsystem
and no disconnected signals) is optimized to eliminate extra copies of the
external input/output data from the System interface. Therefore, a
single-rate model uses the System external inputs as the subsystem’s
external inputs, and the subsystem’s external outputs as the System’s
external outputs.
Multi-Rate System
A multi-rate system represents the general case for external input and
output data. In a multi-rate system, a particular subsystem output might be
used by other subsystems or might be an external system output or some
combination. AutoCode minimizes the connections between subsystems
and the system external output. To accomplish this, AutoCode must
rearrange the ordering of members within the
U
and
Y
structures, as
opposed to the order being maintained in the single-rate case.
Sample and Hold
A property of a multi-rate model is the concept of sample and hold. This
refers to the capturing (holding) of the input data of a subsystem until it
completes. For example, in Figure 5-1, assume subsystem 1 executes at
a rate of 0.1 (10 Hz) while subsystem 2 executes at 0.2 (5 Hz). Each
subsystem depends on the other for 1 input. Given that subsystem 1
executes twice as fast as subsystem 2, the output of subsystem 1, used by
subsystem 2, changes during subsystem 2’s execution. This means that
if there were no sample and hold, subsystem 2 could potentially compute
values using different values at different times during the execution of the
subsystem. This non-determinacy can produce unexpected results.