Back-door read/write vs. peek/poke
Back-door access to registers and memory by using the read/write methods with the path argument set to UVM_BACKDOOR
.
- uvm_reg_field::read() or uvm_reg_field::write()
- uvm_reg::read() or uvm_reg::write()
- uvm_mem::read() or uvm_mem::write()
There are also Peek/Poke methods that can be used instead
- uvm_reg_field::peek() or uvm_reg_field::poke()
- uvm_reg::peek() or uvm_reg::poke()
- uvm_mem::peek() or uvm_mem::poke()
The peek()
and poke()
methods provide direct access to registers or memory using back-door access, but they behave differently compared to regular read()
and write()
methods:
peek()
Method:
Thepeek()
method retrieves the raw value from a register or memory without altering its content. For example, if a register has a field that clears itself when read (like a clear-on-read field), usingpeek()
will not trigger this behavior. This means the value obtained throughpeek()
may differ from what you would get using the regularread()
method.poke()
Method:
Thepoke()
method directly writes a value into a register or memory, overriding any field access restrictions. For instance, non-writable fields (like read-only or write1-to-clear fields) will still be forced to take the poked value, even if they wouldn’t normally accept it. This can lead to different results compared to writing through the regular front-door method.read()
with Back-Door Access:
When using theread()
method with back-door access, it behaves just like a front-door read. For example, if a register has a clear-on-read field, reading it will clear the field by automatically writing zeros to it (using a poke operation internally).write()
with Back-Door Access:
Similarly, thewrite()
method with back-door access mimics a front-door write. For example, if you try to write to a read-only field, the method will preserve the field’s current value by first retrieving it usingpeek()
and then reapplying it using apoke()
operation, instead of overwriting it with the specified value.