update() function firstly calls needs_update() function to check if DUT registers need to be written. If a mirror value has been modified in the abstraction model either through randomization or via the uvm_reg::set() method, the mirror and state of the registers are outdated. The corresponding registers in the DUT need to be updated. Then update() function calls write() function to perform register write using the physical DUT interfaces (front-door access) or back-door accesses.
If you want an example of adapter’s reg2bus() and bus2reg() methods, there is one for APB bus in UVM user guide. You can take it as reference and get more info from the guide.
//------------------------------------------------------------------------------
// Group: Example
//
// The following example illustrates how to implement a RegModel-BUS adapter class
// for the APB bus protocol.
//
class reg2apb_adapter extends uvm_reg_adapter;
`uvm_object_utils(reg2apb_adapter)
function new(string name="reg2apb_adapter");
super.new(name);
endfunction
virtual function uvm_sequence_item reg2bus(uvm_reg_bus_op rw);
apb_item apb = apb_item::type_id::create("apb_item");
apb.op = (rw.kind == UVM_READ) ? apb::READ : apb::WRITE;
apb.addr = rw.addr;
apb.data = rw.data;
return apb;
endfunction
virtual function void bus2reg(uvm_sequencer_item bus_item,
uvm_reg_bus_op rw);
apb_item apb;
if (!$cast(apb,bus_item)) begin
`uvm_fatal("CONVERT_APB2REG","Bus item is not of type apb_item")
end
rw.kind = apb.op==apb::READ ? UVM_READ : UVM_WRITE;
rw.addr = apb.addr;
rw.data = apb.data;
rw.status = UVM_IS_OK;
endfunction
endclass