When to use it
A FIFO (first-in, first-out queue) decouples a producer from a consumer: write when there's room, read when there's data, and the two don't have to move in lockstep. This one is synchronous, both sides share a clock. For crossing clock domains you need an async FIFO with gray-coded pointers instead.
How it works
A small memory plus a write pointer and a read pointer. The trick for telling full from empty, both are "pointers equal", is to make each pointer one bit wider than the address: when the extra bits differ but the address bits match, the FIFO is full.
Gotchas
- Only write when
!fulland read when!empty, the logic ignores the request otherwise, but your data would be lost or stale. - Depth should be a power of two so the pointers wrap cleanly.