uvm_queue

class uvm.base.uvm_queue.UVMQueue(name='')[source]

Bases: UVMObject, Generic[T]

Implements a class-based dynamic queue.

type_name = 'uvm_queue'
m_global_queue: UVMQueue = None
classmethod get_global_queue() UVMQueue[source]

Function: get_global_queue

Returns the singleton global queue.

This allows items to be shared amongst components throughout the verification environment.

Returns

The global singleton queue

Return type

UVMQueue

classmethod get_global(index) Any[source]

Function: get_global

Returns the specified item instance from the global item queue. :param cls: :param index:

Returns:

get(index: int) T[source]

Function: get

Returns the item at the given Index.

If no item exists by that key, a new item is created with that key and returned. :param index:

Returns:

size() int[source]

Function: size

Returns the number of items stored in the queue. Returns:

insert(index: int, item: T) None[source]

Function: insert

Inserts the item at the given Index in the queue. :param index: :param item:

delete(index=-1) None[source]

Function: delete

Removes the item at the given Index from the queue; if Index is not provided, the entire contents of the queue are deleted. :param index:

pop_front() T[source]

Function: pop_front

Returns the first element in the queue (index=0), or null if the queue is empty. Returns: Raises:

front() Optional[T][source]
back() Optional[T][source]
pop_back() Optional[T][source]

Function: pop_back

Returns the last element in the queue (index=size()-1), or null if the queue is empty. Returns:

push_front(item: T) None[source]

Function: push_front

Inserts the given item at the front of the queue. :param item:

push_back(item: T) None[source]

Function: push_back

Inserts the given item at the back of the queue. :param item:

create(name='') UVMQueue[T][source]

Group: Creation

The create method allocates a new object of the same type as this object and returns it via a base uvm_object handle. Every class deriving from uvm_object, directly or indirectly, must implement the create method.

A typical implementation is as follows:

class mytype (UVMObject):
  ...
  def create(self, name=""):
    mytype t = mytype(name)
    return t
Parameters

name (str) – Name of the created object.

Returns

New object.

Return type

obj

get_type_name() str[source]

This function returns the type name of the object, which is typically the type identifier enclosed in quotes. It is used for various debugging functions in the library, and it is used by the factory for creating objects.

This function must be defined in every derived class.

A typical implementation is as follows:

class mytype (UVMObject):
  ...
  type_name = "mytype"

  def get_type_name(self):
    return my_type.type_name

We define the type_name static variable to enable access to the type name without need of an object of the class, i.e., to enable access via the scope operator, ~mytype::type_name~.

Returns

Type name of the object.

Return type

str

do_copy(rhs) None[source]

The do_copy method is the user-definable hook called by the copy method. A derived class should override this method to include its fields in a copy operation.

A typical implementation is as follows:

class mytype (UVMObject):
  ...
  field_1 = 0
  def do_copy(self, rhs):
    super.do_copy(rhs)
    # Optionanl type checking
    field_1 = rhs.field_1

The implementation must call super().do_copy, and can optionally do type checking before copying.

Parameters

rhs (UVMObject) – Object to be copied.

convert2string() str[source]

This virtual function is a user-definable hook, called directly by the user, that allows users to provide object information in the form of a string. Unlike sprint, there is no requirement to use a uvm_printer policy object. As such, the format and content of the output is fully customizable, which may be suitable for applications not requiring the consistent formatting offered by the print/sprint/do_print API.

Fields declared in <Utility Macros> macros (`uvm_field_*), if used, will not automatically appear in calls to convert2string.

An example implementation of convert2string follows.

 class Base(UVMObject):
   field = "foo"
   def convert2string(self):
     return "base_field=" + self.field

 class Obj2(UVMObject):
   field = "bar"
   def convert2string()
     convert2string = "child_field=" + self.field

 class Obj(Base):
   addr = 0x123
   data = 0x456
   write = 1
   child = Obj2()
   def convert2string(self):
      convert2string = super().convert2string() +
        sv.sformatf(" write=%0d addr=%8h data=%8h ",write,addr,data) +
        child.convert2string()

Then, to display an object, you could write:

.. code-block:: python

  o = Obj()
  uvm_report_info("BusMaster", "Sending:

” + o.convert2string())

The output will look similar to:

UVM_INFO @ 0: reporter [BusMaster] Sending:
  base_field=foo write=1 addr=00000123 data=00000456 child_field=bar
Returns:

str: Object converted into string.

find_with(find_func) UVMQueue[T][source]

Group: find functions Added by tpoikela to mimic SystemVerilog find API :param find_func:

Returns:

find_first_index(find_func) int[source]