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) -> None:
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:
UVMObject
Class: UVMRegAdapter
This class defines an interface for converting between <uvm_reg_bus_op> and a specific bus transaction.
- Variables
supports_byte_enable (bool) –
Set this bit in extensions of this class if the bus protocol supports byte enables. Default is False.
- Variables
provides_responses (bool) –
Set this bit in extensions of this class if the bus driver provides separate response items. Default is False.
- Variables
parent_sequence (UVMSequenceBase) –
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
UVMObject.do_clone()
.- reg2bus(rw)[source]¶
Function: reg2bus
Extensions of this class
must
implement this method to convert the specifieduvm_reg_bus_op
to a correspondinguvm_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 genericrw
bus operation, then return it.- Parameters
rw –
Raises:
- bus2reg(bus_item, rw)[source]¶
Function: bus2reg
Extensions of this class
must
implement this method to copy members of the given bus-specificbus_item
to corresponding members of the providedbus_rw
instance. 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: