Module 8: Protocol Projects | Intermediate UVM

FIFO Protocol Project

Build a small, reusable UVM environment that verifies FIFO ordering, status behavior, reset handling, and boundary conditions.

Learning objectives

  • Translate FIFO requirements into executable UVM verification scenarios.
  • Organize a FIFO testbench using an agent, sequences, monitor, scoreboard, and coverage model.
  • Verify ordering, full/empty behavior, reset behavior, and boundary conditions.
  • Use logs, assertions, scoreboard results, and functional coverage as verification evidence.
  • Debug a failing FIFO scenario and reproduce it using a known random seed.

Step 1: Define the FIFO contract

A FIFO is simple at the interface but rich in verification cases. The fundamental contract is first in, first out: data accepted into the FIFO must emerge in the same order unless reset or another explicitly defined control event changes the state.

Before writing sequences, identify the observable behavior:

  • Write: data is accepted when the FIFO is not full.
  • Read: data is returned when the FIFO is not empty.
  • Ordering: the oldest accepted item must be returned first.
  • Empty: the FIFO reports empty when no valid unread entries remain.
  • Full: the FIFO reports full when its configured capacity has been reached.
  • Reset: reset returns the FIFO to its documented initial state.

These requirements become the basis for your sequences, scoreboard checks, assertions, and coverage points.

Verification mindset: Do not begin with random traffic. First prove that a small set of directed scenarios establishes the FIFO contract.

Step 2: Map the project into UVM components

A useful FIFO environment separates stimulus, observation, and checking. The driver translates transactions into pin-level activity, while the monitor reconstructs what actually happened at the interface.

class fifo_env extends uvm_env;


fifo_agent       agent;
fifo_scoreboard  scoreboard;
fifo_coverage    coverage;

function void build_phase(uvm_phase phase);
super.build_phase(phase);


agent      = fifo_agent::type_id::create("agent", this);
scoreboard = fifo_scoreboard::type_id::create("scoreboard", this);
coverage   = fifo_coverage::type_id::create("coverage", this);


endfunction
endclass

The important design decision is not the class names. It is the ownership boundary:

  • The sequence decides what scenario to attempt.
  • The driver applies the transaction to the FIFO interface.
  • The monitor observes accepted writes, reads, data, and status.
  • The scoreboard predicts FIFO contents and compares expected data with observed data.
  • The coverage model records whether important FIFO states and transitions were exercised.

Step 3: Build a reference model

The scoreboard can model the FIFO with a SystemVerilog queue. A write that is accepted by the DUT adds an item to the reference queue; a read removes the oldest item and compares it with the observed output.

class fifo_scoreboard extends uvm_scoreboard;


bit [31:0] expected_q[$];

function void check_write(bit [31:0] data);
expected_q.push_back(data);
endfunction

function void check_read(bit [31:0] actual);
bit [31:0] expected;


if (expected_q.size() == 0) begin
  `uvm_error("FIFO_SB", "Read observed while reference FIFO is empty")
  return;
end

expected = expected_q.pop_front();

if (actual !== expected) begin
  `uvm_error("FIFO_SB",
    $sformatf("FIFO mismatch: expected=%0h actual=%0h",
              expected, actual))
end


endfunction
endclass

The reference model should represent the behavioral contract, not duplicate the DUT implementation. If the RTL uses pointers and counters, the scoreboard should not simply reproduce those same pointers and counters; it should independently predict the externally visible result.

Step 4: Verify the important scenarios

Build the project incrementally. Each scenario should have a clear stimulus, expected result, and observable piece of evidence.

  1. Reset: assert reset and verify the FIFO returns to its documented empty state.
  2. Single write/read: write one value and confirm the same value is returned.
  3. Ordering: write several unique values and verify they are read back in exactly the same order.
  4. Empty boundary: drain the FIFO and verify empty status behaves correctly.
  5. Full boundary: write until capacity is reached and verify full status and write acceptance behavior.
  6. Simultaneous activity: exercise legal read/write combinations and check the documented status and data behavior.
  7. Reset during activity: if supported by the specification, reset while traffic is active and verify the resulting state.
task body();


fifo_reset_seq  reset_seq;
fifo_smoke_seq  smoke_seq;

phase.raise_objection(this);

reset_seq = fifo_reset_seq::type_id::create("reset_seq");
smoke_seq = fifo_smoke_seq::type_id::create("smoke_seq");

reset_seq.start(env.agent.sequencer);
smoke_seq.start(env.agent.sequencer);

phase.drop_objection(this);
endtask

Start with deterministic data such as 32'h11, 32'h22, and 32'h33. Distinct values make ordering failures much easier to diagnose than repeated or fully random data.

Step 5: Add assertions and coverage

A scoreboard answers “Did the observed data match the expected data?” Assertions can answer questions about protocol rules and timing directly at the interface.

// Example intent: a read must not be accepted while empty.


property no_read_when_empty;
@(posedge clk) disable iff (reset)
empty |-> !read_accept;
endproperty

assert property (no_read_when_empty)
else `uvm_error("FIFO_ASSERT", "Read accepted while FIFO was empty");

For coverage, consider tracking meaningful states rather than simply counting transactions:

  • empty state exercised
  • full state exercised
  • single-entry state exercised
  • write followed by read
  • back-to-back writes
  • back-to-back reads
  • simultaneous read/write
  • reset followed by traffic

Coverage should tell you which requirements have been exercised, while the scoreboard and assertions tell you whether the resulting behavior was correct.

Step 6: Debug a failing scenario

When the FIFO fails, preserve enough information to reproduce the problem. Record the test name, random seed, configuration, relevant transaction sequence, and first meaningful error.

`uvm_info("FIFO_TEST",


$sformatf("Starting %s seed=%0d",
get_type_name(), $get_initial_random_seed()),
UVM_LOW)

`uvm_error("FIFO_SB",
$sformatf("Mismatch: expected=%0h actual=%0h",
expected, actual))

When debugging a mismatch, inspect the first divergence rather than the final cascade of errors. A single incorrect write acceptance can cause every later queue comparison to fail.

Common mistake: treating every scoreboard mismatch as an independent bug. Find the earliest incorrect transaction or state transition; later mismatches may be consequences of the same root cause.

Step 7: Turn the project into reusable verification

A successful project should be more than one passing test. Separate reusable infrastructure from scenario-specific intent.

  • Keep the FIFO agent reusable across tests.
  • Keep protocol mechanics in the driver and monitor.
  • Keep expected FIFO behavior in the scoreboard.
  • Put specific scenarios in sequences and tests.
  • Use configuration objects for parameters such as FIFO depth or data width when appropriate.
  • Keep regression metadata sufficient to reproduce failures.

This separation makes it possible to reuse the same verification components when the FIFO configuration changes or when the environment becomes part of a larger subsystem.

Try it yourself

Build a small FIFO verification project with these minimum requirements:

  1. Create a FIFO agent containing a sequencer, driver, and monitor.
  2. Write a directed sequence that fills the FIFO with five distinct values.
  3. Read the values back and verify first-in, first-out ordering with a scoreboard.
  4. Add reset, empty, and full boundary scenarios.
  5. Add at least two functional coverage points for FIFO state or activity.
  6. Run one deterministic test and one seeded-random test.
  7. Capture the test result, seed, scoreboard status, and coverage observation.

Success criteria: the environment can demonstrate correct FIFO ordering, detects an intentionally introduced mismatch, and produces enough diagnostic information to reproduce the failure.

Key takeaways

  • A FIFO project turns protocol requirements into executable stimulus, checking, assertions, and coverage.
  • A queue-based scoreboard provides an independent behavioral reference for FIFO ordering.
  • Boundary conditions such as empty, full, reset, and simultaneous operations deserve explicit verification.
  • Directed tests establish the basic contract before constrained-random testing expands the state space.
  • The first meaningful failure is usually more useful for debugging than a long list of downstream mismatches.
  • A reusable UVM project separates protocol mechanics from scenario intent and verification policy.