Detailed description
Original instructions
Function description
LIFO is a 'last in-first out' stack register.
The index and stack registers are invisible to the user. The stack register is part of the internal state and can accept up to 2000 bytes (i.e. 1000 INT or 500 REAL or 500 TIME elements).
The function block has two Boolean inputs, GET and SET, that are used to either read a value from or write a value to the stack register. If GET and SET are set simultaneously, SET (write) will be executed before GET (read).
The stack register will be cleared if R(eset) = 1.
The input parameters checking the stack must be set in a meaningful order to allow the function block to work properly.
A meaningful order is, for example:
Cycle
Parameters
Result
Cycle n
R=0, SET=0, GET=0
Stack not initialized
Cycle n+1
R=1, SET=0, GET=0
Stack initialized
Cycle n+2
R=0, SET=0, GET=0
End initializing
Cycle n+3
R=0, SET=1, GET=0
Loading stack with x values
Cycle n+x+1
R=0, SET=0, GET=0
End loading
Cycle n+x+2
R=0, SET=0, GET=1
Getting x values
Cycle n+x+2+x
R=0, SET=0, GET=1
Stack not empty
An N_MAX parameter defines the maximum number of elements in the stack register.
In a full stack register (number of elements in the stack register = N_MAX <= 2000 / (size of (X)), FULL is set to 1. Cannot put any more elements onto stack register.
In an empty stack register (number of elements in the stack register = 0), EMPTY is set to 1.
The function has one X input and one Y output for various data types.
X and Y are type ANY, which implies a predefined length. Due to the limited size of the stack register, only data types with an element size less than or equal to 200 bytes are allowed. Otherwise a runtime error will be generated and the ENO output is set to 0.