Classes for Adapting Between Register and Bus Operations

This section defines classes used to convert transaction streams between generic register address/data reads and writes and physical bus accesses.

Contents
Classes for Adapting Between Register and Bus OperationsThis section defines classes used to convert transaction streams between generic register address/data reads and writes and physical bus accesses.
uvm_reg_adapterThis class defines an interface for converting between uvm_reg_bus_op and a specific bus transaction.
uvm_reg_tlm_adapterFor converting between uvm_reg_bus_op and uvm_tlm_gp items.

uvm_reg_adapter

This class defines an interface for converting between uvm_reg_bus_op and a specific bus transaction.

Summary
uvm_reg_adapter
This class defines an interface for converting between uvm_reg_bus_op and a specific bus transaction.
Class Hierarchy
uvm_reg_adapter
Class Declaration
virtual class uvm_reg_adapter extends uvm_object
newCreate a new instance of this type, giving it the optional name.
supports_byte_enableSet this bit in extensions of this class if the bus protocol supports byte enables.
provides_responsesSet this bit in extensions of this class if the bus driver provides separate response items.
parent_sequenceSet this member in extensions of this class if the bus driver requires bus items be executed via a particular sequence base type.
reg2busExtensions of this class must implement this method to convert the specified uvm_reg_bus_op to a corresponding uvm_sequence_item subtype that defines the bus transaction.
bus2regExtensions of this class must implement this method to copy members of the given bus-specific bus_item to corresponding members of the provided bus_rw instance.
get_itemReturns the bus-independent read/write information that corresponds to the generic bus transaction currently translated to a bus-specific transaction.
ExampleThe following example illustrates how to implement a RegModel-BUS adapter class for the APB bus protocol.

new

function new( string  name  =  "" )

Create a new instance of this type, giving it the optional name.

supports_byte_enable

bit supports_byte_enable

Set this bit in extensions of this class if the bus protocol supports byte enables.

provides_responses

bit provides_responses

Set this bit in extensions of this class if the bus driver provides separate response items.

parent_sequence

uvm_sequence_base parent_sequence

Set this member in extensions of this class if the bus driver requires bus items be executed via a particular sequence base type.  The sequence assigned to this member must implement do_clone().

reg2bus

pure virtual function uvm_sequence_item reg2bus( const ref  uvm_reg_bus_op  rw )

Extensions of this class must implement this method to convert the specified uvm_reg_bus_op to a corresponding uvm_sequence_item subtype that defines the bus transaction.

The method must allocate a new bus-specific uvm_sequence_item, assign its members from the corresponding members from the given generic rw bus operation, then return it.

bus2reg

pure virtual function void bus2reg( uvm_sequence_item  bus_item,
ref  uvm_reg_bus_op  rw )

Extensions of this class must implement this method to copy members of the given bus-specific bus_item to corresponding members of the provided bus_rw instance.  Unlike reg2bus, the resulting transaction is not allocated from scratch.  This is to accommodate applications where the bus response must be returned in the original request.

get_item

virtual function uvm_reg_item get_item()

Returns the bus-independent read/write information that corresponds to the generic bus transaction currently translated to a bus-specific transaction.  This function returns a value reference only when called in the uvm_reg_adapter::reg2bus() method.  It returns null at all other times.  The content of the return uvm_reg_item instance must not be modified and used strictly to obtain additional information about the operation.

Example

The following example illustrates how to implement a RegModel-BUS adapter class for the APB bus protocol.

class rreg2apb_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

uvm_reg_tlm_adapter

For converting between uvm_reg_bus_op and uvm_tlm_gp items.

Summary
uvm_reg_tlm_adapter
For converting between uvm_reg_bus_op and uvm_tlm_gp items.
Class Hierarchy
uvm_reg_tlm_adapter
Class Declaration
class uvm_reg_tlm_adapter extends uvm_reg_adapter
Methods
reg2busConverts a uvm_reg_bus_op struct to a uvm_tlm_gp item.
bus2regConverts a uvm_tlm_gp item to a uvm_reg_bus_op.

reg2bus

virtual function uvm_sequence_item reg2bus( const ref  uvm_reg_bus_op  rw )

Converts a uvm_reg_bus_op struct to a uvm_tlm_gp item.

bus2reg

virtual function void bus2reg( uvm_sequence_item  bus_item,
ref  uvm_reg_bus_op  rw )

Converts a uvm_tlm_gp item to a uvm_reg_bus_op. into the provided rw transaction.

virtual class uvm_reg_adapter extends uvm_object
This class defines an interface for converting between uvm_reg_bus_op and a specific bus transaction.
Struct that defines a generic bus transaction for register and memory accesses, having kind (read or write), address, data, and byte enable information.
class uvm_reg_tlm_adapter extends uvm_reg_adapter
For converting between uvm_reg_bus_op and uvm_tlm_gp items.
typedef uvm_tlm_generic_payload uvm_tlm_gp
This typedef provides a short, more convenient name for the uvm_tlm_generic_payload type.
The uvm_void class is the base class for all UVM classes.
virtual class uvm_object extends uvm_void
The uvm_object class is the base class for all UVM data and hierarchical classes.
function new( string  name  =  "" )
Create a new instance of this type, giving it the optional name.
bit supports_byte_enable
Set this bit in extensions of this class if the bus protocol supports byte enables.
bit provides_responses
Set this bit in extensions of this class if the bus driver provides separate response items.
uvm_sequence_base parent_sequence
Set this member in extensions of this class if the bus driver requires bus items be executed via a particular sequence base type.
pure virtual function uvm_sequence_item reg2bus( const ref  uvm_reg_bus_op  rw )
Extensions of this class must implement this method to convert the specified uvm_reg_bus_op to a corresponding uvm_sequence_item subtype that defines the bus transaction.
class uvm_sequence_item extends uvm_transaction
The base class for user-defined sequence items and also the base class for the uvm_sequence class.
pure virtual function void bus2reg( uvm_sequence_item  bus_item,
ref  uvm_reg_bus_op  rw )
Extensions of this class must implement this method to copy members of the given bus-specific bus_item to corresponding members of the provided bus_rw instance.
virtual function uvm_reg_item get_item()
Returns the bus-independent read/write information that corresponds to the generic bus transaction currently translated to a bus-specific transaction.
class uvm_reg_item extends uvm_sequence_item
Defines an abstract register transaction item.
virtual function uvm_sequence_item reg2bus( const ref  uvm_reg_bus_op  rw )
Converts a uvm_reg_bus_op struct to a uvm_tlm_gp item.
virtual function void bus2reg( uvm_sequence_item  bus_item,
ref  uvm_reg_bus_op  rw )
Converts a uvm_tlm_gp item to a uvm_reg_bus_op.