Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Implement an Eight-Entry Synchronous FIFO

Hardware interview practice

Implement an Eight-Entry Synchronous FIFO

MediumTimingSystemVerilog

A single-clock datapath needs an eight-entry, 16-bit FIFO with ready/valid interfaces on both sides. Implement the FIFO with deterministic boundary and simultaneous-transfer behavior.

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_fifo8x16(input logic clk,rst_n,
 input logic in_valid, output logic in_ready, input logic [15:0] in_data,
 output logic out_valid, input logic out_ready, output logic [15:0] out_data,
 output logic [3:0] occupancy);
Reviewed example

Work through one case

Input
Case 1: After reset, accept 16'h0011 then 16'h0022
Case 2: At occupancy 8, assert out_ready and in_valid
Case 3: At occupancy 0, assert in_valid and out_ready
Expected output
Case 1: the next two pop handshakes return 0011 then 0022
Case 2: one old item pops, one new item writes, occupancy stays 8, and both pointers advance
Case 3: only a push occurs; out_valid rises after the edge and the item is not consumed on that edge

The shown result follows by applying this rule: Use three-bit read/write pointers with natural modulo-eight wrap and a four-bit occupancy counter that represents zero through eight. The cases also demonstrate this requirement: Present the oldest entry on out_data and keep it stable while out_valid&& !out_ready; at empty there is no combinational pass-through, so a pushed item becomes valid after the accepting edge.

What to cover

Requirements

  1. Active-low synchronous reset sets both pointers and occupancy to zero; memory contents need not be reset, and out_valid must be zero after reset.
  2. Define pop as out_valid&&out_ready and push as in_valid&&in_ready; out_valid is occupancy!=0, and in_ready is occupancy<8 or pop, allowing a full FIFO to pop and replace one item on the same edge.
  3. Increment occupancy for push without pop, decrement for pop without push, and hold it for neither or both; advance only the pointer belonging to an accepted operation.
  4. Present the oldest entry on out_data and keep it stable while out_valid&& !out_ready; at empty there is no combinational pass-through, so a pushed item becomes valid after the accepting edge.
Continue practicing

Related questions

RTL DesignBuild a synchronous FIFO and race-free BFM→RTL DesignImplement a synchronous FIFO with exact boundary behavior→Memory SystemsSize a Width-Converting Asynchronous FIFO→
asic.fyi · Learn silicon end to end.info@asic.fyi