How occupancy changes
Occupancy rises when accepted writes outnumber accepted reads and falls when reads outnumber writes.
write_accept = write_enable AND NOT full
read_accept = read_enable AND NOT empty
Depth sizing
Depth must cover the maximum accumulated rate difference, backpressure interval, and any implementation margin. Average equal rates do not guarantee that a shallow FIFO is safe during bursts.
A writer sends 80 words at 400 MHz while the reader consumes at 250 MHz. During those 80 writer cycles, the reader consumes about 50 words, so occupancy grows by 30.
Add margin for synchronization and control latency. A practical implementation might choose the next convenient depth, such as 32 or 64 depending on the full system assumptions.
Asynchronous FIFO note
When write and read clocks differ, pointer values cross clock domains. Gray-coded pointers are commonly synchronized because only one bit changes between adjacent counts. The memory data path and pointer-control path still need a proven CDC architecture.
Common mistakes
- Sizing from average throughput while ignoring the longest burst or stall.
- Writing when full or reading when empty.
- Comparing unsynchronized binary pointers across clock domains.
- Forgetting that flag latency changes usable capacity near the boundary.