Understanding FIFO: Full and Empty States

Sep 18, 2024

FIFO Full and Empty Explanation

Introduction

  • Discussing FIFO (First In, First Out) conditions: full and empty.
  • Example with four locations: 00, 01, 10, 11.

Key Concepts

Overflow and Underflow

  • Overflow: Occurs when writing to FIFO without reading, leading to data loss.
  • Underflow: Occurs when reading from FIFO when no data is available, leading to junk data.

Signals for Control

  • Full Signal: Indicates FIFO is full; prevents further writes.
    • Generated when all four locations have data.
  • Empty Signal: Indicates FIFO is empty; prevents reads.
    • Generated when there is no data to read.

Pointers in FIFO

  • Write Pointer (WPtr): Indicates the location where the next write will occur.
  • Read Pointer (RPtr): Indicates the location where the next read will occur.

Pointer Behavior

  • Initially, both pointers start at 00.
  • WPtr increments with each write, and RPtr increments with each read.
  • Condition for full: WPtr equals RPtr after writing four times.
  • Condition for empty: WPtr equals RPtr with no data.

Extra Bit Requirement

  • Need an extra bit to represent FIFO states due to pointer comparison.
    • With four locations, two bits alone are insufficient to distinguish between full and empty states.
    • With three bits, the most significant bit (MSB) helps differentiate between full and empty conditions.

Full Condition Example

  • If five data pieces are written and one is read, it results in four filled locations.
    • Comparing pointers shows MSB is not equal while remaining bits are equal, generating the full condition.

Empty Condition Example

  • If three writes and then three reads occur, both pointers eventually match, indicating empty status.
    • Condition for empty: WPtr equals RPtr.

Conclusion

  • FIFO control is essential to prevent overflow and underflow.
  • Proper use of pointers and signals ensures data integrity in FIFO operations.