Home › Practice › RTL Design › Asynchronous FIFO (depth 4)
Asynchronous FIFO (depth 4)
HardRTLCDCtwo clocksFIFO
Build a FIFO with 4 entries of 8 bits. The write side runs on wclk, the read side on rclk, and the two clocks are unrelated.
- Ports are fixed:
wclk,rclk,wrst(synchronous towclk),rrst(synchronous torclk),winc,wdata[7:0],wfull,rinc,rdata[7:0],rempty. Resets are active-high; after reset the FIFO is empty (rempty=1,wfull=0). - A write happens on a
wclkedge withwinc=1. A read happens on anrclkedge withrinc=1. Wheneverrempty=0,rdatashows the oldest entry, and a read removes it. The test producer setswincwheneverwfull=0 and the test consumer setsrincwheneverrempty=0, so both go as fast as your flags allow. - Flags may be late (they may stay up a cycle or two longer than needed), but never early:
wfullmust be 1 whenever the FIFO is really full, andremptymust be 1 whenever it is really empty. - Structure: every pointer bit that crosses must go straight into a flop of the other clock and through at least two such flops. The data memory itself needs no synchronizer: the pointers guard it.
- Bus rule: a multi-bit pointer that crosses clocks must change one bit at a time (Gray code). If one clock event can change two or more bits of it, the design fails, and the step table shows the bus before and after (for example 011 to 100 flips three bits).
- Bit timing: the first flop of each crossing bit may catch the old or the new value of that bit, on its own. Data must come out in order, with nothing lost or repeated, no write accepted when really full and no read when really empty. Only safety is checked (a clock may stop), for 16 steps. Each step is one clock event:
wclkticks,rclkticks, both, or neither.
What this grader can and cannot see. Simulators and Studio treat flops as ideal and cannot show metastability, so this grader checks the structure and the worst-case bit timing instead. Structure failures are shown as a message naming the net. A timing failure is shown as a table of steps.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.