Hardware interview practice
Implement asynchronous FIFO full and empty logic
Design the pointer, synchronization, memory, full, empty, and coordinated-reset behavior for a depth-16 dual-clock FIFO.
Starting point
Question code
// write: wclk, wrst_n, w_en, wdata, w_full
// read: rclk, rrst_n, r_en, rdata, r_emptyReviewed example
Work through one case
Input
Sixteen accepted writes and no readsExpected output
w_full asserts after the sixteenth pointer advanceThe next write Gray pointer reaches the state one buffer length ahead of synchronized read Gray.
What to cover
Requirements
- Use 5-bit binary/Gray pointers with a 4-bit memory address.
- Register local Gray pointers and synchronize each Gray bus through two destination flops.
- Register empty from next read Gray equaling synchronized write Gray; register full from next write Gray equaling synchronized read Gray with its top two bits inverted.
- Treat reset as a coordinated flush and block both sides until both domains observe synchronized release.
