# FIFO

## `FIFO` (FB)

FUNCTION\_BLOCK FIFO

FIFO is a First-In First-Out memory with x storage locations for INT data. The two outputs xEmpty and xFull indicate when the memory is empty or full. The input xReset clears the entire contents of the memory. The FIFO is written with an INT by setting TRUE on the xWrite input. A read command is executed by setting TRUE on xRead. Reading and writing can be performed simultaneously in one cycle. The block reads or writes in every cycle. The FIFO can be controlled via 3 methods mRead, mWrite, mReset.

InOut:

| Scope  | Name           | Type           | Comment                              |
| ------ | -------------- | -------------- | ------------------------------------ |
| Input  | `iDataIn`      | `INT`          | Data to write into the FIFO          |
| Input  | `xRead`        | `BOOL`         | Read control                         |
| Input  | `xWrite`       | `BOOL`         | Write control                        |
| Input  | `xReset`       | `BOOL`         | Reset control                        |
| Input  | `aiFifoBuffer` | POINTER TO INT | FIFO with x slots                    |
| Output | `iDataOut`     | `INT`          | Data from the FIFO that were read    |
| Output | `xEmpty`       | `BOOL`         | xEmpty = TRUE means: memory is empty |
| Output | `xFull`        | `BOOL`         | xFull = TRUE means: memory is full   |
| Output | `diDataNumber` | `DINT`         | Number of data items in the FIFO     |
