Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Implement a synchronous FIFO with exact boundary behavior

Hardware interview practice

Implement a synchronous FIFO with exact boundary behavior

MediumRTL DesignSystemVerilog

Implement a depth-8, 32-bit synchronous FIFO. Define behavior when empty or full and make simultaneous reads and writes work correctly, including an exchange while full.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

module sync_fifo (
  input logic clk, rst_n,
  input logic wr_valid,
  input logic [31:0] wr_data,
  output logic wr_ready,
  output logic rd_valid,
  output logic [31:0] rd_data,
  input logic rd_ready,
  output logic full, empty
);
Reviewed example

Work through one case

Input
Write A..H to fill the FIFO. Then drive wr_valid=1 with I and rd_ready=1 for one cycle. Later drain all entries.
Expected output
The exchange cycle consumes A and accepts I with count still 8. Remaining read order is B,C,D,E,F,G,H,I.

Read and write fires are independent. Their simultaneous count effects cancel, while both pointers advance exactly once.

What to cover

Requirements

  1. Accept a write only on wr_valid && wr_ready and a read only on rd_valid && rd_ready.
  2. At full, allow a write in the same cycle as a read; the old head is read, the new item is written at the tail, and occupancy remains eight.
  3. At empty, a simultaneous wr_valid and rd_ready accepts only the write; no same-cycle empty bypass is provided, and rd_valid rises afterward.
  4. Preserve order, keep rd_data stable while rd_valid && !rd_ready, and make rejected full writes or empty reads have no effect.
Continue practicing

Related questions

RTL DesignAbsorb ready/valid backpressure with a skid buffer→RTL DesignBuild a synchronous FIFO and race-free BFM→RTL DesignRoute a shared read bus without internal tri-states→
asic.fyi · Learn silicon end to end.info@asic.fyi