How the SPI reg2bus/bus2reg functionality taken care in "a complete working example uvm_spi_bl_reg_tb.tgz"?

Hello ,

I am trying to understand the UVM example from verification academy (i.e uvm_spi_bl_reg_tb.tgz).

I have not seen implantation of reg2bus and bus2reg functionality in example.

Could anyone tell me , How the *.update function will write HW registers?

// This will write the generated values to the HW registers
spi_rm.update(status, .path(UVM_FRONTDOOR), .parent(this));
data = spi_rm.ctrl_reg.get();

Regards
kbkdec15

In reply to Balu_15:

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.

This site has very good pictures to describe register access.
http://cluelogic.com/2013/02/uvm-tutorial-for-candy-lovers-register-access-methods/

This picture shows the update() function:

This is how update() works with step order 1 to 7:

In reply to Balu_15:

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

In reply to Balu_15:

The bus2reg and reg2bus is implemented in agents/apb/reg2apb_adapter.svh

You should be more careful and investigating the data base of this example.