Continuous semantics, Looping concepts, Terminology – National Instruments AutoCode NI MATRIX User Manual

Page 137: Loops and scalar code, Continuous semantics -29, Looping concepts -29, Terminology -29 loops and scalar code -29

Advertising
background image

Chapter 5

Generated Code Architecture

© National Instruments Corporation

5-29

AutoCode Reference

Continuous Semantics

The state data within a continuous subsystem are called States and State
Derivatives. These look very similar to the discrete equivalents, except that
State data is integrated by the integrator algorithm. This is what is intended
by using states within the continuous system. Therefore, if you just
translated the previous discrete BlockScript block example into using
States and State Derivatives, the results would be quite different. So, States
are more than just persistent data in the continuous subsystem.

Looping Concepts

BlockScript contains features within the language to implement loops.
However, loops have a far-reaching effect on the generated code. This
section describes the effects and limitations of loops in the generated code.

Terminology

The discussion of loops in BlockScript cannot proceed until some terms are
defined. We must introduce the concept of rolled and unrolled loops. A
rolled loop is just a loop in the standard programming sense. An unrolled
loop is not a loop at all. An unrolled loop is the body of the loop generated
for each iteration of the loop. In other words, an unrolled loop is the
expansion of that loop over the range of the loop bounds.

Other terms include soft-subscript and hard-subscript. A soft-subscript
is an array subscript that is run-time bound to another variable. A
hard-subscript is an array subscript that is known during code generation,
that is, a constant value.

Loops and Scalar Code

When AutoCode is used for scalar code generation, code for the
BlockScript must be generated using scalar variables. However, the syntax
of BlockScript uses arrays, especially when referring to the inputs and
outputs of a block. So, when generating scalar code, AutoCode must
translate array variables in BlockScript into a set of scalars. This
transformation causes a significant increase in the size of code as well as
prevents some types of algorithms from being directly implemented. The
scalar representation of BlockScript variables applies to inputs, outputs,
and states. Parameters and local variables of the BlockScript can be either
scalar or arrays. This means that only hard-subscripts can be used with
inputs, outputs, and states for scalar code generation.

Advertising