In reply to Tudor Timi:
The problem is that the static nature of the class makes the extension difficult. Consider this code built from yours:
module test;
import uvm_pkg::*;
class uvm_object_pool_that_allocates #(type KEY=int, T=uvm_object) extends uvm_pool #(KEY, T);
virtual function T get (KEY key);
if (!pool.exists(key)) begin
T new_obj = new(); // only works because uvm_objects have optional 'name' argument
pool[key] = new_obj;
end
return pool[key];
endfunction
endclass
typedef uvm_object_pool_that_allocates #(int, uvm_object) my_pool_t;
initial begin
my_pool_t pool_h;
uvm_object object;
pool_h = my_pool_t::get_global_pool(); // line 19 in error message
object = pool_h.get(2);
end
endmodule
It seems that this code should do as you suggest. It should create a new uvm_object when get() is called. However, it doesn’t work:
# ** Error: (vsim-3978) test.sv(19): Illegal assignment to class work.test/uvm_object_pool_that_allocates #(int, class mtiUvm.uvm_pkg::uvm_object) from class mtiUvm.uvm_pkg::uvm_pool #(int, class mtiUvm.uvm_pkg::uvm_object)
The problem is that I can’t get a my_pool_t pool using the get_global_pool()
method. Extending the class does not change the types of the static methods and the specialization of a base class is not considered an extension in terms of polymorphism.
So now I need to rewrite all the static methods in the uvm_pool in order to extend the class and it’s hardly worth it.
Of course, maybe I’m missing something simple. If so that would be great!