Calculating the minimum depth of an asynchronous FIFO is one of the most frequently asked questions in VLSI and ASIC design interviews. Get the calculation wrong in silicon, and your chip drops data. Here is the definitive formula and how to solve it step-by-step.
An asynchronous FIFO connects a fast clock domain to a slow clock domain (or vice versa). Because the clocks operate at different speeds, data might arrive in bursts much faster than the receiving side can read it out.
The FIFO acts as a buffer (an elastic reservoir). The "Depth" of the FIFO is the number of memory slots required to absorb the maximum possible burst of incoming data without overflowing, giving the slower read side enough time to catch up.
To find the minimum safe depth, we must look at the worst-case scenario: maximum back-to-back writes, combined with the slowest possible reads.
Let's break down these terms:
The formula is simply computing: "How many items did I write?" MINUS "How many items did I manage to read out while the writing was happening?" The remaining un-read items must be stored in the FIFO!
Question: You are writing data at 100 MHz and reading at 40 MHz. The data comes in bursts of 120 items continuously. What is the minimum FIFO depth required?
Step-by-Step Solution:
Burst_Size = 120F_wr = 100 MHz, F_rd = 40 MHzTime = Burst_Size / F_wr = 120 / 100 MHz = 1.2 microsecondsItems_Read = Time * F_rd = 1.2 us * 40 MHz = 48 itemsLeftover = 120 (written) - 48 (read) = 72 itemsAnswer: The absolute minimum FIFO depth is 72. (In industry, you would round this up to the nearest power of two, which is 128, because RAMs are instantiated in powers of two).
Interviewers love to make the scenario more complex by adding idle cycles.
"Write frequency is 100MHz, Read frequency is 100MHz. The writer sends 80 items every 100 clock cycles. The reader reads 8 items every 10 clock cycles. What is the minimum depth?"
Wait, if both are 100MHz, shouldn't the depth be 0? No. You must calculate the worst-case continuous burst.
The worst case occurs when the writer goes idle for 20 cycles, writes 80 back-to-back, and then immediately writes 80 back-to-back in the next 100-cycle window! The actual Burst_Size is 160. Always identify the absolute worst-case packing of data before applying the formula.
A: Theoretically, if F_wr = F_rd and data is continuous, a depth of 1 is sufficient. However, in physical silicon, clock jitter, phase skew, and synchronizer latency mean you always need a minimum depth of 4 to 8 to prevent false "Full" flags.
A: Asynchronous FIFOs use Gray code counters to pass the read/write pointers across clock domains. Gray code naturally wraps around cleanly only when the maximum value is a power of 2 (e.g., 0 to 15, or 0 to 127). Standard SRAM macros are also generated in powers of two.