Software constructs, Ifthenelse block, While block – National Instruments AutoCode NI MATRIX User Manual

Page 147: Software constructs -39, Ifthenelse block -39 while block -39

Advertising
background image

Chapter 5

Generated Code Architecture

© National Instruments Corporation

5-39

AutoCode Reference

Software Constructs

These blocks provide the software constructs that are typically found in any
imperative programming language such as C, Pascal, and FORTRAN. The
following software constructs are supported in SystemBuild and
AutoCode:

IfThenElse Blocks (for conditional execution)

WHILE Blocks (for iterative computations)

Sequencers (for sequencing purpose)

Local Variable Blocks (for storing temporary data)

For the highest level of flexibility, the designs of the software construct
block require you to handle all of the details in implementing your
algorithm.

IfThenElse Block

The IfThenElse Block has two sections: one section contains the condition
to be evaluated and the other contains blocks that need to be executed if the
condition evaluates to True. An ELSE-IF or ELSE Block can be associated
with an IfThenElse Block. An ELSE-IF Block has a condition section while
an ELSE Block does not have one.

An IfThenElse Block in the block diagram along with the associated
ELSE-IF and ELSE Blocks is generated as an

if-else

,

if-else

compound statement in C and as an

if-elsif-else

statement in Ada.

For every if and else, if statement, the corresponding condition is
generated, followed by a branch that contains code for the blocks contained
in it. Block ordering with a container frame is just like that of a subsystem.

Variable Blocks must be used to get data out of the computations within the
IF branches, because there may be different numbers of outputs computed
from each branch. It is recommended that host local variable blocks be used
for this purpose.

WHILE Block

The WHILE block is a construct that allows a set of blocks to be repeatedly
executed during the subsystem’s scheduled time-frame during one
invocation of a subsystem or a procedure. AutoCode implements this
construct as a while statement in C and as a loop statement in Ada.

Advertising