
Almost every block on a chip has a FIFO somewhere: between a bus and a DMA engine, inside a network-on-chip router, in front of a memory controller, at the edge of an accelerator. The idea is simple. Data goes in at one end and comes out at the other in the same order. The engineering is in the details: telling a full FIFO from an empty one, deciding what happens when both sides act in the same cycle, and keeping the flag logic off the critical path.
This is Part 1 of a 48-part series on FIFO design, from the plain synchronous FIFO to replay, speculative, banked and multi-clock designs. We start with the one everything else builds on: a FIFO where the writer and the reader share one clock.
Key takeaways
- A synchronous FIFO is a small memory plus two pointers: a write pointer to the next free slot and a read pointer to the oldest entry.
- With a power-of-two depth, one extra pointer bit separates full from empty. Equal pointers mean empty. Equal index bits with different top bits mean full.
- Decide the same-cycle rules on purpose: what a push does when the FIFO is full and a pop happens in the same cycle, and what the read data looks like when the read and write address match.
- The flag compare is often the slowest path in a fast FIFO. Registered flags computed from next-state pointers take it off the critical path.
- Verify with assertions for overflow, underflow and impossible flag states, plus a scoreboard that checks order.
In this part
- What a synchronous FIFO is for
- The interface
- Storage: flip-flops or SRAM
- Pointers and the extra wrap bit
- Full, empty and the same-cycle push and pop
- RTL sketch
- Timing, area and power
- Verification checklist
- Interview questions
- The rest of the series
What a synchronous FIFO is for
A FIFO absorbs a short mismatch between a producer and a consumer that run on the same clock. The producer may burst while the consumer is busy, or the consumer may stall for a few cycles while the producer keeps going. As long as the average rates match, a FIFO deep enough to cover the worst burst keeps both sides running without either one waiting on the other every cycle.
If the long-term write rate is higher than the read rate, no depth is enough. The FIFO only delays the overflow. That rate check comes before any sizing, and our older post on FIFO depth calculation works through nine scenarios.
The interface

The write side has push, wdata and full. The read side has pop, rdata and empty. Many designs add almost_full and almost_empty thresholds, and a count output for software or for flow control.
There are two common conventions for the handshake. In the first, the producer must not push when full is high and the consumer must not pop when empty is high, and assertions catch any violation. In the second, the FIFO simply ignores a push when full and a pop when empty. The second is more forgiving, but it can hide a bug that silently drops data. Pick one and write it in the spec.
Storage: flip-flops or SRAM
Small FIFOs, a few entries to a few dozen, are usually built from flip-flops. Reads are combinational or registered as you choose, any number of entries can be read in one cycle, and there are no memory read latency or read-during-write surprises.
Deeper FIFOs move to an SRAM macro or a register file, because flip-flops cost far more area and power per bit. That brings a fixed read latency, usually one cycle, a rule for what the macro returns when you read and write the same address in the same cycle, and sometimes a minimum depth or width. The crossover point depends on the library and the macro compiler, so check both options for your process rather than relying on a rule of thumb.
Pointers and the extra wrap bit
The storage is used as a ring. The write pointer marks the next free slot. The read pointer marks the oldest entry. Each pointer moves forward by one on an accepted push or pop and wraps back to zero at the end of the array.
The classic problem is that the pointers are equal both when the FIFO is empty and when it is full. The usual fix for a power-of-two depth is to make each pointer one bit wider than the address. The extra bit flips every time the pointer wraps.

- Empty: all bits of the two pointers are equal.
- Full: the index bits are equal and the top bits differ, so the writer is exactly one lap ahead.
- Count: the difference of the two pointers, taken modulo twice the depth, gives the number of entries. In the middle example above, 8 minus 5 is 3.
Two other schemes are common. A separate up and down counter makes count, full and empty trivial to read, at the cost of one more adder. A last-operation flag, set on a push and cleared on a pop, tells whether equal pointers mean full or empty. Non-power-of-two depths need explicit wraparound and get their own part later in the series.
Full, empty and the same-cycle push and pop

The timing diagram shows a four-entry FIFO filling, refusing a push while full, handling a push and a pop together, and draining. The interesting cases are at the edges.
- Push and pop when full. The pop frees a slot in the same cycle. If the design accepts the push as well, throughput stays at one entry per cycle even at the full boundary. If it rejects the push because
fullwas high, you lose a cycle every time the FIFO is full. Accepting it is usually right, but thenfullno longer means "do not push", it means "do not push unless you also pop". Say so in the spec. - Read and write to the same address. When the FIFO is full and both happen, the read and write index are the same. With flip-flops and a registered read, the read returns the old value, which is the correct, oldest entry. With an SRAM, check whether the macro returns old data, new data or an unknown value. If it is new data or unknown, either block the case or add a bypass.
- Push and pop when empty. With a registered read, there is nothing to pop, so the pop is rejected and the new entry appears on
rdataafter a later pop. A design that wants the new data available at once needs a bypass path. That is the first-word fall-through FIFO in Part 3.
RTL sketch
A parameterized flip-flop FIFO with a power-of-two depth, a registered read, and a push accepted at the full boundary when a pop happens in the same cycle:
module sync_fifo #(
parameter int W = 32,
parameter int DEPTH = 16, // power of two
localparam int AW = $clog2(DEPTH)
) (
input logic clk,
input logic rst_n,
input logic push,
input logic [W-1:0] wdata,
output logic full,
input logic pop,
output logic [W-1:0] rdata,
output logic empty
);
logic [W-1:0] mem [DEPTH];
logic [AW:0] wptr, rptr; // one extra wrap bit
wire do_pop = pop && !empty;
wire do_push = push && (!full || do_pop);
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) begin
wptr <= '0;
rptr <= '0;
end else begin
if (do_push) wptr <= wptr + 1'b1;
if (do_pop) rptr <= rptr + 1'b1;
end
always_ff @(posedge clk) begin
if (do_push) mem[wptr[AW-1:0]] <= wdata;
if (do_pop) rdata <= mem[rptr[AW-1:0]]; // old value on a same-address write
end
assign empty = (wptr == rptr);
assign full = (wptr[AW-1:0] == rptr[AW-1:0]) && (wptr[AW] != rptr[AW]);
endmodule
Three details are worth a second look. The storage array has no reset, which saves area, so rdata is only meaningful after a pop. Both pointers are reset to zero, which is what makes the empty flag valid out of reset. And the read is registered, so data appears on rdata in the cycle after the pop is accepted.
Timing, area and power
- Flag timing. In the sketch above,
fullandemptyare comparators on the pointer registers, anddo_pushdepends onfullanddo_pop. In a fast design that chain feeds wide enables on the storage and the pointer adders. The usual fix is registered flags: compute the next pointers, compare them, and registerfullandemptyso they come straight from flops. - Count. A pointer subtraction is a carry chain. If
countor analmost_fullthreshold is needed every cycle at high frequency, keep a registered counter instead of subtracting. - Read mux. A combinational read from a flip-flop array is a DEPTH-to-1 multiplexer per bit. For deep, wide FIFOs it grows quickly in area and delay, which is another reason to move to SRAM or a registered read.
- Power. Write only the addressed entry, gate the storage clock when there is no push, and avoid resetting the data array. Low-power FIFOs get their own part later.
Verification checklist
- A scoreboard (a reference queue) that checks every popped value against the value pushed in that position.
- Assertions on the convention you chose. For the "must not violate" convention:
a_no_overflow: assert property (@(posedge clk) disable iff (!rst_n) !(push && full && !pop)); a_no_underflow: assert property (@(posedge clk) disable iff (!rst_n) !(pop && empty)); a_flags_sane: assert property (@(posedge clk) disable iff (!rst_n) !(full && empty)); - Cover the edges: fill to full, push and pop together when full, push and pop together when empty, wrap both pointers several times, and reset in the middle of traffic.
- Random traffic with random stalls on both sides for a long run, so the pointers wrap many times.
- If the storage is an SRAM, model its read-during-write behavior exactly, or the same-address case will pass in simulation and fail in silicon.
Interview questions
1. How do you tell full from empty when the pointers are equal?
A strong answer gives the extra wrap bit for power-of-two depths and explains why it works, then mentions the counter and last-operation alternatives and when each is better.
2. The FIFO is full, and push and pop arrive in the same cycle. What should happen?
A strong answer says the push can be accepted because the pop frees a slot, explains the throughput cost of rejecting it, and raises the same-address read-during-write behavior of the storage.
3. Your full flag is on the critical path at 1.5 GHz. What do you change?
A strong answer registers the flags from next-state pointers, replaces pointer subtraction with a registered count where a threshold is needed, and checks that the push enable no longer depends on a long compare chain.
4. Flip-flops or SRAM for a 64-entry, 128-bit FIFO?
A strong answer weighs area and power per bit against SRAM read latency, read-during-write rules and the macro's minimum sizes, and says it would compare both in the target library before deciding.
5. How would you verify it?
A strong answer combines a reference-queue scoreboard, assertions for overflow, underflow and flag sanity, coverage of full and empty boundary cases, long random runs, and a correct model of the SRAM.
The rest of the series
Part 2 crosses into two clock domains: the asynchronous FIFO, Gray-coded pointers and synchronizers. Later parts cover multi-push and multi-pop FIFOs, packet and width-conversion FIFOs, credit-based flow control, and replay, speculative and banked designs.
Three parts are built on FIFO interview challenges shared by Rahul Behl of Tenstorrent: a multi-pop FIFO with a thermometer-coded pop, a FIFO-based ID tracker that flags every stored request ID each cycle, and an in-order write-coalescing buffer with a late-arriving address. He has also published all three as PPA challenges on QuickSilicon. Those parts credit him and link to the originals.
Related reading: FIFO Depth Calculation: Formula and 9 Worked Scenarios and Top 10 Common RTL Coding Mistakes and How to Avoid Them.

Your comments will be moderated before it appears here.