Register Fields and Access Policies
A practical, step-by-step lesson for building reliable and reusable UVM verification environments.
Learning objectives
- Encode field width, position, reset, and access policy in a register class.
- Distinguish RW, RO, WO, W1C, and volatile behavior during checking.
- Design negative tests that prove illegal writes are handled intentionally.
Step 1: Understand the concept
A register field is more than a slice of bits. Its access policy defines how writes affect the DUT and how reads affect the model. Read-only, write-only, write-one-to-clear, write-one-to-set, and volatile fields need different expected-value rules.
Do not use UVM_DEFAULT as a substitute for understanding the specification. For every field, record reset, access, volatility, and whether a read or write has side effects. A checker that assumes every read is non-destructive will report false failures or miss real ones.
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 status_reg extends uvm_reg;
uvm_reg_field ready;
uvm_reg_field error;
function void build();
ready = uvm_reg_field::type_id::create("ready");
ready.configure(this, 1, 0, "RO", 1, 1'b0, 1, 0, 0);
error = uvm_reg_field::type_id::create("error");
error.configure(this, 1, 1, "W1C", 0, 1'b0, 1, 0, 0);
endfunction
endclass
The field declaration captures the contract, but the DUT and predictor must implement the same semantics. For a W1C field, a write of one clears the bit; a write of zero leaves it unchanged. Test both paths explicitly.
Step 3: Build it in small pieces
- Create a field table with bit range, reset, access, side effects, and volatility.
- Implement one normal field and one W1C field, then lock the register.
- Write legal and illegal access tests, checking both bus activity and resulting readback.
- Investigate any mismatch by asking whether the error is in the field policy, DUT behavior, or predictor semantics.
Try it yourself
Acceptance criteria: your field table matches the model; writing one to W1C clears the DUT bit; writing zero does not clear it; RO writes are covered as a negative test; and every failure identifies the register, field, operation, expected value, and actual value.
Architecture review for Register Fields and Access Policies
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 Register Fields and Access Policies
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: Register Fields and Access Policies
Evaluate register fields and access policies 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 register fields and access policies: 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: Register Fields and Access Policies
In this lesson, focus on how to model RO, RW, WO, W1C, volatile, and reserved bits explicitly. 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: Register Fields and Access Policies
// Primary API or artifact: uvm_reg_field.configure()
// Expected evidence: one observable result tied to the requirement
What to notice: uvm_reg_field.configure() 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: Register Fields and Access Policies
- Write the requirement, preconditions, expected result, and failure policy.
- Implement the smallest example that uses
uvm_reg_field.configure(). - 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.
- write legal and illegal values and compare DUT readback.
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
Register Fields and Access Policies means that you must model RO, RW, WO, W1C, volatile, and reserved bits explicitly. 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: Register Fields and Access Policies
// Primary API: uvm_reg_field.configure()
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 Register Fields and Access Policies 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
write legal and illegal values and compare DUT readback 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 register fields and access policies.
- 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 Register Fields and Access Policies. 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_field.configure() 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 Register Fields and Access Policies.
- 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.
write legal and illegal values and compare DUT readback 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 model RO, RW, WO, W1C, volatile, and reserved bits explicitly using uvm_reg_field.configure(). 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? |
write legal and illegal values and compare DUT readback The work is complete only when the code and this report agree about what the test proves.
Key takeaways
- Field access policies are executable specification, not decoration.
- Side effects and volatile values require deliberate predictor and checker rules.
- Negative access tests are essential evidence for RO, WO, and W1C fields.