uvm中资源池uvm_pool是一个很基础的类,由此派生出uvm_object_string_pool等常见的类。uvm_pool在UVM的代码里其实也占用着重要的作用。当需要hash表的时候可以使用uvm_pool实现。
uvm_pool本质上就是一个受保护的关联数组。这个定义位于uvm源码的uvm_pool.svh中。
class uvm_pool #(type KEY=int, T=uvm_void) extends uvm_object;
const static string type_name = "uvm_pool";
typedef uvm_pool #(KEY,T) this_type;
static protected this_type m_global_pool;
protected T pool[KEY];
uvm_pool有十几个函数,这里不一一赘述,有兴趣的可以看一下uvm的源码。这里给出一个简单的应用案例:
initial begin
uvm_pool #(string, int) ev;
ev = new("ev");
ev.add("one", 12);
if(ev.exists("one")) begin
$display("[debug] ev[%s] = %d", "one", ev.get("one"));
end
end
运行如上代码,可以显示: