Module 7: Advanced RTL Design Techniques · 7.4 FIFOs — Synchronous & Asynchronous

Why Every Design Has a FIFO in It

Section 7.3 addressed datapath flow control using stall mechanisms. When an upstream producer cannot pause or downstream consumers service data intermittently, digital systems insert elastic buffer memories. A First-In, First-Out (FIFO) memory provides hardware buffering to decouple producer and consumer execution rates.

Consider a UART receiver interface. A UART receives byte frames every 100 microseconds. A host microprocessor may remain occupied with higher-priority tasks for 200 microseconds. Without intermediate buffering, incoming bytes overwrite unread data. A FIFO buffer absorbs instantaneous rate differences, preventing data corruption without halting producer hardware.

Standard FIFO Interface Contract

Every FIFO architecture provides an industry-standard interface:

FIFO interface: write side, read side, full and empty
Figure 1: The minimal FIFO interface

  • Write Port (wdata, wr_en): The producer asserts write data and enables wr_en to push entries into the queue.
  • Full Indicator (full): Asserts when the buffer reaches capacity, signaling the producer to withhold write transactions.
  • Read Port (rdata, rd_en): The consumer asserts rd_en to pop the oldest stored entry onto rdata.
  • Empty Indicator (empty): Asserts when the queue contains zero valid entries, warning the consumer to pause read requests.

This interface implements bilateral backpressure flow control. The full flag protects the buffer from overflow, while the empty flag protects the consumer from reading invalid data.

Rate Mismatch Versus Burst Buffering

FIFO architectures solve two primary data transport challenges:

  1. Continuous Rate Jitter: Average producer and consumer bandwidths match over time, but instantaneous rates fluctuate. The FIFO operates roughly half-full to smooth timing variance.
  2. High-Speed Burst Traffic: Producers deliver rapid bursts of contiguous data followed by extended idle intervals. Network interfaces receiving Ethernet packets exhibit this behavior. The buffer capacity must hold the entire burst volume until consumer processing begins.

Calculating Minimum Buffer Depth

FIFO buffer depth is a calculated architectural requirement. Calculate minimum burst buffer depth using the standard formula:

$$\text{Required Depth} \geq \text{Burst Size} - (\text{Consumer Drain Rate} \times \text{Burst Duration})$$

Suppose an input port delivers a 64-byte packet across 10 clock cycles. During this window, a consumer drains 1 byte every 2 clock cycles (5 bytes total). The FIFO buffer must hold at least $64 - 5 = 59$ bytes. Undersizing the FIFO causes buffer overflow and packet drops.

System-on-Chip (SoC) peripherals, such as DMA engines, USB endpoints, and PCIe bridges, specify FIFO depths rigorously to guarantee zero packet loss under worst-case bus latencies.

Section Roadmap

This section develops FIFO architectures systematically:

  1. Synchronous FIFO: Both ports share a common clock signal to establish circular pointer and flag logic.
  2. Gray Code Conversion: Mathematical properties of Gray-code pointers eliminate multi-bit race conditions across clock boundaries.
  3. Asynchronous FIFO: Separate read and write clock domains operate safely across Clock Domain Crossing (CDC) boundaries.

Verification Exercise

An environmental sensor transmits 32 sample measurements across 16 clock cycles, followed by an idle interval. A digital filter drains one sample every 3 clock cycles continuously. Calculate the minimum FIFO depth required to prevent data loss.

View Solution

During the 16-cycle transmission burst, the filter consumes:

$$\lfloor 16 / 3 \rfloor = 5\text{ samples}$$

The FIFO buffer must store the unread remainder:

$$\text{Minimum Depth} = 32 - 5 = 27\text{ entries}$$

In practical RTL implementations, designers round capacity up to a power of two (32 entries) to simplify pointer wraparound logic.

FIFO memories absorb bandwidth differences between independent digital subsystems. The next article implements a synchronous FIFO and details circular pointer tracking logic.

← A Pipelined Multiply-Accumulate Unit The Synchronous FIFO and the Full/Empty Problem →