Function mode of operation
FIFO is a 'first in/first out' stack register.
The index and stack register are invisible to the user. The stack register is part of the internal state and can accept up to 2000 bytes with data (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 is cleared when 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
|
The N_MAX parameter provides 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 and no more elements can be placed in the stack register. If the stack register is empty (number of elements in the stack register = 0), then EMPTY is set to 1. The function has an X input and a Y input for various elementary data types.
X and Y are type ANY, which implies a predefined length. Due to the limited size of the internal stack register, only input and output types with an element size equal to or smaller than 200 bytes are accepted. Otherwise a runtime error occurs and an error message is generated that sets ENO to 0.