Intermediate Project | 6-8 hours

Asynchronous FIFO

Run a complete UVM testbench against a depth-four asynchronous FIFO with independent clocks, boundary checks, concurrent traffic, and a monitor-driven scoreboard.

Before you begin

Prerequisites

  • SystemVerilog interfaces, classes, queues, and clocking blocks.
  • UVM sequences, drivers, monitors, analysis ports, and scoreboards.
  • A simulator with a UVM library. The testbench source is provided; the FIFO RTL is the DUT to supply.

Design contract

Use this contract as the reference for both the DUT and the checks. If you make an assumption beyond it, record that assumption in your project notes.

AreaRequired behavior
InterfaceModule async_fifo has wr_clk, rd_clk, rst_n, wr_en, wr_data[7:0], full, rd_en, rd_data[7:0], and empty ports.
ConfigurationDATA_WIDTH is 8 and ADDR_WIDTH is 2, giving four FIFO entries.
Resetrst_n is active-low asynchronous assertion. The DUT synchronizes reset release independently into each clock domain. Reset clears both pointers and sets empty=1 and full=0.
Write acceptanceA write is accepted on a rising wr_clk edge when wr_en=1 and the pre-edge full flag is 0. Writes attempted while full are ignored.
Read acceptanceA read is accepted on a rising rd_clk edge when rd_en=1 and the pre-edge empty flag is 0. Reads attempted while empty are ignored.
Read dataFirst-word-fall-through: while non-empty, rd_data continuously presents the oldest word; the monitor samples it at the accepting rd_clk edge.
CDC flagsfull and empty may assert/deassert after pointer synchronization latency. Do not require same-cycle visibility across clock domains.

What you will learn

This project uses a first-word-fall-through FIFO contract: when non-empty, rd_data presents the oldest stored word before the read edge. The testbench drives independent write and read clocks, derives accepted operations from the observed local flags, and compares every accepted read with a reference queue of accepted writes.

  • Verify independently clocked write and read domains
  • Check accepted-operation ordering with a reference queue
  • Prove full/empty rejection and reset recovery
  • Exercise concurrent randomized traffic and operation coverage
Project method: write the behavior first, build the smallest working DUT, observe it with a self-checking testbench, then add boundary and error scenarios.

Step 1: Understand the design contract

Before writing stimulus, identify the input transaction, the expected behavior, the boundary conditions, and the evidence that proves the result. This contract is the reference for both the DUT and the verification environment.

Verification questionAnswer to define
What does the DUT receive?inputs, transactions, configuration, or protocol requests
What should it produce?output data, state transition, response, flag, or error
What does the testbench observe?monitor data, response timing, status, waveform, or coverage
What can fail?normal operation, boundary, reset, timing, ordering, and invalid input

Step 2: Study the DUT contract or starter snippet

// Complete UVM source: download the testbench below.
// Instantiate an async_fifo DUT with the documented ports.
// The testbench uses independent 10 ns and 14 ns clocks.
// rd_data uses first-word-fall-through behavior.

This project may provide RTL, a behavioral contract, or pseudocode here. Treat it as the stated project scope, not as a complete implementation. Identify the inputs, outputs, acceptance event, response timing, and reset behavior before writing checks.

Questions to answer

  1. What is the legal input range?
  2. What is the exact acceptance event?
  3. What happens at the minimum and maximum values?
  4. How does reset affect pending or stored state?
  5. What response indicates an invalid operation?

Step 3: Build the verification stimulus

Keep the stimulus separate from the checking logic. A driver or task applies inputs; a monitor or observation block samples what the DUT actually did.

Complete UVM testbench source

Download the SystemVerilog testbench, connect a DUT that matches the design contract, and compile with UVM enabled.

Download testbench (.sv)
async_fifo_uvm_tb_top
  +-- async_fifo_if (clocking blocks)
  +-- write agent: sequencer, driver, monitor
  +-- read agent: sequencer, driver, monitor
  +-- queue scoreboard and operation coverage
  +-- reset, boundary, concurrent-random, and recovery scenarios

UVM testbench architecture

The write and read sides are separate agents because they are driven by independent clocks. Both monitors send observed operations to one scoreboard, which checks ordering across the two clock domains.

                         async_fifo_uvm_tb_top
            +--------------------+--------------------+
            |                                         |
      async_fifo_if                              async_fifo DUT
   clocks / reset / pins                 write ptr <-> read ptr
            |                              synchronizers (DUT)
       +----+----+                                   ^
       |         |                                   |
  WRITE DOMAIN  READ DOMAIN                          |
       |         |                                   |
  write agent  read agent                            |
  +---------+  +---------+                           |
  |sequence |  |sequence |                           |
  |sequencer|  |sequencer|                           |
  |driver   |  |driver   | ---- interface pins ------+
  |monitor  |  |monitor  |                           |
  +----+----+  +----+----+                           |
       |            |                                |
       +----+-------+                                |
            v                                        |
      queue scoreboard <---- observed transfers -----+
      + operation coverage

What each component does

async_fifo_if
A SystemVerilog interface that groups FIFO pins and clocking blocks. The write driver/monitor use wr_clk; the read driver/monitor use rd_clk.
fifo_req_item
The request sequence item sent to a driver. It carries write data; read items request a read operation.
fifo_mon_item
A monitor transaction containing reset state, request, local full/empty flag, accepted status, operation direction, and sampled data.
fifo_write_sequence / fifo_read_sequence
Generate write and read requests. Directed sequences create known boundary cases; the concurrent write sequence can generate randomized data.
write/read sequencers
Arbitrate and deliver sequence items to the matching domain's driver. Each agent has its own sequencer.
fifo_write_driver / fifo_read_driver
Drive one-cycle write or read requests using the matching interface clocking block. They do not decide whether the request is accepted; the DUT's local full/empty flag does.
fifo_write_monitor / fifo_read_monitor
Observe each clock domain independently. They publish an accepted operation only when reset is released, enable is asserted, and the pre-edge local flag permits it.
fifo_write_agent / fifo_read_agent
Package a domain's sequencer, driver, and monitor. Keeping the agents separate reflects the independent clocks and interfaces.
fifo_scoreboard
Pushes accepted write data into a reference queue and pops/checks the oldest value for every accepted read. It also counts blocked and accepted operations and samples operation coverage.
async_fifo_env
Builds both agents and the scoreboard, then connects each monitor analysis port to the matching scoreboard input.
async_fifo_test
Configures reset and runs directed full/empty tests, concurrent randomized traffic, queue drain, and reset recovery while controlling the UVM objection.
async_fifo_uvm_tb_top
Creates independent clocks, instantiates the interface and DUT, passes the virtual interface through uvm_config_db, and starts the named UVM test.

Step-by-step development

Build and debug the environment in layers. Keep each stage passing before adding the next source of concurrency.

  1. Freeze the DUT contract. Confirm signal names, active-low reset behavior, depth, data width, accepted write/read edges, flag latency, and whether reads are first-word-fall-through. Match the contract on the page before changing the testbench.
  2. Compile the interface and top. Connect the async_fifo module with DATA_WIDTH=8 and ADDR_WIDTH=2. Start with the two clocks and reset only; resolve port and parameter mismatches before debugging UVM.
  3. Define transactions. Use fifo_req_item for driver requests and fifo_mon_item for monitor evidence. Keep requested operations distinct from accepted operations.
  4. Build one domain at a time. Bring up the write sequence, sequencer, driver, and monitor first. Then add the read side with its own clock and agent. Use clocking blocks to avoid drive/sample races.
  5. Connect the scoreboard. Connect both monitor analysis ports. Enqueue only monitor-confirmed accepted writes; on each accepted read, compare the sampled FWFT head against the queue front and report mismatches with expected and actual data.
  6. Prove directed boundaries. Reset, write four distinct values, check full, attempt one blocked write, read the four values in order, check empty, and attempt one blocked read. Confirm operation counters match the scenario.
  7. Add concurrent traffic. Run read and write sequences together with independent clocks. Use a fixed seed for reproduction, drain every accepted item, and require zero mismatches and an empty reference queue.
  8. Test reset during activity. Write pending data, assert reset, confirm the reference model is flushed, then release reset and check both flags return to the empty state.
  9. Review limits and expand regressions. Run multiple seeds and clock ratios after the baseline passes. The supplied covergroup measures operation, accepted/blocked status, and local flag; it does not prove metastability safety, Gray-code correctness, or all occupancy/clock-ratio combinations.

Step 4: Verify the important scenarios

Run the provided async_fifo_uvm_tb.sv with your async_fifo RTL and UVM library. The top module expects async_fifo with DATA_WIDTH and ADDR_WIDTH parameters and the exact ports in the contract above. The test checks four accepted writes before full, rejected write-at-full, four ordered accepted reads, rejected read-at-empty, concurrent randomized traffic, final queue drain, and reset with pending data. The independent clocks have 10 ns and 14 ns periods; adjust them to explore other clock ratios.

ScenarioExpected evidence
Nominal operationone legal request produces one correct result
Boundary operationminimum, maximum, last, or transition value is handled correctly
Invalid operationerror, rejection, ignore, or documented recovery occurs
Reset interruptionstate and pending work return to the specified condition
Repeated/concurrent trafficordering, correlation, and no-loss behavior remain correct

Make the result self-checking

The code above is a project-specific starting point, not a complete testbench. Your finished test should calculate expectations independently from the DUT and report failures with enough context to reproduce them.

  1. Count each check and fail the run when an expected behavior is violated.
  2. Use monitor observations as evidence; do not pass a test solely because the driver requested an operation.
  3. Include the scenario, expected value, actual value, and transaction context in mismatch messages.
  4. End only after outstanding responses are checked and the scoreboard is drained.

Example successful summary

Illustrative successful summary:
FIFO_TEST PASS: reset, ordering, full/empty rejection, concurrent clocks, random traffic, and reset recovery
FIFO_SB accepted writes=... blocked writes=... accepted reads=... blocked reads=... pending=0 mismatches=0

This is an illustrative pass summary, not a captured simulator transcript. Your run should report the scenarios and checks you actually executed, along with zero unexpected errors.

Common mistakes and debugging

SymptomFirst thing to inspect
Expected result never arrivesreset, handshake, enable condition, and end-of-test drain
Data mismatchtransaction ordering, bit/byte order, and reference-model calculation
Only boundary cases failinclusive versus exclusive limits and width truncation
Only random tests failseed, race, uninitialized state, or unsupported combination
Test hangsobjections, waits, queues, and missing response timeout
Test passes too easilyensure checking uses monitor observations, not driver intent
Debug rule: preserve the first failure, seed, configuration, timestamp, transaction ID, expected value, and actual value before changing the test.

UVM extension

Once the direct testbench works, organize the project as UVM components: a sequence item carries the transaction, a sequence creates scenarios, a driver applies protocol activity, a monitor publishes observations, and a scoreboard checks an independent expectation.

class project_item extends uvm_sequence_item;
    rand logic [31:0] data;
    `uvm_object_utils(project_item)

    function new(string name = "project_item");
        super.new(name);
    endfunction
endclass

class project_scoreboard extends uvm_scoreboard;
    `uvm_component_utils(project_scoreboard)
    uvm_analysis_imp #(project_item, project_scoreboard) analysis_export;

    function void write(project_item observed);
        // Calculate expected behavior independently.
        // Compare with observed and report useful context.
    endfunction
endclass

Do not add UVM classes just for decoration. The value is the separation of responsibilities and the ability to reuse the same sequence and checks when the interface or DUT configuration changes.

Project milestones

  1. Connect the documented FIFO DUT and compile the testbench with UVM enabled.
  2. Pass reset recovery and verify empty=1 and full=0 in both domains.
  3. Accept four distinct words, assert full, reject one extra write, then read all four words in order.
  4. Assert empty after drain and reject a read while empty.
  5. Run concurrent randomized writes and reads, drain all accepted data, then reset with pending words.

Submit these artifacts

  • The passing simulator transcript, including simulator/UVM version and random seed.
  • A waveform showing the independent clocks, reset, synchronized flags, and accepted transfers.
  • Scoreboard totals for accepted and blocked operations, pending words, and mismatches.
  • Coverage results for read/write crossed with accepted/blocked operations and local flag state.
  • A note confirming whether the DUT follows the first-word-fall-through contract or what monitor timing must change.

Project goals and acceptance criteria

  1. Verify independently clocked write and read domains.
  2. Check accepted-operation ordering with a reference queue.
  3. Prove full/empty rejection and reset recovery.
  4. Exercise concurrent randomized traffic and operation coverage.
  5. Include at least one boundary and one negative or error scenario.
  6. Capture console and waveform evidence for the first failure and final passing run.
  7. Document assumptions, unsupported cases, and remaining verification risk.
Acceptance criteria: the DUT implements the documented contract; the testbench checks observed behavior independently; nominal and boundary scenarios pass; the relevant error path is detected; reset and end-of-test behavior are controlled; and the UVM extension has a clear item, driver, monitor, and scoreboard responsibility.