RAL Predictors
A practical, step-by-step lesson for building reliable and reusable UVM verification environments.
Learning objectives
- Explain why prediction must be driven by monitored bus activity.
- Choose explicit or auto prediction and prevent double prediction.
- Debug mirror mismatches by comparing request, response, and predictor inputs.
Step 1: Understand the concept
A predictor updates the register model from transactions observed on the bus. The model must learn what the DUT accepted, rather than trusting what the driver intended to send.
Use one prediction policy per path. With an explicit predictor, disable the map's auto-prediction or the same transaction may update the mirror twice. Failed bus operations must not update the mirror.
Step 2: Study the example
Read the example from top to bottom. Identify the UVM class or communication point first, then trace the transaction or configuration value through it.
class csr_predictor extends uvm_reg_predictor #(apb_item);
`uvm_component_utils(csr_predictor)
function void write(apb_item item);
uvm_reg_bus_op rw;
rw.kind = item.write ? UVM_WRITE : UVM_READ;
rw.addr = item.addr;
rw.data = item.write ? item.wdata : item.rdata;
rw.byte_en = item.strb;
rw.status = item.error ? UVM_NOT_OK : UVM_IS_OK;
bus_in.write(rw);
endfunction
endclass
The predictor consumes the monitor's item, not the driver's request. A read response supplies read data; a failed operation supplies no new state.
Step 3: Build it in small pieces
- Connect the monitor to one predictor and document who owns prediction.
- Run a successful write, failed write, and read response while logging predictor input.
- Compare the mirror after each observed transaction and verify failed operations leave it unchanged.
- Temporarily enable a second prediction path to diagnose a double-update failure.
Try it yourself
Acceptance criteria: only monitored successful operations update the mirror; failed writes do not; read responses update read-only fields correctly; and there is one documented prediction owner.
Architecture review for RAL Predictors
Apply the module's working contract to this topic: address, width, reset, access policy, volatility, side effects, byte enables, and the bus path. Identify the component that owns the behavior and the independent observer that can prove it. The implementation is not complete until both sides are named.
| Review dimension | Question to answer | Evidence to keep |
|---|---|---|
| Ownership | Which UVM object creates, configures, and controls this behavior? | build/connect/run trace |
| Correctness | What expected result is compared with the observed result? | checker, assertion, or status |
| Failure | What is the first useful symptom if the behavior is wrong? | context-rich report and transaction |
| Reuse | What changes when the interface, test, or configuration changes? | portable scenario or documented limitation |
Implementation walkthrough
- Convert the topic into one requirement with a measurable expected outcome.
- Declare the configuration and transaction types at the ownership boundary instead of using hidden globals.
- Construct objects in
build_phase, connect TLM paths inconnect_phase, and perform scenario timing in sequences or run phases. - Attach an independent monitor, checker, coverage collector, or report consumer before adding random stimulus.
- Run the smallest positive case, then a boundary and negative case, and preserve the first failure.
function void report_result(string operation,
string expected, string actual);
`uvm_info("EVIDENCE", $sformatf(
"operation=%s expected=%s actual=%s",
operation, expected, actual), UVM_LOW)
endfunction
Use structured evidence instead of a vague pass message. A report should tell a reviewer which operation ran, what was expected, what was observed, and where to look next.
Failure-driven exercise
Break one part of the implementation deliberately: remove a TLM connection, change a boundary value, delay an event, or provide an invalid configuration. Predict the symptom before running the test, then compare that prediction with the actual log.
- Record the test name, seed, configuration, phase, and transaction identity.
- Identify the first incorrect observation, not only the final cascade of errors.
- Repair the responsible owner and rerun the same reproducer.
- Explain what review or assertion would prevent the defect returning.
Architecture review for RAL Predictors
Apply the module's working contract to this topic: address, width, reset, access policy, volatility, side effects, byte enables, and the bus path. Identify the component that owns the behavior and the independent observer that can prove it. The implementation is not complete until both sides are named.
| Review dimension | Question to answer | Evidence to keep |
|---|---|---|
| Ownership | Which UVM object creates, configures, and controls this behavior? | build/connect/run trace |
| Correctness | What expected result is compared with the observed result? | checker, assertion, or status |
| Failure | What is the first useful symptom if the behavior is wrong? | context-rich report and transaction |
| Reuse | What changes when the interface, test, or configuration changes? | portable scenario or documented limitation |
Implementation walkthrough
- Convert the topic into one requirement with a measurable expected outcome.
- Declare the configuration and transaction types at the ownership boundary instead of using hidden globals.
- Construct objects in
build_phase, connect TLM paths inconnect_phase, and perform scenario timing in sequences or run phases. - Attach an independent monitor, checker, coverage collector, or report consumer before adding random stimulus.
- Run the smallest positive case, then a boundary and negative case, and preserve the first failure.
function void report_result(string operation,
string expected, string actual);
`uvm_info("EVIDENCE", $sformatf(
"operation=%s expected=%s actual=%s",
operation, expected, actual), UVM_LOW)
endfunction
Use structured evidence instead of a vague pass message. A report should tell a reviewer which operation ran, what was expected, what was observed, and where to look next.
Failure-driven exercise
Break one part of the implementation deliberately: remove a TLM connection, change a boundary value, delay an event, or provide an invalid configuration. Predict the symptom before running the test, then compare that prediction with the actual log.
- Record the test name, seed, configuration, phase, and transaction identity.
- Identify the first incorrect observation, not only the final cascade of errors.
- Repair the responsible owner and rerun the same reproducer.
- Explain what review or assertion would prevent the defect returning.
Technical deep review: RAL Predictors
Evaluate ral predictors using the module contract: address, width, reset, access policy, volatility, side effects, byte enables, and the bus path. Do not stop at whether the API call completes. Identify the state transition, the independent observation, the failure report, and the evidence that another engineer can audit.
| Dimension | Question | Evidence |
|---|---|---|
| Semantics | What does the operation mean before and after execution? | state table or transaction trace |
| Ownership | Which component is allowed to change or check the state? | build/connect/run design |
| Failure | What is the first incorrect observation? | context-rich report |
| Reuse | What can vary without changing the scenario? | configuration or extension contract |
Technical implementation checklist
- State the requirement, preconditions, expected result, and failure policy.
- Declare typed configuration and transaction boundaries instead of hidden global state.
- Construct objects in
build_phaseand connect communication inconnect_phase. - Attach an independent monitor, checker, assertion, or coverage consumer.
- Run nominal, boundary, negative, reset, and repeated cases where applicable.
- Preserve seed, phase, transaction ID, expected value, actual value, and first failure.
`uvm_info("EVIDENCE", $sformatf(
"component=%s phase=%s expected=%s actual=%s",
get_full_name(), phase_name, expected, actual), UVM_LOW)
Failure-driven lab and review rubric
Introduce one controlled defect in ral predictors: remove a connection, change a boundary, delay an event, or alter configuration. Predict the symptom, run the smallest reproducer, and repair the responsible layer.
- Pass: deterministic positive behavior is checked independently.
- Pass: a boundary and negative case produce intentional outcomes.
- Pass: the injected defect is detected with useful context.
- Pass: the remaining limitation and prevention action are documented.
Learn: RAL Predictors
In this lesson, focus on how to update the mirror from accepted monitor transactions, not driver intent. This matters because the register model must agree with the software-visible specification and with observed bus activity. Start with one requirement and one expected result before adding randomization or additional components.
// Topic: RAL Predictors
// Primary API or artifact: uvm_reg_predictor and bus_in
// Expected evidence: one observable result tied to the requirement
What to notice: uvm_reg_predictor and bus_in is the subject of this lesson. It is not enough for the call or artifact to exist; the testbench must observe the resulting transaction, state change, checker result, coverage sample, or review decision.
Expected behavior: the normal case produces the documented result, the boundary case is deliberate, and the failure case identifies the responsible owner instead of hiding the symptom.
Try it: RAL Predictors
- Write the requirement, preconditions, expected result, and failure policy.
- Implement the smallest example that uses
uvm_reg_predictor and bus_in. - Run a nominal case, a boundary case, and a controlled failure.
- Record the seed or configuration, transaction identity, expected result, actual result, and first incorrect observation.
- prove failed transfers do not change the mirror.
Check your work: another engineer should be able to understand what was tested, reproduce the result, and identify what remains unverified.
Learn the idea in plain language
RAL Predictors means that you must update the mirror from accepted monitor transactions, not driver intent. In practical verification, this matters because the register model must agree with the software-visible specification and with observed bus activity. Start with a small, deterministic example. Once the example works, add error cases, concurrency, and randomization.
There are three questions to ask before writing UVM code:
- What requirement or risk does this topic address?
- Which object owns the behavior, and which object observes the result independently?
- What exact evidence proves success or exposes the first failure?
Key terms
| Term | Meaning | Why it matters here |
|---|---|---|
requirement | Behavior the design must provide | defines what the test must prove |
owner | UVM object responsible for a behavior | prevents duplicated or hidden responsibilities |
observation | Independent evidence of what happened | prevents stimulus from validating itself |
boundary | Minimum, maximum, transition, or exceptional case | finds defects that nominal traffic misses |
diagnostic | Context preserved when behavior fails | reduces debug time in regressions |
Use the vocabulary consistently in code reviews. Saying “the test failed” is incomplete. Say which requirement failed, which observation was wrong, which owner produced it, and which evidence should be inspected next.
Example 1: the smallest useful pattern
// Topic: RAL Predictors
// Primary API: uvm_reg_predictor and bus_in
function void check_result(string expected, string actual);
if (expected != actual)
`uvm_error("TOPIC", $sformatf(
"expected=%s actual=%s", expected, actual))
else
`uvm_info("TOPIC", "observable result is correct", UVM_LOW)
endfunction
This small pattern has an owner, an expected result, an actual result, and a report. It is not a complete environment, but it demonstrates the minimum contract that every advanced component should expose.
What each part does
check_resultreceives data rather than reaching into another component's private state.expectedrepresents the verification plan or reference model.actualcomes from a monitor, response, assertion, or measured artifact.uvm_errorpreserves a failure in the report stream instead of silently returning.uvm_inforecords successful evidence at a controlled verbosity.
Expected result: a passing case reports the operation as correct; a failing case names both values and allows the test to be reproduced.
Example 2: connect the pattern to UVM phases
class topic_component extends uvm_component;
`uvm_component_utils(topic_component)
topic_config cfg;
uvm_analysis_imp #(topic_item, topic_component) input_export;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
input_export = new("input_export", this);
if (!uvm_config_db#(topic_config)::get(this, "", "cfg", cfg))
`uvm_fatal("CFG", "missing topic configuration")
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
// Connect the monitor or producer to input_export.
endfunction
function void write(topic_item item);
// Apply the topic rule and publish evidence.
endfunction
endclass
This example shows where the topic belongs in a real UVM component. Construction and configuration happen in build_phase. TLM connectivity happens in connect_phase. The observed transaction is processed by write().
Do not move all behavior into the test just because the test is easy to edit. Tests choose scenarios; reusable components implement and observe the mechanism.
Step-by-step implementation
- Write the requirement in one sentence and identify the failure risk.
- List the input type, output type, configuration, and lifecycle phase.
- Choose the independent monitor, checker, assertion, coverage collector, or review artifact.
- Implement a nominal case with a known expected result.
- Add the smallest boundary case that could expose an off-by-one or ordering defect.
- Add an invalid or failure case and define whether it should error, reject, ignore, or recover.
- Record seed, configuration, component path, transaction ID, expected value, actual value, and first failure.
- Only after these checks pass, add random stimulus or broader concurrency.
This order is deliberately conservative. It gives each later test a trustworthy foundation and prevents a large regression from hiding a small wiring mistake.
Decision table
| Situation | Preferred choice | Reason |
|---|---|---|
| One reusable protocol behavior | agent, driver, monitor, or sequence | keeps protocol mechanics reusable |
| Several interfaces must coordinate | virtual sequence and typed handles | keeps scenario intent above protocol details |
| Observed behavior must be compared | scoreboard, predictor, or assertion | provides independent correctness evidence |
| A test needs controlled variation | configuration or factory extension | avoids editing shared code |
| A risk has not occurred | targeted sequence and coverage point | connects stimulus to a measurable gap |
The correct choice depends on lifetime, ownership, timing, and evidence. Familiarity alone is not an architecture decision.
Expected behavior and output
UVM_INFO @ 0: reporter [BUILD] topic configuration accepted
UVM_INFO @ 120ns: env.monitor [OBSERVE] id=7 operation completed
UVM_INFO @ 120ns: env.checker [CHECK] expected=result_7 actual=result_7
UVM_ERROR @ 240ns: env.checker [CHECK] id=8 expected=result_8 actual=result_6
The successful messages establish that construction, observation, and checking occurred. The error identifies an actual mismatch and includes the transaction identity. In a real project, include the address, phase, reset state, configuration, or coverage bin that is specific to the topic.
A report without context creates a second debugging problem. A report with too much low-value data makes the first failure hard to find. Keep high-signal fields at low verbosity and enable detailed traces for a minimized reproducer.
Common mistakes
| Mistake | Why it is dangerous | Better approach |
|---|---|---|
| Checking the driver request | the test can pass even when the DUT rejects it | check the monitor response |
| Using hidden global state | tests influence each other and reuse becomes unclear | use typed configuration and explicit connections |
| Testing only nominal traffic | boundary and recovery defects remain invisible | add boundary, negative, reset, and repeated cases |
| Weakening a checker after a failure | the environment becomes falsely green | preserve the failure and fix its owner |
| Adding randomization too early | many failures obscure the first wiring defect | prove a deterministic vertical slice first |
| Claiming coverage from API calls | an API call does not prove DUT behavior | sample observable results tied to requirements |
Mini quiz
- What requirement does RAL Predictors verify?
- Which component owns the behavior?
- Where does the independent actual result come from?
- What boundary case would be most valuable?
- What information must appear in the first failure report?
Answer guide: use the specific contract for this lesson, name one UVM owner, identify an observation path, choose a realistic edge condition, and include enough context to reproduce the failure.
Practice exercise
prove failed transfers do not change the mirror Extend the task with a short design note containing the requirement, assumptions, component owner, positive case, boundary case, negative case, expected evidence, and remaining risk.
- Implement the smallest example and run it with a fixed seed or fixed configuration.
- Capture the expected and actual result in the report.
- Introduce one controlled defect related to ral predictors.
- Diagnose the first incorrect observation without disabling checks.
- Restore the implementation and rerun the same reproducer.
Guided walkthrough: from requirement to evidence
Use this four-pass method for RAL Predictors. First write what must be true. Next identify the UVM owner and interface. Then implement the smallest path that can produce evidence. Finally challenge the path with a boundary and a controlled defect.
- Pass 1 - describe: write one requirement, one precondition, and one expected result.
- Pass 2 - design: decide whether the owner is a sequence, component, monitor, checker, coverage collector, service, or review artifact.
- Pass 3 - implement: use uvm_reg_predictor and bus_in and connect it through the normal UVM lifecycle.
- Pass 4 - prove: capture an observation that demonstrates the register model must agree with the software-visible specification and with observed bus activity.
This method prevents a common advanced-level mistake: writing a large amount of testbench code before deciding what the code must prove.
Guided example: make the boundary visible
class topic_checker extends uvm_component;
`uvm_component_utils(topic_checker)
function void check(topic_item actual);
topic_item expected;
expected = model.predict(actual);
if (!actual.compare(expected))
`uvm_error("TOPIC_CHECK", $sformatf(
"path=%s id=%0d expected=%s actual=%s",
get_full_name(), actual.id,
expected.sprint(), actual.sprint()))
endfunction
endclass
The checker is deliberately independent from the driver. It receives an actual observation, creates or obtains an expectation, and reports a comparison. Adapt the same boundary to the API in this lesson.
Read the example in order
- The component is created by the environment and has a stable name.
- The
check()method receives observed behavior. - The expectation is produced by a model or reference policy.
- The comparison preserves the path and transaction ID.
- The failure is actionable without opening every waveform by default.
API checklist
| Check | Question | Result to record |
|---|---|---|
| Declaration | Is the type or API strongly typed and created by the correct owner? | class path and factory type |
| Configuration | Are defaults validated and can the test override them deliberately? | resolved configuration print |
| Connection | Does the input arrive from the intended monitor or producer? | TLM topology or connection log |
| Timing | Is the operation legal in the current phase and reset state? | phase and timestamp |
| Checking | Is actual behavior compared against an independent expectation? | pass/fail report with values |
| Recovery | What happens after timeout, reset, error, or duplicate activity? | defined recovery result |
| Reuse | Can another test or interface use this without editing internals? | public API and limitation |
What should happen in each phase?
| Phase or activity | Expected work | Do not do this |
|---|---|---|
build_phase | create components, objects, and configuration | wait for clock events or drive protocol activity |
connect_phase | connect TLM ports, exports, and analysis paths | start sequences or depend on DUT responses |
end_of_elaboration | print topology and validate required handles | silently accept null sequencers or missing exports |
run_phase | execute timed stimulus and wait for observable completion | finish on sequence completion before checking drain |
report_phase | summarize errors, coverage, and residual risk | claim success from a single status bit |
The exact phase details vary by topic, but ownership remains stable. Put construction, communication, timing, and reporting in the phase where another engineer would expect to find them.
Troubleshooting playbook
| Symptom | Ask first | Useful next action |
|---|---|---|
| No transaction or result | Was the object created and connected? | print topology and resolved configuration |
| Wrong expected value | Is the reference model independent and current? | compare expected state before and after the event |
| Only boundary fails | Is the limit inclusive, exclusive, or transformed? | write a directed boundary test and inspect fields |
| Only random test fails | Which seed and ordering produced the first error? | rerun the exact command and reduce stimulus |
| Test hangs | Which objection, wait, or queue is not completing? | add timeout and report outstanding work |
| High coverage, low confidence | Did the checker prove the covered behavior? | trace the bin to a requirement and assertion/check |
Debug from the first incorrect observation forward. Later errors are often consequences. Preserve the original seed, configuration, phase, transaction ID, and time before changing the test.
Knowledge check
- State the single most important requirement for RAL Predictors.
- Name the UVM object that owns its implementation.
- Name the independent object or artifact that proves the result.
- Choose one boundary case and explain why it is valuable.
- Choose one failure injection and predict its first symptom.
- List the minimum information needed to reproduce that failure.
Self-check: your answers should identify a specific requirement, one owner, one observation, one realistic edge, one predicted symptom, and enough metadata to repeat the result. Answers such as “test everything” do not define an executable verification plan.
Lesson submission rubric
- Concept: the learner explains the topic in plain language and uses the correct UVM vocabulary.
- Implementation: the example is placed in the correct component and phase with explicit configuration and connections.
- Evidence: a monitor, checker, assertion, coverage result, report, or decision record independently supports the claim.
- Debug: one controlled failure is reproduced, diagnosed, repaired, and prevented or documented.
- Quality: assumptions, limitations, and residual risk are written down for the next engineer.
prove failed transfers do not change the mirror The final artifact should be a small working example plus a short explanation of what it proves and what it does not prove.
Practice: build the smallest working example
Now apply the lesson to one small verification target. The target is to update the mirror from accepted monitor transactions, not driver intent using uvm_reg_predictor and bus_in. Keep the first version deliberately small: one interface, one transaction or state change, one expected result, and one independent observation.
Write these four lines before coding:
Requirement: the DUT must provide the documented behavior.
Stimulus: one legal operation reaches the DUT.
Observation: the monitor or checker sees what actually happened.
Evidence: expected and actual results are compared with context.
Replace the placeholders with the real requirement for this lesson. This habit makes advanced verification work readable to someone who did not write the original test.
Practice: read the code line by line
function void process_observation(topic_item actual);
string expected;
string actual_text;
expected = reference_model.predict(actual);
actual_text = actual.convert2string();
`uvm_info("TOPIC", $sformatf(
"id=%0d expected=%s actual=%s",
actual.id, expected, actual_text), UVM_LOW)
if (actual_text != expected)
`uvm_error("TOPIC", "verification result does not match")
endfunction
- The method receives an observation, so it is not coupled to the driver request.
- The reference model creates the expectation independently.
- The report records the identity and both sides of the comparison.
- The error is emitted only after the evidence has been captured.
For the real topic, replace the generic comparison with the appropriate register comparison, protocol rule, coverage sample, performance measurement, or architecture decision. Keep the same discipline: input, rule, observation, evidence.
Practice: positive, boundary, and failure cases
| Case | Question | Expected result |
|---|---|---|
| Positive | Does a valid operation work? | checker passes and evidence is recorded |
| Boundary | What happens at the smallest, largest, last, or transition value? | documented boundary behavior |
| Failure | What happens when the owner, input, timing, or configuration is wrong? | intentional error or recovery |
| Reset | What state is retained, cleared, or reinitialized? | model and DUT agree after reset |
| Repeat | Does the result remain correct across repeated or concurrent activity? | ordering and correlation remain valid |
Do not call a case “negative” merely because it fails. A negative test is successful when the environment detects the prohibited behavior and reports it at the correct severity with enough information to debug it.
Practice: debug the first mismatch
When the exercise fails, stop at the first incorrect observation. Use this order:
- Confirm the test name, seed, configuration, reset state, and phase.
- Compare the stimulus that was intended with the transaction the driver issued.
- Compare the driver transaction with the monitor observation.
- Check the reference model, predictor, checker, or coverage sampler that consumed the observation.
- Only then inspect the DUT response and decide whether the defect is in RTL or the testbench.
Practice: explain your result
Complete this short report after implementing the exercise:
| Report item | Your answer |
|---|---|
| Requirement | What exact behavior was verified? |
| Owner | Which UVM object implements the behavior? |
| Observation | Which monitor, checker, assertion, or artifact supplied actual behavior? |
| Positive evidence | What passing result was captured? |
| Boundary evidence | What edge case was exercised? |
| Failure evidence | What controlled defect was detected? |
| Residual risk | What remains unverified? |
prove failed transfers do not change the mirror The work is complete only when the code and this report agree about what the test proves.
Key takeaways
- Prediction is synchronization from observed behavior, not acknowledgement of stimulus.
- Choose explicit or auto prediction and ensure there is exactly one active owner.
- Bus response status and side effects must influence prediction.