Predictors
Connect observed DUT inputs to expected behavior by building predictors that invoke reference models, preserve correlation, and publish reliable expected transactions.
Learning objectives
- Explain the role of a predictor between monitors, reference models, and scoreboards.
- Distinguish predictor responsibilities from reference-model and scoreboard responsibilities.
- Build a UVM predictor using analysis implementation and analysis-port communication.
- Transform monitor transactions into reference-model inputs.
- Publish expected transactions for scoreboard checking.
- Preserve transaction IDs and other correlation information through the prediction path.
- Handle stateful models, reset, and transaction acceptance correctly.
- Recognize when a predictor needs buffering or independent processing.
- Handle one-to-one, one-to-many, many-to-one, and delayed prediction relationships.
- Debug whether a failure originates in the monitor, predictor, reference model, scoreboard, or DUT.
- Design predictors that remain reusable when the verification environment grows.
Step 1: What is a predictor?
Lesson 22 introduced the reference model as an executable representation of expected behavior.
The next problem is integration:
How does a transaction observed by the UVM environment
become an expected transaction that the scoreboard can check?
A predictor performs that integration.
Observed input transaction
|
v
Predictor
|
v
Reference model
|
v
Expected transaction
|
v
Scoreboard
The predictor is therefore the bridge between UVM transaction flow and the reference model.
Step 2: Separate the three responsibilities
A clean checking architecture separates prediction from comparison.
| Component | Primary responsibility |
|---|---|
| Monitor | Observe interface activity and reconstruct transactions. |
| Predictor | Adapt observed transactions, invoke the model, and publish expected transactions. |
| Reference model | Calculate expected behavior according to the specification. |
| Scoreboard | Correlate expected and actual transactions and determine pass/fail. |
The resulting architecture is:
+-------------------+
| Reference Model |
+---------^---------+
|
expected result
|
Input Monitor --> Predictor --> Expected Monitor Stream
|
v
Scoreboard
^
|
Output Monitor --------------------> Actual
Keeping these responsibilities separate prevents the scoreboard from becoming a large combination of transaction adaptation, algorithmic modeling, and comparison logic.
Step 3: Why not call the model directly from the scoreboard?
For a small environment, it may seem convenient to calculate the expected value directly when an actual response arrives.
actual response
|
v
scoreboard
|
v
calculate expected
|
v
compare
This becomes awkward when the expected result must be calculated before the response arrives.
For example:
Request ID=10
Request ID=11
Request ID=12
|
v
Expected:
ID=10 -> A
ID=11 -> B
ID=12 -> C
|
v
Actual responses may arrive:
ID=12
ID=10
ID=11
The predictor can generate expected transactions when requests are accepted, while the scoreboard independently waits for and matches actual responses.
Step 4: The basic predictor data flow
A common UVM predictor has an analysis implementation for incoming transactions and an analysis port for expected transactions.
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;
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);
endfunction
endclass
The predictor receives an input transaction through write() and
publishes the expected transaction through expected_ap.
Step 5: Implement the prediction operation
Suppose the reference model exposes:
function packet predict(packet req);
The predictor can invoke it:
packet_model model;
function void write(packet req);
packet expected;
expected = model.predict(req);
expected_ap.write(expected);
endfunction
The complete flow is now:
monitor.ap.write(request)
|
v
predictor.write(request)
|
v
model.predict(request)
|
v
expected transaction
|
v
predictor.expected_ap.write(expected)
|
v
scoreboard
This is the fundamental predictor pattern.
Step 6: Preserve transaction identity
A predictor should preserve the correlation information needed by the scoreboard.
Input:
ID=27
data=100
|
v
Predictor
|
v
Expected:
ID=27
result=200
If the predictor accidentally creates an expected transaction without the ID:
Expected:
ID=0
result=200
the scoreboard may no longer be able to correlate the expected transaction with the actual response.
The predictor should therefore treat fields such as these as part of the prediction contract when applicable:
- Transaction ID.
- Channel ID.
- Sequence or stream identifier.
- Address.
- Operation type.
- Other protocol-defined correlation information.
Step 7: Transform the monitor transaction
The monitor's transaction type does not always match the reference model's input type.
Monitor transaction
|
v
Predictor transformation
|
v
Model input
For example, a monitor may provide a protocol-level request:
class bus_request extends uvm_sequence_item;
bit [7:0] id;
bit [31:0] address;
bit [31:0] data;
bit write;
endclass
while the model expects a simpler abstraction:
class model_input;
int address;
int data;
bit write;
endclass
The predictor can perform the adaptation:
function model_input make_model_input(bus_request req);
model_input input;
input = new();
input.address = req.address;
input.data = req.data;
input.write = req.write;
return input;
endfunction
This keeps protocol-specific UVM details out of the core behavioral model.
Step 8: One input can produce one expected transaction
The simplest predictor relationship is one-to-one.
Request A --> Expected A
Request B --> Expected B
Request C --> Expected C
For example:
function void write(packet req);
packet expected;
expected = model.predict(req);
expected.id = req.id;
expected_ap.write(expected);
endfunction
This is common for arithmetic blocks, simple protocol transformations, and many memory-mapped operations.
Step 9: One input can produce multiple expected transactions
A predictor is not limited to one expected transaction per input.
Consider a packet that the specification says must generate two output transactions:
Input packet
|
v
Predictor
|
+----> Expected packet A
|
+----> Expected packet B
The predictor can publish both:
function void write(packet req);
packet expected_a;
packet expected_b;
expected_a = model.predict_part_a(req);
expected_b = model.predict_part_b(req);
expected_a.id = req.id;
expected_b.id = req.id;
expected_ap.write(expected_a);
expected_ap.write(expected_b);
endfunction
The scoreboard must then understand the expected transaction semantics. This is an important architectural point: changing the prediction relationship may also require a corresponding checking strategy.
Step 10: Multiple inputs can contribute to one prediction
The reverse relationship is also possible.
Input A ----+
|
Input B ----+--> Predictor --> Expected result
|
Input C ----+
For example, a protocol might require several configuration transactions before the model can predict the result of a later operation.
The predictor may maintain context:
configuration transaction
|
v
predictor state
|
v
data transaction
|
v
reference model
|
v
expected result
This is one reason a predictor can be more than a simple function call.
Step 11: Stateful predictors
A predictor may need its own state even when the reference model is separated into another object.
For example, the predictor might need to remember which configuration applies to a particular channel.
configuration[CHANNEL_A] = mode_1
configuration[CHANNEL_B] = mode_2
Then:
request(channel=CHANNEL_A)
|
v
predictor reads mode_1
|
v
reference model
|
v
expected result
Keep the distinction clear:
- The reference model state represents behavioral state required to calculate expected behavior.
- The predictor state represents integration/context information needed to feed the model correctly.
Step 12: Predict from accepted transactions
Prediction must use the correct transaction boundary.
For a ready/valid interface:
accept = valid && ready
If the input monitor publishes only accepted transactions, the predictor can consume them directly.
Interface
|
v
Monitor
|
| only accepted transfers
v
Predictor
|
v
Reference model
If the monitor instead publishes cycles in which valid is asserted
regardless of ready, the predictor must understand that distinction
or it may predict transactions the DUT never accepted.
Step 13: Predictor and out-of-order responses
The predictor does not normally need to wait for an actual response just because the DUT supports out-of-order completion.
Requests:
ID 10
ID 11
ID 12
Predictor:
ID 10 -> Expected A
ID 11 -> Expected B
ID 12 -> Expected C
DUT responses:
ID 12
ID 10
ID 11
The scoreboard can store the expected transactions by ID.
expected_by_id[10] = expected_A;
expected_by_id[11] = expected_B;
expected_by_id[12] = expected_C;
The predictor generates expected behavior independently from response arrival order. The scoreboard owns the matching policy.
This separation is especially important for Lesson 25's out-of-order scoreboard architecture.
Step 14: When prediction itself must wait
Some models cannot produce an expected result until additional information arrives.
Input A
|
| waiting for B
v
Predictor state
^
|
Input B
|
v
Reference model
|
v
Expected transaction
In such cases, the predictor may need to buffer partial information.
For example:
function void write(input_transaction tr);
partial_by_id[tr.id] = tr;
if (has_all_required_inputs(tr.id)) begin
expected = model.predict(
partial_by_id[tr.id]);
expected_ap.write(expected);
partial_by_id.delete(tr.id);
end
endfunction
The exact state structure depends on the protocol, but the architectural idea is general: prediction can be delayed until the model has enough information.
Step 15: Predictor buffering and TLM FIFOs
A direct write() callback is convenient for simple prediction.
More complicated predictors may benefit from buffering.
Monitor
|
v
analysis_port
|
v
analysis_fifo
|
v
Predictor process
|
v
Reference model
|
v
expected_ap
The predictor can then consume transactions using:
task run_phase(uvm_phase phase);
packet req;
forever begin
input_fifo.get(req);
predict(req);
end
endtask
This is useful when prediction needs blocking operations, independent processing, or coordination between multiple streams.
The key distinction from Lesson 14 remains:
get() blocks the consuming process; it does not mean the entire
simulation is blocked.
Step 16: Reset handling in predictors
If the predictor or model maintains state, reset must clear the appropriate state.
Reset
|
+--> reference model state cleared
|
+--> predictor context cleared
|
+--> scoreboard pending expectations cleared
|
v
New transaction stream
The exact ownership depends on the architecture, but state must not survive a DUT reset accidentally.
For example:
function void reset();
model.reset();
foreach (partial_by_id[id])
partial_by_id.delete(id);
endfunction
Reset handling should be coordinated with the monitor and scoreboard so that stale expected transactions are not compared against post-reset actual traffic.
Step 17: Do not predict transactions the DUT never accepted
Consider a ready/valid input interface:
Cycle 100:
valid=1
ready=0
Cycle 101:
valid=1
ready=1
Only the second cycle represents an accepted transfer.
If the predictor creates predictions on both cycles:
Prediction 1 <-- incorrect
Prediction 2 <-- correct
the scoreboard can become permanently misaligned.
A strong verification architecture therefore defines clearly where acceptance is established.
Step 18: Predictor diagnostics
Prediction failures can be difficult to debug if the predictor is silent. Useful diagnostics should identify the input and the resulting prediction.
`uvm_info("PRED",
$sformatf(
"Predicted ID=%0d opcode=%0d expected=0x%08h",
req.id,
req.opcode,
expected.data),
UVM_HIGH)
During normal regressions, prediction messages can remain at high verbosity. When investigating a failure, the engineer can increase verbosity for the predictor.
This is more useful than printing every prediction at normal verbosity because large regressions may contain millions of transactions.
Step 19: A complete simple predictor
The following example combines the major pieces introduced so far.
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);
// Preserve correlation information.
expected.id = req.id;
`uvm_info("PRED",
$sformatf(
"Predicted ID=%0d expected_data=0x%08h",
expected.id,
expected.data),
UVM_HIGH)
expected_ap.write(expected);
endfunction
endclass
The environment can then connect the streams:
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
input_monitor.ap.connect(predictor.input_imp);
predictor.expected_ap.connect(
scoreboard.expected_imp);
output_monitor.ap.connect(
scoreboard.actual_imp);
endfunction
The architecture is now explicit:
Input Monitor
|
v
Predictor
|
v
Reference Model
|
v
Expected
|
v
Scoreboard
^
|
Actual
^
|
Output Monitor Step 20: Debug the prediction pipeline
When the scoreboard reports a mismatch, determine which layer is responsible before changing code.
Actual mismatch
|
v
Was monitor input correct?
|
+--> No --> Monitor problem
|
+--> Yes
|
v
Was predictor input transformation correct?
|
+--> No --> Predictor problem
|
+--> Yes
|
v
Was model state correct?
|
+--> No --> Model/state problem
|
+--> Yes
|
v
Was expected transaction published correctly?
|
+--> No --> Predictor problem
|
+--> Yes
|
v
Was correlation correct?
|
+--> No --> Scoreboard problem
|
+--> Yes
|
v
Investigate DUT
Useful debug information should therefore expose the prediction boundary.
Input:
ID=17
opcode=ADD
A=10
B=5
Prediction:
ID=17
expected=15
Actual:
ID=17
actual=20
This tells you much more than a generic "scoreboard mismatch" message.
Step 21: Keep prediction independent from DUT timing when possible
A predictor often generates an expected transaction as soon as enough input information is available.
Request accepted
|
v
Predictor
|
v
Expected transaction
DUT latency
|
v
Actual response
The expected transaction does not need to arrive at the scoreboard at the same simulation time as the actual transaction.
The scoreboard can store the expected transaction until the actual response arrives.
This is particularly important for:
- Pipelined DUTs.
- Variable-latency operations.
- Out-of-order responses.
- Multiple outstanding requests.
Functional prediction and response timing can therefore remain separate responsibilities.
Step 22: Avoid making the predictor a second scoreboard
A predictor should generally not decide whether the DUT's response is correct.
Avoid architectures like:
predictor
|
+--> calculate expected
|
+--> receive actual
|
+--> correlate
|
+--> compare
|
+--> report all failures
That duplicates the scoreboard's responsibility and makes the architecture harder to reuse.
Prefer:
Predictor
|
+--> generate expected
Scoreboard
|
+--> correlate
+--> compare
+--> report Common mistakes
- Confusing predictor and reference model: The model calculates expected behavior; the predictor integrates that model into UVM transaction flow.
- Predicting from unaccepted traffic: Make sure the predictor receives transactions at the correct protocol acceptance boundary.
- Losing transaction IDs: Preserve correlation fields required by the scoreboard.
- Embedding scoreboard logic in the predictor: Generate expected transactions; leave comparison and correlation to the scoreboard.
- Ignoring model state: Stateful models require correctly ordered inputs and explicit reset behavior.
- Ignoring predictor state: Configuration and partial transactions may require predictor-owned context.
- Assuming one input always creates one output: Some specifications require one-to-many or many-to-one prediction relationships.
- Waiting for actual responses unnecessarily: Generate predictions as soon as the model has enough information.
- Blocking inside an analysis callback: Use a FIFO and independent processing thread when prediction requires blocking behavior.
- Making prediction dependent on DUT implementation timing: Keep functional expected behavior separate from latency checking where possible.
- Logging every prediction at normal verbosity: Large regressions become unreadable and slow to debug.
- Not validating the predictor independently: A correct reference model can still be integrated incorrectly by the predictor.
Debugging strategy
When a prediction-based scoreboard fails, trace the transaction through the complete pipeline.
- Identify the failing transaction ID.
- Inspect the monitor's input transaction.
- Verify the protocol acceptance event.
- Inspect any predictor transformation.
- Inspect predictor-owned state.
- Inspect the reference-model input.
- Calculate the expected result independently.
- Inspect the expected transaction published by the predictor.
- Verify scoreboard correlation.
- Only then investigate the DUT response.
Monitor
|
| ID=42, A=10, B=5
v
Predictor
|
| model input = 10, 5
v
Reference Model
|
| expected = 15
v
Expected transaction
|
| ID=42, data=15
v
Scoreboard
^
|
| ID=42, data=20
|
Actual monitor
This trace immediately narrows the investigation to the DUT if every prediction-stage value is correct.
Practice: Build a simple predictor
Create a transaction containing:
id
opcode
operand_a
operand_b
Reuse the arithmetic reference model from Lesson 22.
Build a predictor that:
- Receives the transaction through an analysis implementation.
- Passes the operands to the reference model.
- Creates an expected transaction.
- Preserves the transaction ID.
- Publishes the expected transaction through an analysis port.
Connect the expected stream to a scoreboard and verify at least five different transactions.
Challenge: Add predictor state
Extend the predictor so that each transaction contains a channel ID. Maintain a separate configuration value for each channel.
Channel A -> mode 1
Channel B -> mode 2
Request on A -> use mode 1
Request on B -> use mode 2
Verify that changing Channel A's configuration does not accidentally change predictions for Channel B.
Advanced challenge: Out-of-order prediction
Generate requests:
ID=10
ID=11
ID=12
ID=13
Have the predictor produce all expected transactions immediately. Then return actual responses in this order:
ID=12
ID=10
ID=13
ID=11
Your environment should:
- Generate one expected transaction for every accepted request.
- Preserve each transaction ID.
- Store pending expectations in the scoreboard.
- Match responses by ID rather than arrival order.
- Report an unknown ID.
- Report a duplicate response.
- Report an incorrect response value.
- Report an expected transaction that never receives a response.
This exercise combines the reference-model architecture from Lesson 22 with the correlation concepts from Lessons 17 and 18 and prepares you for the dedicated out-of-order scoreboard lesson.
Connection to the next lessons
The checking architecture now has three distinct layers:
Reference Model
|
| expected behavior
v
Predictor
|
| expected transactions
v
Scoreboard
|
| compare / correlate
v
Verification result
The remaining lessons specialize how the scoreboard consumes and checks those expected transactions.
Lesson 21 -> Scoreboard Design Patterns
|
Lesson 22 -> Reference Models
|
Lesson 23 -> Predictors
|
+--> Lesson 24: In-Order Scoreboards
|
+--> Lesson 25: Out-of-Order Scoreboards
|
+--> Lesson 26: Multi-Stream Scoreboards
|
+--> Lesson 27: Error Handling Strategies
|
+--> Lesson 28: Timeout Detection
|
+--> Lesson 29: End-of-Test Scoreboard Draining
|
+--> Lesson 30: Debug-Friendly Diagnostics
The important progression is:
Specification
|
v
Reference Model
|
v
Predictor
|
v
Expected Transaction Stream
|
+---------------------+
|
v
Scoreboard
^
|
Actual Stream
|
v
DUT
Lesson 24 will now focus on the simplest concrete scoreboard policy: in-order checking, including queues, expected/actual alignment, mismatch handling, and the conditions under which ordered comparison is valid.
Self-check
- What is the primary responsibility of a predictor?
- How is a predictor different from a reference model?
- How is a predictor different from a scoreboard?
- Why should a predictor preserve transaction IDs?
- Why is the protocol acceptance boundary important to prediction?
- When might a predictor need its own state?
- Can one input transaction produce multiple expected transactions?
- Can multiple input transactions contribute to one expected result?
- Why might a predictor use an analysis FIFO instead of direct
write()processing? - Why does a predictor not normally need to wait for the DUT response before generating an expected transaction?
- How should predictor and reference-model state respond to reset?
- What information should you inspect when a predicted value is unexpectedly wrong?
- Why should correlation and comparison generally remain in the scoreboard?
Key takeaways
- A predictor connects UVM transaction flow to a reference model.
- The reference model calculates expected behavior; the predictor integrates that model into the environment.
- The scoreboard consumes expected and actual transactions and performs correlation and comparison.
- Predictors commonly receive transactions through analysis implementations and publish expected transactions through analysis ports.
- Protocol-defined transaction acceptance boundaries must be respected when generating predictions.
- Transaction IDs and other correlation information must survive the prediction path.
- Predictors can transform transaction types before passing information to the reference model.
- Prediction relationships are not always one-to-one; one-to-many and many-to-one relationships are possible.
- Predictors may maintain integration state even when the behavioral algorithm lives in a separate reference model.
- Stateful prediction requires explicit reset handling.
- Analysis FIFOs can decouple complex prediction processing from monitor callbacks.
- Prediction should generally be independent of actual response arrival time.
- Good predictor diagnostics make it possible to distinguish monitor, predictor, model, scoreboard, and DUT problems.
- A clean predictor architecture prepares the environment for specialized in-order, out-of-order, and multi-stream scoreboards.