Register Model Adaptor¶
Title: 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.
Group: Example
The following example illustrates how to implement a RegModel-BUS adapter class for the APB bus protocol:
class rreg2apb_adapter(UVMRegAdapter):
def __init__(self, name="reg2apb_adapter"):
super().__init__(name)
def reg2bus(self, rw) -> UVMSequenceItem:
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
def bus2reg(self, bus_item, rw):
arr_apb = []
if not sv.cast(arr_apb, bus_item, apb_item)) begin
uvm_fatal("CONVERT_APB2REG","Bus item is not of type apb_item")
end
apb = arr_apb[0]
rw.kind = apb.op==apb.READ ? UVM_READ : UVM_WRITE
rw.addr = apb.addr
rw.data = apb.data
rw.status = UVM_IS_OK
uvm_object_utils(reg2apb_adapter)
-
class
uvm.reg.uvm_reg_adapter.UVMRegAdapter(name='')[source]¶ Bases:
uvm.base.uvm_object.UVMObject-
reg2bus(rw)[source]¶ Function: reg2bus
Extensions of this class
mustimplement this method to convert the specifieduvm_reg_bus_opto a correspondinguvm_sequence_itemsubtype 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 genericrwbus operation, then return it.pure virtual function uvm_sequence_item reg2bus(const ref uvm_reg_bus_op rw)
- Parameters
rw –
Raises:
-
bus2reg(bus_item, rw)[source]¶ Function: bus2reg
Extensions of this class
mustimplement this method to copy members of the given bus-specificbus_itemto corresponding members of the providedbus_rwinstance. Unlikereg2bus, the resulting transaction is not allocated from scratch. This is to accommodate applications where the bus response must be returned in the original request.- pure virtual function void bus2reg(uvm_sequence_item bus_item,
ref uvm_reg_bus_op rw)
- Parameters
bus_item –
rw –
Raises:
-