Module 5: Observation and Checking | Beginner UVM

Reference Model Basics

Learn how a reference model predicts the DUT's expected behavior and provides the expected results used by a scoreboard.

Learning objectives

  • Explain the purpose of a reference model in a UVM testbench.
  • Distinguish expected transactions from transactions observed from the DUT.
  • Build a simple reference model that transforms an input transaction into an expected result.
  • Connect the reference model to a scoreboard using a TLM analysis connection.
  • Use a mismatch report to identify a DUT or testbench problem.

Step 1: Understand the concept

A reference model is a simplified model of the behavior that the DUT is supposed to implement. It receives stimulus-related information and calculates the result that should occur.

The important idea is that the reference model should be independent of the DUT implementation. If the reference model simply repeats the DUT's algorithm, the same design mistake could appear in both places and the testbench might incorrectly report a pass.

Think of it this way: The DUT answers, "What did the hardware produce?" The reference model answers, "What should the hardware have produced?" The scoreboard compares the two.

A common verification flow looks like this:

Sequence


|
v
Driver ---> DUT ---> Monitor ---> Actual transaction
|                         
|                          v
+----> Reference Model --> Expected transaction
|
v
Scoreboard
|
Compare expected
vs. actual

The reference model does not normally drive DUT pins. Its job is to calculate expected behavior at the transaction level.

Step 2: Study a simple reference model

Suppose the DUT implements a simple arithmetic operation:

result = a + b;

A beginner reference model can represent that behavior as a small function or component. The model receives an input transaction and creates the expected output.

class reference_model extends uvm_component;


`uvm_component_utils(reference_model)

uvm_analysis_imp #(packet, reference_model) input_export;
uvm_analysis_port #(packet) expected_port;

function new(string name, uvm_component parent);
super.new(name, parent);
endfunction

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


input_export = new("input_export", this);
expected_port = new("expected_port", this);


endfunction

function void write(packet tr);
packet expected;


expected = packet::type_id::create("expected");

expected.data = tr.a + tr.b;

expected_port.write(expected);


endfunction

endclass

When the reference model receives a transaction, it calculates the expected value and publishes another transaction. The scoreboard can then compare that expected transaction with the transaction observed from the DUT.

Notice the separation of responsibilities:

  • Monitor: observes what actually happened on the interface.
  • Reference model: calculates what should have happened.
  • Scoreboard: compares expected and actual results.

Step 3: Connect the reference model to the scoreboard

The reference model becomes useful when its expected transactions reach the scoreboard. A typical environment connects these components through analysis ports.

function void connect_phase(uvm_phase phase);


super.connect_phase(phase);

agent.monitor.analysis_port.connect(
scoreboard.actual_export
);

reference_model.expected_port.connect(
scoreboard.expected_export
);

agent.monitor.analysis_port.connect(
reference_model.input_export
);
endfunction

Now one observed transaction can be used in two ways: the reference model uses it to calculate the expected result, while the scoreboard receives the DUT's actual result.

Important: Do not confuse a reference model with a monitor. A monitor observes signals and creates transactions. A reference model performs behavioral prediction using those transactions.

Step 4: Compare expected and actual results

The scoreboard performs the final comparison. For a simple transaction, the check might look like this:

if (actual.data == expected.data) begin


`uvm_info("SCOREBOARD",
            "Transaction matched expected result",
            UVM_MEDIUM)
end
else begin
  `uvm_error("SCOREBOARD",
$sformatf(
"Mismatch: expected=%0d actual=%0d",
expected.data,
actual.data
))
end

A useful failure message should contain enough information to reproduce and diagnose the problem. At minimum, report the expected value and the actual value. For more complex protocols, include addresses, operation types, IDs, timestamps, or other fields that help identify the transaction.

Debugging tip: When a scoreboard reports a mismatch, do not immediately assume the DUT is wrong. Check the sequence, monitor, reference model, transaction ordering, and scoreboard matching logic as well.

Step 5: Build it in small pieces

  1. Define the behavior. Write down exactly what the DUT should produce for one input.
  2. Create the transaction. Include only the fields required to describe the operation.
  3. Build the reference calculation. Start with one simple, deterministic operation.
  4. Publish the expected result. Send it through an analysis port or another appropriate TLM connection.
  5. Connect the scoreboard. Feed it both expected and actual transactions.
  6. Run one known case. Confirm that the scoreboard reports a match.
  7. Introduce an intentional error. Change the expected calculation or DUT input temporarily and verify that the scoreboard detects the mismatch.
Common mistake: making the reference model too complicated too early. Start with a small behavioral rule that you can verify manually. Add protocol details, queues, latency handling, and more complex prediction only after the basic comparison works.

Expected vs. actual: the verification boundary

One of the most important habits in verification is keeping the expected and actual paths conceptually separate.

                 EXPECTED PATH
                 |


Input transaction --> Reference Model --> Expected
|
v
Scoreboard
^
|
DUT --> Monitor --> Actual ------------------+
|
|
ACTUAL PATH

If the expected and actual values come from the same implementation, a common bug can potentially be hidden. A good reference model uses a clear behavioral specification or an independently reasoned algorithm rather than simply duplicating DUT code.

Try it yourself

Create a reference model for a transaction containing a, b, and result.

  1. Calculate expected.result = a + b in the reference model.
  2. Publish the expected transaction through an analysis port.
  3. Connect the expected transaction to a scoreboard.
  4. Compare it with the DUT's monitored result.
  5. Test both a matching result and an intentionally incorrect result.

Success criterion: the testbench reports a pass when expected and actual results match and clearly reports an error when they differ.

Key takeaways

  • A reference model predicts what the DUT should produce; it does not drive the DUT.
  • The monitor supplies observed transactions, while the reference model generates expected transactions.
  • The scoreboard compares expected behavior with actual DUT behavior.
  • Keep the reference model simple and as independent from the DUT implementation as practical.
  • Good mismatch messages make verification failures much easier to debug.