Chapter 5 Generated Code Architecture
© National Instruments Corporation 5-3 AutoCode Reference
Global StorageIn a strict modular programming paradigm, global storage is strictly
avoided. However, global storage can be used safely and provides
significant benefits in terms of code size and speed. Traditionally,
AutoCode generates code that enforces a policy of safe access to global
data. However, the need for potentially unsafe uses of global memory to
achieve tight and efficient production code requires more latitude in the
code generation, and requires a lot of effort to design properly. There is the
possibility of losing determinacy and reentrancy.
Percent vars (%var)
Percent vars represent parameterized data specified within some
SystemBuild Blocks. A %var is generated as a global variable. AutoCode
uses a %var variable in a read-only context. If a %var parameter can be
written to, as in the case of passing parameters to a UCB, duplicate data is
generated to allow the data to change, but at the same time, not affect the
read-only uses. Notice that a %var value can be changed as part of a startup
procedure SuperBlock. Refer to the Startup section for details.
Global Variable Blocks
Global Variable Blocks are implemented as global variables in the
generated code. AutoCode sequences and generates code that provides a
safe and deterministic use of variables blocks. You must generate variable
block callouts to form a critical section to maintain integrity of the global
variable blocks when used in a pre-emptive multi-tasking system. This
safety can be expensive if performance is an issue and you might not get
the behavior you want because of the special sequencing.
Sequencing Variable Blocks
The sequence when a read from and write to a variable block occurs is
critical in maintaining determinacy. The following is a summary of when
the block will execute.
•Read-From Variable Block (ALL Addressing mode)—These
blocks execute before any other type of block within the subsystem,
procedure, or sequence frame. The data from the variable block is
copied into local variables. These local variables are accessed in place
of the actual global variable.