Repair and Continue: Register Bugs That Don't Stop the Run
When a register write doesn't land, fix it through the backdoor, flag it, and keep simulating. A UVM report catcher keeps the run alive past the quit limit, and still fails it at the end with every repair listed. With a runnable Verilator example.
After UVM RAL Fundamentals went out, Kevin Cameron described, in a comment, a methodology he had proposed for agile IC design. Do the register writes for block control through the front door. If a write doesn’t turn up, a backdoor mechanism applies it and flags a bug, so the simulation carries on correctly instead of stalling. Then burn down the outstanding issues.
The article was an overview of how RAL accesses work, not a methodology, but the idea deserves a proper treatment. It also raises a question the comment doesn’t answer: if every broken write gets repaired, what makes the test fail? This post works through that, for tests driven by the register model and for firmware, with a small example that runs on Verilator.
Why a bad write costs more than one bug
A block-level register test that finds a write which didn’t land has done its job. It reports the mismatch, the run ends, someone fixes the RTL. One bug, one failure, one fix.
Most register writes in a real regression aren’t in register tests. They’re setup: a test about DMA ordering, or interrupt coalescing, or a boot flow, starts by writing twenty configuration registers and then gets on with what it’s actually about. When one of those twenty doesn’t land, the test never reaches the thing it was written to check. Either the mismatch stops the run, or nothing checks the write and the block sits in the wrong mode until something times out.
Early in a project that happens to many tests at once. One RTL bug in a common configuration register can stall every test that touches the block, and the bugs behind it, in the logic those tests were meant to exercise, stay hidden until the first one is fixed. With a fix-and-rerun cycle of a day, three stacked bugs take three days to surface even when each fix is trivial.
Repair-and-continue breaks that chain. The broken write gets fixed in the simulation, the test goes on to check what it was written to check, and the run reports both the register bug and whatever else it finds.
Two requirements that pull against each other
The run has to keep going after a mismatch, and it has to end as a failure.
UVM’s quit limit works against the first. A regression usually sets +UVM_MAX_QUIT_COUNT low, often to 1, so a broken test stops at its first error instead of burning CPU on a run that’s already failed. Every repaired write is an error, so the first repair ends the run, which is exactly what repair-and-continue is trying to avoid.
Turning the mismatch into a warning works against the second. Warnings don’t fail a run, and a repaired test that passes is the worst outcome: the bug is real, the regression is green, and nothing on the dashboard says otherwise.
The answer is to do both, at different times:
- During the run, each mismatch is reported as a warning, so it doesn’t count toward the quit limit.
- At the end, the test raises one error that lists every repair, so the run fails and the failure says exactly what was patched.
The report catcher
uvm_report_catcher sees every report before the report server acts on it, and can change its severity, ID, message or action. That’s the hook for the first half:
1class repair_catcher extends uvm_report_catcher;
2 string repairs[$];
3
4 virtual function action_e catch();
5 if (get_severity() != UVM_ERROR) return THROW;
6 if (get_id() == "CSR_MISMATCH" ||
7 (get_id() == "RegModel" && contains(get_message(), "does not match mirrored value"))) begin
8 repairs.push_back(get_message());
9 set_severity(UVM_WARNING);
10 set_message({"repaired, continuing: ", get_message()});
11 end
12 return THROW;
13 endfunction
14endclassLowering the severity is enough. When a catcher changes a report’s severity and leaves its action alone, UVM gives it the default action for the new severity, and the default for a warning is to display it without counting it.
Two details matter here.
The match is narrow. uvm_reg reports a failed mirror check under the ID RegModel, but it uses the same ID for real model problems, such as an unmapped address or a missing backdoor. A catcher that demoted every RegModel error would hide those as well, so this one also requires the mismatch message. That string comes from the UVM library’s source, not from the standard, so check it against the version your project uses.
The catcher only exists when repair is on. The test registers it behind a plusarg, so the same test runs strict by default:
1if ($test$plusargs("REPAIR")) begin
2 catcher = new("repair_catcher");
3 uvm_report_cb::add(null, catcher);
4endThe second half goes in report_phase, which runs after the test has finished:
1virtual function void report_phase(uvm_phase phase);
2 string s;
3 if (catcher == null || catcher.repairs.size() == 0) return;
4 s = $sformatf("%0d register write(s) did not land and were repaired through the backdoor:",
5 catcher.repairs.size());
6 foreach (catcher.repairs[i]) s = {s, $sformatf("\n %0d. %s", i + 1, catcher.repairs[i])};
7 `uvm_error("CSR_REPAIR_SUMMARY", s)
8endfunctionOne error, so the run fails. Raising it as the last thing the run does means the quit limit has nothing left to cut short.
Through the register model
The example’s block has four registers and three injected bugs: CTRL never stores the upper mode bit, THRESH ignores writes while the block is enabled, and DATA drops bit 0. The test enables the block, sets a threshold, waits for a ready bit, and writes a data byte, which is a plausible bring-up sequence and enough to hit all three.
Every configuration write goes through one helper:
1task write_checked(uvm_reg r, uvm_reg_data_t value);
2 uvm_status_e status;
3 r.write(status, value);
4 r.mirror(status, UVM_CHECK);
5 if (repair && r.get_mirrored_value() != value) r.poke(status, value);
6endtaskmirror() with UVM_CHECK reads the register back through the front door and compares it with the mirror, which auto-prediction set from the write. A mismatch raises the RegModel error and updates the mirror to what the hardware returned, so a mirror that no longer equals the written value means the write didn’t land. poke() then writes the intended value through the backdoor.
The logs below are trimmed to the relevant lines, with the file and line prefixes dropped and 64-bit register values shortened. Strict, with +UVM_MAX_QUIT_COUNT=1:
1UVM_ERROR @ 50: reporter [RegModel] Register "blk.CTRL" value read from DUT (0x03)
2 does not match mirrored value (0x07)
3Quit count reached!One bug found, two still hidden. With +REPAIR:
1UVM_WARNING @ 50: [RegModel] repaired, continuing: Register "blk.CTRL" value read from DUT (0x03) ...
2UVM_WARNING @ 90: [RegModel] repaired, continuing: Register "blk.THRESH" value read from DUT (0x00) ...
3UVM_INFO @ 110: [CSR] STATUS.ready is set
4UVM_WARNING @ 150: [RegModel] repaired, continuing: Register "blk.DATA" value read from DUT (0xa4) ...
5UVM_INFO @ 150: [CSR] setup sequence complete
6UVM_ERROR @ 150: [CSR_REPAIR_SUMMARY] 3 register write(s) did not land and were repaired through the backdoor:
7 1. Register "blk.CTRL" ...
8 2. Register "blk.THRESH" ...
9 3. Register "blk.DATA" ...
10
11Number of demoted UVM_ERROR reports : 3
12UVM_ERROR : 1All three bugs in one run, and the run still fails. The catcher summary that UVM prints itself, “Number of demoted UVM_ERROR reports: 3”, is a useful cross-check: it should always equal the length of the repair list.
The whole exchange, step by step, strict and then with repair:
All 13 steps
- Strict. The test calls
write_checked(CTRL, 'h07): enable, mode 3. It starts with an ordinary frontdoorwrite(), and auto-prediction sets the mirror to ‘h07 as the write completes. UVM RAL Fundamentals - The write reaches the block, and the decode logic drops the upper mode bit. The flops hold ‘h03: enabled, but in mode 1.
mirror(status, UVM_CHECK)reads CTRL back through the front door. The value returned, ‘h03, doesn’t match the mirror’s ‘h07, souvm_regraises aUVM_ERRORunder the IDRegModel.- The error reaches the report server as an error and counts. One of one: the run ends at 50 ns. THRESH and DATA are never written, so their two bugs stay hidden until CTRL is fixed and the test is run again.
- With +REPAIR. Same test, same bug, with
+REPAIR. The test has registeredrepair_catcher, which sees every report before the server does. The mismatch error goes to the catcher first. - The catcher matches the ID and the mismatch message, keeps the message in its list, and lowers the severity to warning. With the action left alone, UVM gives the report a warning’s default action: display it, don’t count it.
- The failed check also updated the mirror to what the hardware returned, so the mirror reads ‘h03, not the ‘h07 the test asked for. The test sees that and calls
poke()with the value it wanted. - The backdoor writes the flops directly, with no bus transfer. CTRL now holds what the test wrote, and the test goes on as if the write had landed.
- THRESH is written next, ‘h05, and the block ignores it because it’s already enabled. The same check fails at 90 ns, the catcher demotes it, and the backdoor puts ‘h05 in place.
- With CTRL and THRESH as intended, STATUS.ready rises and the test’s poll sees it at 110 ns. The strict run never got this far.
- DATA is written ‘hA5 and lands as ‘hA4, with bit 0 dropped. That’s the third bug, caught and repaired the same way at 150 ns, and the test finishes.
- End of test.
report_phaseruns after the test is done. It takes the catcher’s list, three entries, and builds one message from it. - No.
report_phaseraises oneUVM_ERROR,CSR_REPAIR_SUMMARY, listing all three registers. It’s the last report of the run, so there’s nothing left for the quit limit to cut short. Three bugs from one run, each one a ticket to burn down. The Waiver Problem and a Scalable Waiver Manager
Through firmware
Firmware is where repair-and-continue pays the most, and where it’s hardest to build.
Boot code doesn’t go through a register model. It writes addresses, and the only things it reads back are status bits it has to wait on. When a configuration write doesn’t land, nothing in the firmware notices. The block just never becomes ready, and the firmware polls until something times out. Running the same three bugs with firmware-style bus traffic and no checking:
1UVM_FATAL @ 1050: [FW_HANG] firmware stuck polling STATUS.ready after 50 readsThat’s the expensive failure: a hang, a long way from the cause, which names no register. Two of the three bugs (mode and threshold) could each produce it, and whoever debugs it starts from the poll loop and works backward through a waveform.
In the example, “firmware” is a sequence that puts raw bus transactions on the register bus: fixed addresses and data, in boot order, with no register model involved. In a real project the same writes come from compiled code on a processor model, or from C tests calling a bus driver through DPI. The checker below doesn’t care which, because all it watches is the block’s register bus.
Since firmware traffic never goes through uvm_reg, there’s no mirror check to catch. The detection has to come from the bus. A monitor publishes each write once the DUT has clocked it in, and a checker reads the register back through the backdoor and compares it with the read-write bits of what was written:
1fifo.get(it);
2r = blk.default_map.get_reg_by_offset(it.addr, 0);
3if (r == null) continue;
4mask = rw_mask(r);
5if (mask == 0) continue;
6expected = it.data & mask;
7r.peek(status, actual);
8if ((actual & mask) == expected) continue;
9`uvm_error("CSR_MISMATCH", $sformatf("%s: wrote 0x%02h, register holds 0x%02h",
10 r.get_name(), expected, actual & mask))
11if (repair) r.poke(status, (actual & ~mask) | expected);The register model is still useful here, just not on the access path: it’s the address map, the field layout and the backdoor. The mask matters. Read-only, write-1-to-clear and reserved bits don’t hold what was written by design, so only fields with RW access take part in the comparison, and the repair leaves the other bits as the hardware has them.
With the checker, the hang becomes a named register at the time of the write:
1UVM_ERROR @ 30: [CSR_MISMATCH] CTRL: wrote 0x07, register holds 0x03
2Quit count reached!With the checker and +REPAIR, the firmware boots:
1UVM_WARNING @ 30: [CSR_MISMATCH] repaired, continuing: CTRL: wrote 0x07, register holds 0x03
2UVM_WARNING @ 50: [CSR_MISMATCH] repaired, continuing: THRESH: wrote 0x05, register holds 0x00
3UVM_INFO @ 90: [FW] STATUS.ready is set
4UVM_WARNING @ 110: [CSR_MISMATCH] repaired, continuing: DATA: wrote 0xa5, register holds 0xa4
5UVM_INFO @ 110: [FW] boot sequence complete
6UVM_ERROR @ 130: [CSR_REPAIR_SUMMARY] 3 register write(s) did not land and were repaired through the backdoor:
7 1. CTRL: wrote 0x07, register holds 0x03
8 2. THRESH: wrote 0x05, register holds 0x00
9 3. DATA: wrote 0xa5, register holds 0xa4This checker uses its own ID, CSR_MISMATCH, so it doesn’t strictly need a catcher. A test could instead raise it as a warning when repair is on and count the reports by ID at the end. Routing both paths through the same catcher keeps one switch and one summary.
The firmware version, from the hang to a completed boot:
All 13 steps
- No checker. Firmware writes ‘h07 to CTRL at address ‘h00: enable, mode 3. It’s a raw bus transaction. No register model is involved, so nothing predicts or checks the value.
- The decode logic drops the upper mode bit, and CTRL holds ‘h03. The firmware doesn’t read it back. Boot code rarely does.
- THRESH gets ‘h05. The block is already enabled, so it ignores the write. That’s a second bug, and nothing notices this one either.
- Zero, every time. Ready needs mode 3 and a non-zero threshold, and neither write landed. After 50 polls the firmware’s watchdog fires
FW_HANGat 1,050 ns. - None. Either bug alone would cause this hang, and the report is a poll loop timing out, a thousand nanoseconds after the cause. Debug starts at the poll and works backward through a waveform.
- A checker on the bus. Same boot, with a monitor and a checker added. The monitor watches the bus pins and sees the CTRL write go by.
- It publishes the write on the next falling edge, once the DUT has clocked it in, so whatever the register holds now is what the write left behind.
- The checker finds CTRL in the register model’s address map and peeks it through the backdoor: ‘h03. Only RW fields count in the comparison, because read-only and write-1-to-clear bits never hold what was written.
- ‘h03 isn’t ‘h07, so the checker raises
CSR_MISMATCH: “CTRL: wrote 0x07, register holds 0x03”. With no catcher registered it counts, and the run ends at 30 ns. The hang is gone, and the report names the register at the write that failed. - Checker and +REPAIR. With
+REPAIR, the sameCSR_MISMATCHgoes to the catcher, which demotes it to a warning and keeps it in the list. The quit count stays at zero. - The checker pokes the RW bits that were written into CTRL through the backdoor. The firmware’s next transaction sees a CTRL that holds ‘h07, as the write intended.
- No. The checker catches THRESH at 50 ns and repairs it the same way. Ready rises, and the firmware’s poll sees it at 90 ns.
- DATA is written ‘hA5 and lands as ‘hA4. That’s the third bug, repaired at 110 ns, and the boot sequence completes. Then
report_phaselists all three in oneCSR_REPAIR_SUMMARYerror, and the run fails. The Waiver Problem and a Scalable Waiver Manager
Where it lies to you
A repaired run checks a design that doesn’t exist yet: the RTL as it will be once the bug is fixed. That’s the point of the method, and also where it can mislead.
The repair hides what the bug would have caused. The THRESH bug only bites when firmware enables the block before setting the threshold. Repairing it means everything after that point runs as though the ordering didn’t matter. If the real fix turns out to be “firmware must set THRESH first”, the repaired run checked a sequence the product will never run. A repair says “assume this register is correct”, and it holds only if the fix makes it true.
A second bug in the same register stays hidden. Once the backdoor has put the right value in place, a later write to that register that also doesn’t land is caught only if the write is checked again. The checker above checks every write, but a test that repairs once and then trusts the register won’t catch the second failure.
A wrong backdoor path fails quietly. If the HDL path is stale after a rename, the poke goes nowhere, or into the wrong flop, and the run continues on a design that is neither the RTL nor the intended one. Peeking after each poke and treating a mismatch there as a fatal error closes that hole cheaply.
Timing bugs look like value bugs. A register that takes effect a few cycles late, through a clock crossing or a shadow register that updates on a later event, fails an immediate read-back and gets “repaired” into a register that takes effect at once. The repair hides the real bug, which is the delay. Registers with deliberate update latency need their check to wait for it, and a repair there is suspect by default.
Repair must be off for sign-off. A passing run is never a repaired run, because the summary error guarantees that. But a regression where every test fails with a long repair list can still look “nearly done” on a dashboard. Sign-off regressions run strict, with the catcher never registered.
Burning down the list
Kevin’s last step, burn-down, is what makes the method more than a debug trick. The summary from each run lists the registers that needed repair; collected across a regression, that’s a ranked list of register bugs by how many tests they break.
A few things make that list manageable:
- Every entry gets a bug ID. A repair with no bug behind it is a waiver with no owner. The same discipline as a waiver manager applies: each one has a reason and a ticket, and is reviewed when the ticket closes.
- The count only goes down. Track repairs per regression, and treat a rise as a new bug, even if every test was already red.
- Repair is per register, not global. Once a bug is fixed, the repair for that register is switched off, so a regression of the fix shows up as a strict failure instead of a quiet repair. A per-register allow-list, keyed by bug ID, does this better than one plusarg.
Running it
The example is in adibis/repair-and-continue. It needs Verilator 5 with --timing, and uses the non-DPI UVM 2020.3.2 build that Verilator’s own regression suite runs:
1make demo # all six scenarios
2make run TEST=fw_test REPAIR=1Two things in it are specific to that UVM build. It has no DPI, so uvm_hdl_deposit isn’t available, and the backdoor uses hierarchical references into the DUT instead of add_hdl_path(). It also can’t read +UVM_* plusargs, so the base test applies +UVM_MAX_QUIT_COUNT itself. On a commercial simulator with the standard library, neither workaround is needed.
Thanks to Kevin Cameron for the idea and the nudge to write it up.