Chip Foundry Services Request Assessment

Asynchronous Fifo Design

An asynchronous FIFO moves data safely between two clock domains that have no fixed timing relationship to each other, built around a dual-port SRAM core whose write side runs entirely on one clock and whose read side runs entirely on another — the real engineering problem isn't the memory array itself, which is just a standard dual-port cell, but the read and write pointers that track how full the FIFO is, because comparing a pointer generated in one clock domain against a pointer generated in a completely unrelated clock domain is exactly the kind of operation that produces metastability if done carelessly.

Write pointer increments on write clock
Tracks the next dual-port SRAM address to fill
Read pointer increments on read clock
Tracks the next address to drain
Pointers must cross into the OTHER clock domain to compareFull flag needs the read pointer; empty flag needs the write pointer
Binary pointer comparison is unsafe
Multiple bits can change at once — a synchronizer can catch a torn value
Gray-coded pointers change one bit per increment
A synchronizer catching mid-transition still reads a valid value
Two-flop synchronizers pass each Gray pointer across
Resolves metastability with one cycle of added latency
Full/empty flags generated from the synchronized pointers
Each side only ever sees a safely-crossed version of the other's pointer

Gray coding isn't an arbitrary choice of counter format — it's the specific property that makes crossing a multi-bit pointer into an unrelated clock domain safe at all. An ordinary binary counter can change several bits simultaneously on a single increment — going from 0111 to 1000 flips four bits at once — and if a synchronizer samples that counter at the exact moment several bits are transitioning, it can latch an inconsistent mix of old and new bit values that was never a valid count at any point in time; a Gray-coded counter instead guarantees that only one bit ever changes per increment, so a synchronizer catching the counter mid-transition reads either the value just before or just after the increment, both of which are valid, real counts the FIFO actually passed through. This single property is why every reliable asynchronous FIFO design uses Gray-coded pointers rather than raw binary ones for the values that have to cross clock domains.

Two-flip-flop synchronizers resolve the metastability that crossing a clock domain inherently risks, at the direct cost of one added cycle of latency per bit crossed. When a signal changes right at the sampling edge of a flip-flop in a different, unrelated clock domain, that flip-flop can briefly enter a metastable state — neither a clean 0 nor a clean 1 — before settling to one value or the other; a single flip-flop sampling that signal might pass the metastable glitch downstream, but chaining a second flip-flop behind the first gives the first flip-flop's output a full clock cycle to resolve to a stable value before the second flip-flop samples it, reducing the probability of a metastability failure propagating to a negligible level. Every Gray-coded pointer bit crossing into the opposite clock domain goes through its own two-flop synchronizer, which is why asynchronous FIFOs always carry at least one extra cycle of pointer-crossing latency baked into their full and empty flag timing.

Full and empty flags are generated from synchronized pointers specifically, not from the FIFO's own native pointers, which is what makes the flag logic inherently a cycle or more conservative than the FIFO's true instantaneous state. The write side can only know how full the FIFO actually is by comparing its own write pointer against a synchronized copy of the read pointer that has already crossed over from the read clock domain — and because that synchronized copy is always at least one cycle stale relative to the read domain's actual current state, the full flag can assert slightly earlier than the FIFO is truly full, and conversely the empty flag can assert slightly earlier than the FIFO is truly empty. This conservative-by-design behavior is a deliberate tradeoff: it guarantees the FIFO never reports available space or data that isn't safely there yet, at the cost of giving up a small amount of the FIFO's actual capacity to synchronization margin.

Binary Pointer Crossing vs. Gray-Coded Pointer Crossing a synchronizer sampling mid-transition reads garbage from one, a valid value from the other Binary counter crossing (unsafe) 0111 → 1000 four bits change at once synchronizer samples mid-transition — can catch a mix of old and new bits result: a value the counter never actually held at any point in time Gray-coded crossing (safe) 0100 → 1100 only one bit changes synchronizer samples mid-transition — reads either the before or after value result: always a value the counter genuinely passed through

The dual-port SRAM array itself, covered in more depth in this site's article on 8T, 10T, and dual-port SRAM variants, is actually the least complicated part of this entire design — the memory cells don't care which clock wrote or read them, only the pointers tracking those accesses do. A FIFO's storage array is simply a dual-port SRAM with one write-clock-driven port and one read-clock-driven port, addressed directly by the raw binary (not Gray-coded) write and read pointers on their own native sides — the Gray-coding and synchronization machinery described above exists purely to let each side safely know roughly where the other side currently is for flag generation, not because the memory array itself needs any special clock-domain handling at all.

Read an asynchronous FIFO through a *the-pointers-are-the-hard-part* lens rather than a *dual-port-memory* lens: the storage array is ordinary dual-port SRAM that would work the same way regardless of clocking, and the entire engineering discipline — Gray coding, two-flop synchronizers, conservative full/empty flag generation — exists solely to let two pointers living in unrelated clock domains learn enough about each other to stay safe, which is precisely why getting FIFO depth and synchronizer latency right is a timing-closure problem first and a memory-design problem only secondarily.