Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Eight-entry asynchronous FIFO

Hardware interview practice

Eight-entry asynchronous FIFO

MediumClock Domain CrossingSystemVerilog

A 32-bit producer and consumer use unrelated clocks. Implement an eight-entry asynchronous FIFO with local full/empty flags, Gray-pointer crossings, and reset-release gating in both domains.

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

input logic wclk, wrst_n, wvalid;
output logic wready;
input logic [31:0] wdata;
input logic rclk, rrst_n, rready;
output logic rvalid;
output logic [31:0] rdata;
Reviewed example

Work through one case

Input
After reset, write A once and hold rready=1
Expected output
rvalid eventually rises and the first accepted read returns A

The write Gray pointer crosses two rclk stages before rempty clears; the data bus remains in dual-port memory and FIFO order is preserved.

What to cover

Requirements

  1. Use 4-bit binary read and write pointers for eight entries, convert each next pointer to Gray code, and synchronize only Gray pointers through two flops into the opposite domain.
  2. Accept a write only on wvalid and wready; assert local full when the next write Gray pointer equals the synchronized read Gray pointer with its two most-significant bits inverted.
  3. Accept a read only on rvalid and rready; assert local empty when the next read Gray pointer equals the synchronized write Gray pointer, and preserve FIFO order.
  4. For initialization or flush, assert both resets together; each local reset clears its binary pointer, Gray pointer, and flag, and permit no traffic until both resets have been released and synchronized.
Continue practicing

Related questions

Clock Domain CrossingGenerate and synchronize a Gray-code counter→Clock Domain CrossingImplement asynchronous FIFO full and empty logic→Clock Domain CrossingBinary-to-Gray converter→
asic.fyi · Learn silicon end to end.info@asic.fyi