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

uvm_pool implements a parameterized, class-based dynamic associative array and can be allocated on demand, and stored by reference. This also can return handle to a global pool which can then be used to share items between different verification components.


class uvm_pool #(type KEY = int, T = uvm_void) extends uvm_object;


Function Description
function new (string name = "") Creates a new pool with the given name
static function this_type get_global_pool () Returns the singleton global pool for the item type, T
static function T get_global (KEY key) Returns the specified item instance from global pool
virtual function T get (KEY key) Returns item with the given key if one exists, else a new item will be created and returned
virtual function void add (KEY key, T item) Adds the given key value pair to the pool if key does not exist, else it will be overwritten
virtual function int num() Returns the number of keys stored in the pool
virtual function void delete (KEY key) Removes the item with the given key from the pool
virtual function int exists (KEY key) Returns 1 if an item with the given key already exists in the pool, else returns 0
virtual function int first (ref KEY key) Returns the key of the first item in the pool via ref argument
virtual function int last (ref KEY key) Returns key of the last item in the pool via ref argument
virtual function int next (ref KEY key) Returns key of the next item in the pool via ref argument
virtual function int prev (ref KEY key) Removes key of the previous item in the pool via ref argument


class base_test extends uvm_test;
   uvm_pool #(string, int) my_pool;
   string key;
   virtual task run_phase (uvm_phase phase);
      my_pool = new ("age");
      my_pool.add("Ross", 28);
      my_pool.add("Rachel", 26);
      `uvm_info ("TEST", $sformatf ("my_pool        : %0d", my_pool.num()), UVM_MEDIUM)
      `uvm_info ("TEST", $sformatf ("my_pool [Ross] : %0d", my_pool.get("Ross")), UVM_MEDIUM)
      `uvm_info ("TEST", $sformatf ("Rachel exists  ? %0d", my_pool.exists("Rachel")), UVM_MEDIUM)
      `uvm_info ("TEST", $sformatf ("Joey exists    ? %0d", my_pool.exists("Joey")), UVM_MEDIUM)
      `uvm_info ("TEST", $sformatf ("Delete Ross, my_pool : %0d", my_pool.num()), UVM_MEDIUM)
      my_pool.add("Chandler", 28);
      my_pool.add("Phoebe", 27);
      my_pool.add("Monica", 26);
      `uvm_info ("TEST", $sformatf ("first = %s", key), UVM_MEDIUM)
      `uvm_info ("TEST", $sformatf ("last = %s", key), UVM_MEDIUM)
      key = "Monica";
      `uvm_info ("TEST", $sformatf ("next = %s", key), UVM_MEDIUM)
      `uvm_info ("TEST", $sformatf ("prev = %s", key), UVM_MEDIUM)
Simulation Log
UVM_INFO @ 0: reporter [RNTST] Running test base_test...
UVM_INFO ./tb/tb_top.sv(26) @ 0: uvm_test_top [TEST] my_pool        : 2
UVM_INFO ./tb/tb_top.sv(27) @ 0: uvm_test_top [TEST] my_pool [Ross] : 28
UVM_INFO ./tb/tb_top.sv(28) @ 0: uvm_test_top [TEST] Rachel exists  ? 1
UVM_INFO ./tb/tb_top.sv(29) @ 0: uvm_test_top [TEST] Joey exists    ? 0
UVM_INFO ./tb/tb_top.sv(32) @ 0: uvm_test_top [TEST] Delete Ross, my_pool : 1
UVM_INFO ./tb/tb_top.sv(39) @ 0: uvm_test_top [TEST] first = Chandler
UVM_INFO ./tb/tb_top.sv(41) @ 0: uvm_test_top [TEST] last = Rachel
UVM_INFO ./tb/tb_top.sv(44) @ 0: uvm_test_top [TEST] next = Phoebe
UVM_INFO ./tb/tb_top.sv(46) @ 0: uvm_test_top [TEST] prev = Monica

--- UVM Report catcher Summary ---

Was this article helpful ?

You consent to our cookies if you continue to use our website. To know more about cookies, see our privacy policy. I accept cookies from this site.