TO Be coming

Nov 20, 2026

UVM Course :Day 16: Building a Register Model — Access Types, configure(), Reset, Volatile, Generators

Day 16: Building a Register Model — Access Types, configure(), Reset, Volatile, Generators
Advertisement
Top banner — drop your 728×90 or responsive ad unit here.

Day 16: Building a Register Model — Access Types, configure(), Reset, Volatile, Generators

A 30-day SystemVerilog/UVM verification series. Yesterday you learned the four classes. Today you learn how to fill them in correctly.

The RAL classes from Day 15 are containers. What actually matters is what goes inside them: the access policy, the reset value, the volatility, and the bit position. Get those right and the model catches bugs the scoreboard cannot. Get them wrong and the model lies — sometimes loudly, more often quietly, in a way that costs a week of debugging.

Today is about those details, and then about how to avoid typing them by hand. Real register maps have hundreds of registers. Nobody writes them out manually. You write them once in a CSV or IP-XACT file, feed it to a generator, and commit the generated SV. Today shows how that pipeline works.


1. Access Types in Detail

The access policy is the model's expectation of how the DUT responds to reads and writes. If the DUT behaves differently, the model catches it. So the policy has to be exactly right.

PolicyWrite behaviorRead behaviorCommon use
"RO"IgnoredReturns current valueStatus bits, ID registers
"RW"Stores new valueReturns stored valueConfiguration registers
"WO"Stores new valueReturns 0 or undefinedCommand registers, doorbells
"W1C"1 in a bit clears that bit; 0 leaves itReturns current valueInterrupt flags
"W1S"1 sets, 0 leavesReturns current valueBit-set registers
"RC"IgnoredReading clears to 0Counters, snapshot registers
"RSVD"IgnoredReturns 0Reserved bits

Two common near-misses that cause real bugs:

  • Declaring an interrupt-flag field RW instead of W1C. The model expects "write 1 stores 1." The DUT clears the flag. The model reports a mismatch on every read after write. Someone spends a day thinking the DUT is broken.
  • Declaring a status field RW instead of RO. The model allows the test to write garbage into the mirror. The DUT ignores it. Reads return the real value. The model thinks the write succeeded and the read is wrong — or vice versa depending on timing.
Rule: copy the access policy from the register spec, character for character. Do not paraphrase. Do not guess. If the spec is ambiguous, file a bug against the spec before you write the model.

2. configure() — Every Argument

The uvm_reg_field::configure() signature:

function void configure(
    uvm_reg        parent,                     // the register that contains this field
    int unsigned   size,                       // width in bits
    int unsigned   lsb_pos,                    // starting bit position
    string         access,                     // "RW", "RO", "W1C", etc.
    bit            volatile,                   // 1 = value can change without a write
    uvm_reg_data_t reset,                      // reset value
    bit            has_reset,                  // 1 = reset value is applied at reset
    bit            is_rand,                    // 1 = field is randomized by sequence items
    bit            individually_accessible     // 1 = field can be read/written without the full register
);

Most of these are obvious. Two deserve extra attention:

volatile

volatile=1 means "this field can change without a register write." The predictor uses this to decide whether to update the mirror on a write. A status bit that reflects the FIFO's full state is volatile — a write to the CTRL register does not change it, but the FIFO filling up does. If you mark it non-volatile, the model expects the write to update it, which produces false mismatches.

Rule of thumb: if the field can change for reasons other than a write to its own register, mark it volatile. That includes status flags, counters, and anything driven by hardware.

has_reset

has_reset=1 means the reset value is applied when the DUT resets. This is almost always what you want. has_reset=0 is for registers whose value is undefined at reset — rare, and a red flag if the spec says so.


3. Reset Values

The reset value is what the field returns after reset deasserts, before any writes. Get this wrong and every test that reads a register immediately after reset reports a mismatch.

Two failure modes:

  • Wrong reset value in the model. Spec says CTRL resets to 0x0000_0000. Model says 0x0000_0010. Reading CTRL after reset returns 0x0000_0000 and the model reports a mismatch.
  • Reset never applied to the model. The model was built with the reset value, but reset() was never called after the RTL reset fired. The model holds the reset values, but any subsequent writes are applied to a wrong baseline.

Standard pattern in a test:

phase.raise_objection(this);
fork
    // Apply DUT reset
    begin
        vif.rst_n = 0;
        repeat (5) @(posedge vif.clk);
        vif.rst_n = 1;
    end
    // Reset the model at the same time
    begin
        reg_model.reset();
    end
join
@(posedge vif.clk);
phase.drop_objection(this);
The mismatch between model reset and DUT reset is the #1 RAL bring-up bug. The DUT is reset by rst_n; the model is reset by an explicit reset() call. If the two are not aligned in time, the model's view of the registers is stale relative to the DUT, and every subsequent comparison fails.

4. Volatile Fields and Prediction

Prediction is the model's process of keeping its mirror in sync with the DUT. When the test writes a value, the model updates its mirror. When the test reads, the model checks the observed value against the mirror. If the DUT changes a volatile field without a write, the predictor learns the new value from the read response.

Two prediction modes:

  • Auto-prediction — the model updates itself on each read and write it performs. Simple, but does not see changes from non-RAL accesses (e.g., a driver writing to the bus directly, or the DUT changing a volatile field).
  • Explicit prediction — a uvm_reg_predictor observes bus traffic (typically via the monitor) and updates the model from actual observed transactions. More setup, but it catches everything the bus sees.

Day 18 covers the predictor in detail. For today, the important point is: volatile fields almost always require explicit prediction, because auto-prediction only knows what the model itself did, not what the DUT did between accesses.


5. Register Generators

Writing registers by hand is fine for five. It is a waste of time and a source of typos for five hundred. The standard is a register generator: a script that reads a spec file (CSV, IP-XACT, or a tool-specific format) and emits the SV classes.

The workflow:

registers.csv  →  ralgen or reggen or vendor-specific  →  dut_reg_block.sv
   (the spec)                                                 (generated SV)

Two things matter about the generated code:

  • Commit it, don't regenerate it per build. Regenerate only when the spec changes, then diff the generated file. That way, a spec change shows up as a reviewable diff in the SV, not a silent runtime surprise.
  • Do not edit generated code. If the model needs a change, change the spec and regenerate. Hand-editing gets lost on the next regenerate and creates two sources of truth.

Common generator inputs:

FormatTypical toolProsCons
CSVIn-house scripts, ralgenEasy to write and reviewNo schema validation
IP-XACT (XML)Vendor tools (Cadence, Synopsys)Standard, schema-validatedVerbose to write by hand
RALFVendor-specificRich, expressiveTool-locked
If you are learning: write the model by hand for your first DUT. Once you have done it once, the generator's output makes sense. Generators are wonderful once you know what the generated code is supposed to look like; they are confusing before that.

6. What Day 17 Will Add

Tomorrow: Address Mapping. You will build the uvm_reg_map that connects the register model to the bus, understand how base addresses and offsets resolve to absolute addresses, and handle DUTs with multiple maps (e.g., a fast bus and a slow bus both reaching the same registers).


7. Quiz

Ten questions on access types, configure(), reset, volatility, and generators.

Question 1 of 10
Loading…
    0 / 10
    Advertisement
    Bottom banner — drop your 728×90 or responsive ad unit here.

    Coming Up Next: Day 17 — Address Mapping

    • uvm_reg_map — base address, bus width, endianness, and how addresses resolve.
    • Multiple maps — the same block reached over two busses with different offsets.
    • Sub-blocks in a top block — how address translation works when blocks are nested.
    • Adding memories — add_mem and how memory arrays map into the same address space.
    ← Back to the 30-Day UVM Course
    See all 30 days, week by week.

    Series: 30 days of SystemVerilog/UVM verification. Day 16's register-model details.

    No comments:

    Post a Comment

    SiteMap