1. Start with the contract
This example is a single-clock synchronous FIFO with a registered read output. Reset is active high and takes effect on the rising clock edge. All acceptance decisions use the queue state before that edge.
| Before the edge | Requested operation | Result |
|---|---|---|
| Any state | Reset | Clear occupancy and output; ignore read/write. |
| Empty | Read + write | Accept write only. No same-edge bypass. |
| Partly filled | Read + write | Read oldest value and append new value; occupancy stays constant. |
| Full | Read + write | Accept read only. No same-edge replacement. |
| Any state | No accepted read | Read-valid is 0; read-data retains its last value. |
Other FIFOs can choose different full/empty policies. This conservative example trades throughput at the boundaries for a simple, explicit contract. It is not an asynchronous FIFO or a CDC solution.
2. Predict, then step
Select read and write requests, enter an unsigned byte, and advance one rising edge. The boxes show logical queue order, not physical memory addresses.
Ready. The queue is empty.
Recent clock edges
Newest first, up to 10 edges. This trace stays in your browser and is not submitted.
| Edge | Accepted operations | Queue after edge | Read result |
|---|
3. Run checks that can fail
The source package includes parameterised RTL, a Python queue model, generated testbench and the browser model. The published run checked ten configurations: depths 1, 2, 3, 4 and 8, each at 8- and 16-bit widths.
13,688 checked vectors cover every occupancy/reset/read/write combination, seeded random sequences and a final drain. Three deliberately incorrect RTL variants were detected: writing when full, reading from the wrong pointer, and resetting occupancy incorrectly.
Download source and checksView machine-readable results · Educational source released under MIT licence.
python3 test_fifo.py
node test_model.mjsInstall Python 3 and Icarus Verilog first. The optional browser-model check also needs Node.js. Run the commands inside the extracted folder; generated simulation files stay in test-output/.
These checks establish behaviour for the tested RTL configurations and stimuli. They do not establish synthesis quality, hardware timing, memory inference, metastability safety or signoff.
4. Make the exercise your own
- Predict the boundary. Fill all four slots, request a read and a write together, and predict both the read result and the new occupancy before advancing.
- Check ordering. Write 12, 37 and 91, then read twice. Explain why the next value is 91 even after the pointer has wrapped in a later experiment.
- Change the policy. Design full replacement as a separate variant. Update the contract and reference model first, then test data order and depth 1 explicitly.
- Extend coverage. Add a depth-5 configuration. Explain how the test distinguishes an accepted transaction from a request blocked at a boundary.
- Review the oracle. The reference uses a software queue, not RTL pointers. Describe one error that could still be shared by both models and how you would challenge it with a hand-worked trace.
Questions before you begin
Is this a course video preview?
No. This is an original, free practice resource. Course lesson previews are available only where the course curriculum explicitly marks a lesson as Preview.
Why does a read at empty not see the new write?
Acceptance is based on pre-edge occupancy. The example has no bypass path; the newly written value can be read on a later edge.
Can I use this between two clock domains?
No. The design and tests assume one clock. A multi-clock FIFO requires a different design and CDC-specific analysis.
Which courses does this complement?
Use it alongside Verilog, RTL Design or Design & Verification. It is a self-directed exercise, not an instructor-graded assignment.