RTL Design #58 · 2026-11-20 · FIFOs · Medium · about 25 min

A first-word-fall-through FIFO

Build a first-word-fall-through FIFO, fwft_fifo, in fwft.sv. Unlike a FIFO with a registered read port, the oldest word is already on rdata whenever the FIFO is not empty: you don't ask for it first. rd_en means "I have taken the word on rdata; move to the next one."

Requirements:

  1. Storage is DEPTH words of W bits (DEPTH is a power of two, 4 by default). Words come out in the order they went in.
  2. A write happens on a rising edge where wr_en is 1 and full is 0. A read happens on a rising edge where rd_en is 1 and empty is 0. Otherwise the request is ignored. Both can happen on the same edge, each judged by the full and empty values in that cycle: with the FIFO full, a write alongside a read is ignored.
  3. full and empty are combinational functions of what the FIFO holds: full is 1 exactly when DEPTH words are stored, empty exactly when none are.
  4. While empty is 0, rdata is the oldest stored word, in the same cycle, with no read needed. While empty is 1, rdata is don't-care.
  5. rst_n is a synchronous, active-low reset that empties the FIFO.

Example, DEPTH = 4, starting empty:

edge wr_en / wdata rd_en state after the edge
1 1 / 0x11 0 empty 0, rdata 0x11
2 1 / 0x22 0 rdata still 0x11
3 0 1 rdata 0x22 (0x11 was consumed)
4 0 1 empty 1

Write and run your answer in the browser. The hidden tests check it, and it’s free.