Hardware interview practice
Build a FIFO UVM testbench
A depth-8 non-fall-through synchronous FIFO must be verified for ordering, flags, simultaneous operations, overflow attempts, and underflow attempts. Design the minimum reusable UVM environment and concrete checking rules.
Starting point
Question code
clk, rst_n
wr_valid, wr_ready, wr_data[15:0]
rd_valid, rd_ready, rd_data[15:0]
full, emptyReviewed example
Work through one case
Input
Model contains [A,B]; rd_valid=rd_ready=wr_valid=wr_ready=1 with wr_data=CExpected output
Compare rd_data with A, then model becomes [B,C]Processing the read against pre-edge state before appending the write preserves simultaneous-transfer semantics and occupancy.
What to cover
Requirements
- Use an active agent to drive writes and read-ready, a monitor to publish accepted writes and reads, and a scoreboard with a reference queue.
- Use a non-fall-through contract: before each nonreset edge, empty==(model_size==0), full==(model_size==8), rd_valid==!empty, and wr_ready==!full; accept transfers only from those sampled handshakes.
- On an edge with rst_n=0, ignore handshakes and clear the model; require empty=1 and full=0 on the following cycle. On a simultaneous accepted read/write, compare and remove the pre-edge head before appending the write.
- Cover occupancies 0 through 8, full/empty transitions, simultaneous accepted read/write, blocked write at full, and blocked read at empty.
