This exercise has a walk: A status bit the mirror never heard about. It plays step by step beside the code.
ctrl_reg has two fields: enable (RW) and irq_pending (W1C: writing 1 clears the pending flag in hardware). uvm_reg::update() writes the whole register, computing a value for every field. For a W1C field it inverts desired, so desired=0 becomes a write of 1. If irq_pending was never read, its desired is still the reset default 0, and update() clears a real pending interrupt nobody asked it to touch.
RequirementWrite enabler::enable_device(uvm_reg r, uvm_reg_field enable, uvm_reg_map map) so it sets enable without disturbing what irq_pending holds in hardware. It takes one extra call, first: what has to happen before desired can mean “leave this alone”?
Right nowenable=0, want 1. The stub does nothing.
Done whenA frontdoor read-back after enable_device (in the test) shows enable=1 and irq_pending=1. enable.set(1) then r.update(...) with no read first gives enable=1 but irq_pending=0.
One working answer: brokenbench's own fix for this exercise. Try a few runs first.
What changes, against the code you started with:
csr.mirror(status, UVM_CHECK). Before reading anything, mirror() notes the mirrored value, ‘h005, as what it expects to find.
UVM RAL Fundamentalsreg2bus() to an APB item, this time with write = 0.bus2reg() pulls ‘h105 out of the item, and mirror() gets its value back.csr.write(status, 'h105). In set(), a W1C field treats the 1 as a clear, so desired becomes ‘h005: what the register should read after the write, not the bits sent.
Register Access Types Aren't Symmetricdocker run --pull always --rm -p 127.0.0.1:8787:8787 ghcr.io/adibis/brokenbench-runnerLooking for a runner on this computer…
The first start downloads about 250 MB; after that it starts in seconds and only downloads again when there's an update. Your code goes to the runner on your computer, not to chipdv.io.