Module 3: Checking Architecture | Intermediate UVM

Reference Models

Build an independent executable model of expected behavior and use it to generate trustworthy predictions for scoreboard checking.

Learning objectives

  • Explain the purpose of a reference model in a UVM verification environment.
  • Distinguish a reference model from a scoreboard, predictor, monitor, and DUT implementation.
  • Translate a specification-level rule into executable expected behavior.
  • Design a reference model that is sufficiently independent from the DUT implementation.
  • Understand stateless and stateful reference models.
  • Connect a reference model to a UVM predictor and scoreboard.
  • Handle model state, reset, ordering, and transaction boundaries correctly.
  • Validate a reference model independently before relying on it for DUT checking.
  • Recognize common modeling mistakes that can cause the checker and DUT to fail in the same way.
  • Prepare a reference-model architecture for more advanced predictor and scoreboard designs.

Step 1: Why do we need a reference model?

Lesson 21 introduced the scoreboard as the component responsible for checking whether observed DUT behavior is correct.

That immediately raises another question:

Where does the expected result come from?

For a very simple DUT, the expected result may be calculated directly inside the scoreboard. For a realistic design, however, expected behavior can involve state, transformations, protocol rules, queues, address mapping, arithmetic, or other nontrivial algorithms.

A reference model provides an executable representation of the expected behavior described by the specification.

Stimulus / observed input
      |
      v
Reference Model
      |
      v


Expected transaction
|
v
Scoreboard
^
|
Actual transaction
|
v
DUT
^
|
Driver
Core idea: The reference model answers "What should the DUT do?" The scoreboard answers "Did the DUT actually do it?"

Step 2: Reference model versus scoreboard

These components are related, but they have different responsibilities.

Component Main question Typical responsibility
Monitor What happened on the interface? Convert signal activity into transactions.
Reference model What should happen? Calculate expected behavior.
Predictor When and from which inputs should expected transactions be produced? Adapt model inputs/outputs to the verification environment.
Scoreboard Does actual behavior match expected behavior? Correlate, compare, and report.
Coverage Which scenarios occurred? Measure verification space.

A useful architecture therefore looks like:

                  +--> Coverage
              |


Input Monitor ----+--> Predictor --> Reference Model
|
v
Expected stream
|
v
Scoreboard
^
|
Actual stream
|
v
Output Monitor

Step 3: The reference model should model behavior, not RTL structure

A reference model is useful only if it provides meaningful independent verification.

Suppose the specification says:

For each input value:
output = input * coefficient

A simple model could be:

function automatic int predict(int input, int coefficient);


return input * coefficient;
endfunction

The model does not need to reproduce the RTL's internal pipeline stages, registers, implementation-specific control logic, or signal names.

The important requirement is that it accurately represents the behavior that the verification environment needs to check.

Step 4: Start from the specification

A good reference model begins with a behavioral requirement, not with the RTL.

For example, consider a simple packet transformation:

Specification:


Input packet:
opcode
address
data

Expected result:
if opcode == ADD:
result = address + data


if opcode == XOR:
    result = address ^ data

The reference model can express that behavior directly:

function automatic packet predict(packet req);


packet rsp;

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

rsp.id = req.id;

case (req.opcode)


ADD:
  rsp.data = req.address + req.data;

XOR:
  rsp.data = req.address ^ req.data;

default:
  rsp.error = 1;


endcase

return rsp;

endfunction

The model is intentionally expressed at the behavioral level. It does not attempt to reproduce how the DUT internally implements ADD or XOR.

Step 5: Stateless reference models

The simplest reference models are stateless. Their output depends only on the current input.

output = f(input)

For example:

function automatic bit [31:0]


calculate_checksum(bit [31:0] data);

return data[15:0] + data[31:16];

endfunction

A stateless model has several advantages:

  • Simple input/output relationship.
  • Easy unit testing.
  • No internal history to synchronize.
  • Easy reuse in multiple tests.
  • Simple debugging when a prediction is incorrect.

Many arithmetic or data-transformation blocks can be modeled this way.

Step 6: Stateful reference models

Real designs frequently depend on previous transactions. In those cases, the reference model must maintain state.

Consider a simple accumulator:

Specification:


On each accepted transaction:


accumulator = accumulator + data

output = accumulator

The reference model needs internal state:

class accumulator_model;


int accumulator;

function new();
accumulator = 0;
endfunction

function int predict(int data);
accumulator += data;
return accumulator;
endfunction

function void reset();
accumulator = 0;
endfunction

endclass

Now prediction depends on transaction history:

Input   Model state   Expected output


10      0 -> 10       10
5       10 -> 15      15
8       15 -> 23      23

Stateful models require much more careful reset and transaction-order handling than stateless models.

Step 7: Reset is part of the model

If the DUT state changes during reset, the reference model must reflect the same architectural reset behavior.

DUT:
reset
  |
  v


internal_state = 0

Reference model:
reset
|
v
model_state = 0

A model that forgets to reset can produce a long sequence of apparently unrelated scoreboard failures after reset.

A stateful model should therefore expose an explicit reset operation:

function void reset();


accumulator = 0;
pending_count = 0;
endfunction

The verification environment should define clearly when that reset operation occurs relative to transaction processing.

Important: Reset is not just another input transaction unless the specification defines it that way. Model the DUT's architectural reset semantics explicitly.

Step 8: Define the model's transaction boundary

The model must know when an input transaction is actually accepted.

For a ready/valid interface, acceptance may occur when:

valid && ready

The reference model should generally process the transaction at that defined acceptance point rather than whenever valid happens to be high.

valid = 1


ready = 0
|
|  no transaction accepted
|
v
valid = 1
ready = 1
|
v
transaction accepted
|
v
reference model processes input

This is an important connection to the protocol-monitoring concepts from the previous module.

Step 9: Model state versus DUT timing

A reference model does not necessarily need to reproduce cycle-by-cycle implementation timing.

Suppose a DUT accepts a request at cycle 100 and returns a response at cycle 115.

Cycle 100                 Cycle 115


|                         |
v                         v
Request accepted --------> Response

The reference model may simply calculate:

expected_response = model.predict(request);

The scoreboard and other checking infrastructure can separately verify:

  • Whether the response is correct.
  • Whether it has the correct ID.
  • Whether it arrived within the allowed latency.
  • Whether it obeyed protocol ordering rules.

This separation prevents the behavioral model from becoming unnecessarily coupled to implementation timing.

Step 10: Reference model architecture

A clean architecture can separate the model from the UVM plumbing.

class packet_model;


function packet predict(packet req);


packet expected;

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

// Specification-level behavior

return expected;


endfunction

endclass

The model itself does not need to know about UVM analysis ports, phases, or report mechanisms.

A UVM predictor can adapt it:

class packet_predictor extends uvm_component;


`uvm_component_utils(packet_predictor)

uvm_analysis_imp #(packet, packet_predictor) input_imp;
uvm_analysis_port #(packet) expected_ap;

packet_model model;

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

function void build_phase(uvm_phase phase);


super.build_phase(phase);

input_imp  = new("input_imp", this);
expected_ap = new("expected_ap", this);

model = new();


endfunction

function void write(packet req);


packet expected;

expected = model.predict(req);

expected_ap.write(expected);


endfunction

endclass

This gives the environment a clean separation:

UVM transport
 |
 v


Predictor
|
v
Reference model
|
v
Expected transaction
|
v
Scoreboard

Step 11: Why the predictor is useful

A reference model and a predictor are related but not identical concepts.

The reference model answers:

Given this input, what should the behavior be?

The predictor answers:

Given the transactions observed by this verification environment,


when and how should I invoke the model and publish the expected result?

The predictor may therefore perform additional work:

  • Translate monitor transactions into model inputs.
  • Maintain model context.
  • Call the reference model.
  • Attach transaction IDs to predictions.
  • Split or combine transactions when required.
  • Publish expected transactions through an analysis port.

Lesson 23 will focus specifically on these predictor patterns.

Step 12: Connect expected and actual streams

The complete checking architecture now becomes:

                 +------------------+
             | Reference Model  |
             +--------+---------+
                      ^
                      |
                Predictor
                      ^
                      |
                Input Monitor
                      |
                      v
                     DUT
                      |
                      v
                Output Monitor
                      |
                      v
                   Actual
                      |
                      v
                +-----------+


Expected ---------->| Scoreboard|
+-----------+

In a real environment, the expected stream may be generated from input-side observations rather than directly from the sequence. This can be valuable because the predictor then models behavior based on what the DUT actually accepted.

Debug principle: Decide whether the model should consume test intent, driver activity, or monitor-observed input. For protocol checking, monitor-observed accepted transactions are often the strongest basis because they represent activity actually seen at the DUT interface.

Step 13: Handle stateful pipelines carefully

A more realistic model might represent a queue or pipeline.

Input A --> Model state


Input B --> Model state
Input C --> Model state


         |
         v


Expected A
Expected B
Expected C

The model must update its state at the correct transaction boundary. If it updates too early or too late, every subsequent prediction can become incorrect.

For example, if a DUT accepts only when valid && ready, the model should not consume a transaction during cycles where ready == 0.

Cycle   valid   ready   Model action


100       1       0     wait
101       1       0     wait
102       1       1     consume transaction
103       0       1     no input

A single incorrect acceptance rule can cause a long cascade of false scoreboard failures.

Step 14: Model state should match architectural state

Not every internal RTL state needs to exist in the reference model.

Suppose the DUT contains:

state machine


pipeline registers
temporary staging registers
implementation-specific control flags

The reference model may need only:

architectural_state

For example, if a register block exposes a set of architecturally visible registers, the model may maintain those register values without reproducing every internal RTL register used to implement them.

This reduces coupling and makes the model easier to maintain when the DUT implementation changes without changing externally visible behavior.

Step 15: Keep the model deterministic

For the same valid input state, a reference model should normally produce the same expected result.

same state
+


same input
|
v
same expected behavior

If the specification allows nondeterministic behavior, the model may instead need to describe a set or range of legal outcomes.

For example, if a protocol permits either response order:

Legal:


Response A
Response B

or:

Response B
Response A

the reference model should not arbitrarily impose one ordering unless the specification actually requires it.

This connects directly to Lesson 21's principle: the checking architecture must follow the protocol contract.

Step 16: Avoid over-modeling

A common temptation is to build a complete software simulation of the DUT. That is not always necessary.

A useful reference model should contain enough behavior to determine whether the required DUT behavior is correct.

Avoid adding:

  • RTL implementation details that are irrelevant to the check.
  • Timing behavior that is already checked elsewhere.
  • Internal signals that are not architecturally meaningful.
  • Duplicate logic that another verification component already owns.
  • Unnecessary protocol mechanics that belong in the monitor or predictor.
Modeling principle: Model the specification at the abstraction level needed for checking. More model complexity does not automatically produce better verification.

Step 17: Validate the reference model before trusting it

A reference model is itself verification infrastructure. It can contain bugs.

Therefore, do not immediately assume:

model output = truth

Instead, validate the model using independent evidence.

  1. Write directed tests for simple specification cases.
  2. Check boundary values.
  3. Check illegal and error conditions.
  4. Check reset behavior.
  5. Check state transitions.
  6. Compare model results against known-good reference data where available.
  7. Use small hand-calculated examples before large randomized tests.

For example:

Input A = 10


Input B = 5

Expected:
A + B = 15

Model:
15

Pass

Only after the model itself is trusted should it become the basis for thousands of automated scoreboard comparisons.

Step 18: Debug model failures separately from DUT failures

Suppose the scoreboard reports:

Expected = 0x1234


Actual   = 0x5678

There are at least two major possibilities:

Was the model wrong?
    |
    +--> Yes --> fix reference model
    |
    +--> No
          |
          v
    Investigate DUT behavior

Useful diagnostics should therefore expose the model input as well as the expected and actual outputs.

UVM_ERROR [SB_MISMATCH]


ID       = 17
opcode   = ADD
address  = 0x1000
input    = 0x0020

Expected = 0x1020
Actual   = 0x1000

This makes it possible to reproduce the model calculation independently.

Step 19: Reference models and transaction correlation

The model should preserve the information needed by the scoreboard to correlate expected and actual transactions.

Request ID=42
 |
 v


Reference model
|
v
Expected ID=42

Actual response ID=42
|
v
Scoreboard
|
+--> compare
|
+--> consume expected

For out-of-order protocols, the model may generate expected transactions faster than the DUT returns actual responses.

Expected:


ID 10 -> result A
ID 11 -> result B
ID 12 -> result C

Actual:

ID 12
ID 10
ID 11

The scoreboard, not the reference model, should normally own the matching policy unless the model itself has a protocol-specific reason to manage outstanding state.

This separation keeps expected-data generation independent from response arrival order.

Step 20: Reference models and reset/restart scenarios

Verification environments frequently reset the DUT multiple times in one simulation.

Initial state
 |
 v


Transactions
|
v
Reset
|
v
Model reset
|
v
New transactions
|
v
New predictions

If pending model state survives a reset when the DUT state does not, the scoreboard may report a large number of false mismatches.

Reset handling should therefore be treated as an explicit model requirement, not as an afterthought.

Common mistakes

  • Copying RTL into the model: This creates unnecessary coupling and can reproduce the same implementation bug.
  • Confusing a reference model with a scoreboard: The model calculates expected behavior; the scoreboard checks observed behavior.
  • Ignoring transaction acceptance rules: A model that consumes data before the DUT actually accepts it can become permanently misaligned.
  • Forgetting reset: Stateful models must reset when the architectural DUT state resets.
  • Modeling implementation timing unnecessarily: Functional expected behavior and cycle-level latency checking can often be separated.
  • Ignoring legal nondeterminism: Do not impose an ordering or value constraint that the specification does not require.
  • Making the model depend on waveform signals: Prefer transaction-level inputs derived from well-defined protocol events unless lower-level information is genuinely required.
  • Making the model too complex: A large software replica of the DUT can become another difficult-to-verify project.
  • Trusting the model without validation: A wrong reference model can make a correct DUT look broken or allow an incorrect DUT behavior to appear correct.
  • Mixing correlation with prediction: Keep expected-data generation separate from response matching when possible.

Debugging strategy

When a reference-model-based scoreboard fails, debug the chain from input through prediction to comparison.

  1. Identify the failing transaction ID.
  2. Inspect the actual input transaction seen by the model.
  3. Verify that the input was accepted at the correct protocol event.
  4. Inspect the model state at prediction time.
  5. Calculate the expected result independently from the specification.
  6. Check that the predictor published the correct expected transaction.
  7. Check scoreboard correlation.
  8. Compare the expected and actual transactions.
  9. Use transaction recording and waveforms only after the transaction-level evidence is understood.
Observed input
  |
  v


Correct transaction?
|
+--> No --> monitor / protocol issue
|
+--> Yes
|
v
Correct model state?
|
+--> No --> reference model state issue
|
+--> Yes
|
v
Correct prediction?
|
+--> No --> model / predictor issue
|
+--> Yes
|
v
Correct correlation?
|
+--> No --> scoreboard issue
|
+--> Yes
|
v
Investigate DUT

This layered approach is especially important because a scoreboard failure does not automatically prove that the DUT is wrong.

Practice: Build a stateless reference model

Create a simple transaction containing:

opcode


operand_a
operand_b
id

Implement a reference model supporting:

  • ADD
  • SUB
  • AND
  • OR
  • XOR

The model should return an expected transaction containing the original ID and calculated result.

Validate it with at least:

  • Zero operands.
  • Maximum values.
  • Equal operands.
  • Different opcodes.
  • Multiple transaction IDs.

Challenge: Build a stateful model

Implement a reference model for an accumulator with the following behavior:

On accepted request:
accumulator = accumulator + data
expected_response = accumulator


On reset:
accumulator = 0

Generate:

10


5
20
7

Verify that the model produces:

10


15
35
42

Then reset the model and verify that the next input starts again from zero.

Advanced challenge: Predictor plus scoreboard

Build the complete path:

Input monitor
 |
 v


Predictor
|
v
Reference model
|
v
Expected transaction
|
v
Scoreboard
^
|
Actual monitor
|
v
DUT

Add a transaction ID to every request and response.

Then deliberately introduce:

  1. A wrong model calculation.
  2. A wrong transaction ID.
  3. An incorrect DUT response.
  4. A reset that the model fails to process.

For each failure, determine whether the problem belongs to the monitor, predictor, reference model, scoreboard, or DUT.

Connection to the next lessons

Lesson 21 established the scoreboard as the checking architecture. Lesson 22 now introduces the component that can generate independent expected behavior.

Lesson 21  -> Scoreboard Design Patterns
              |
              v


Lesson 22  -> Reference Models
|
v
Lesson 23  -> Predictors
|
v
Lesson 24  -> In-Order Scoreboards
|
v
Lesson 25  -> Out-of-Order Scoreboards
|
v
Lesson 26  -> Multi-Stream Scoreboards
|
v
Lesson 27  -> Error Handling Strategies
|
v
Lesson 28  -> Timeout Detection
|
v
Lesson 29  -> End-of-Test Scoreboard Draining
|
v
Lesson 30  -> Debug-Friendly Diagnostics

The architectural progression is:

Specification
  |
  v


Reference Model
|
v
Predictor
|
v
Expected Transactions
|
+------------------+
|
v
Scoreboard
^
|
Actual Transactions
|
v
DUT

Lesson 23 will focus on the predictor layer: how to invoke models from observed traffic, manage model inputs and outputs, and adapt expected behavior to the transaction-level architecture of a real UVM environment.

Self-check

  1. What is the primary purpose of a reference model?
  2. How is a reference model different from a scoreboard?
  3. Why should a reference model avoid unnecessary RTL implementation details?
  4. What is the difference between a stateless and stateful reference model?
  5. Why must reset behavior be represented in a stateful model?
  6. Why is transaction acceptance important when feeding a model?
  7. Does a reference model normally need to reproduce the DUT's pipeline timing? Why or why not?
  8. Why should a model preserve transaction IDs when the scoreboard uses them for correlation?
  9. What role does a predictor play between a monitor and a reference model?
  10. How can an incorrect reference model produce false DUT failures?
  11. How can an incorrect reference model hide a real DUT bug?
  12. Why should a reference model be validated independently?
  13. What information should you inspect first when a model-based scoreboard reports a mismatch?
Expected understanding: You should be able to take a specification-level behavioral rule, express it as an executable reference model, identify whether it needs state, handle reset and transaction boundaries correctly, and integrate it with a predictor and scoreboard without coupling the model to the DUT's implementation.

Key takeaways

  • A reference model represents expected behavior independently of the DUT implementation.
  • The reference model calculates what should happen; the scoreboard determines whether the DUT actually produced that behavior.
  • A predictor adapts observed verification transactions to the reference model and publishes expected transactions.
  • Stateless models depend only on current inputs; stateful models depend on architectural history.
  • Stateful models must handle reset and transaction acceptance at the correct boundaries.
  • The model does not normally need to reproduce every RTL register, pipeline stage, or implementation detail.
  • Functional prediction and cycle-level timing checking can be separated when the verification architecture allows it.
  • Legal nondeterminism should be modeled as permitted behavior rather than accidentally turned into a false ordering requirement.
  • Transaction IDs and other correlation information must survive the prediction path when the scoreboard depends on them.
  • A reference model is itself verification code and must be validated independently.
  • Debug should distinguish model errors, predictor errors, scoreboard correlation errors, and actual DUT failures.
  • A clean model/predictor/scoreboard separation makes checking architecture easier to reuse and extend.