Skip to content

Enable a device through update() without clearing a pending interrupt in the same register

write-from-scratch / w1c / access-policyUVM · runs take about 2 minutes

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.

Source on GitHub

update_can_silently_clear_a_w1c_field.sv