Welcome ! This website will help YOU (recent graduates/professionals) learn verification languages like SystemVerilog and UVM. Register for free and access more content !
2 minutes reading time (327 words)

about the UVM queue class ?

about the UVM queue class ?

Yes. UVM has a class-based dynamic queue that can be allocated on demand, passed and stored by reference. Eventhough uvm_queue is a parameterized class extended from uvm_object, it is not registered with the factory and hence invocation of new() function is the correct way to create a queue object.

Also, UVM provides a global singleton queue instance by the name m_global_queue which can be retrieved via get_global_queue() method. This allows items to be shared amongst components throughout the verification environment.

class uvm_queue #(type T = int) extends uvm_object;
  typedef uvm_queue #(T) this_type;
  static local this_type m_global_queue;
  protected T queue[$];
  static function this_type get_global_queue();

In the following example, we'll see how to use a queue in real UVM code.

  class my_data extends uvm_sequence_item;
    // my custom data object
  class my_test extends uvm_test;
    uvm_queue #(my_data)     my_q;
    virtual task main_phase (uvm_phase phase);
      // Create a new object and assign to handle my_q
      my_q = new ("my_q");
      my_data tmp = my_data::type_id::create ("tmp");
      my_q.push_back (tmp);

Here are a few examples on how to use some of the popular methods of the uvm_queue class.

  my_data obj = my_q.get (i);      // where i can be an integer 0 to my_q.size()
  qsize = my_q.size ();           // Get number of elements in the queue
  obj = get_global (5);           // Get the item at index 5 from the global queue
  my_q = get_global_queue();      // Get handle to the global queue
  my_q.insert (4, obj);           // Insert obj at index 4
  my_q.delete ();                 // Delete all elements in the queue
  my_q.delete (2);                // Delete element at index 2
  obj = my_q.pop_front ()         // Pop the item at the front of the queue
  obj = my_q.pop_back ()          // Pop the item at the back of the queue
  my_q.push_back (obj);           // Push the object to the back of the queue
  my_q.push_front (obj);          // Push the object to the front of the queue
What is SystemVerilog ?
When an X on clock almost went unnoticed


No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Monday, 18 June 2018

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. You consent to our cookies if you continue to use our website. To find out more about the cookies we use and how to delete them, see our privacy policy.

  I accept cookies from this site.
EU Cookie Directive plugin by www.channeldigital.co.uk