uvm_event相较于event来讲,进行了一些类的封装,丰富了一些用法;
先看下uvm_event_pool是个什么概念:
typedef uvm_object_string_pool #(uvm_event(#uvm_object)) uvm_event_pool;
可以看出,uvm_event_pool实际上是一个object <-> string 映射的一个关联数组,通过字符串和uvm_event相互关联;
这里要特别注意的一点,uvm_pool基类中声明的这个m_global_pool是一个static的变量,也就是在整个环境中不管例化多少个uvm_event_pool, 所有的event都是大家可见的;而不是其他帖子所说的这个uvm_event_pool是全局变量,然后大家才互相可见;
同理,既然uvm_event_pool的指针都是同一个,那么自然,该class中的pool也是大家共用;
class uvm_pool #(type KEY=int, T=uvm_void) extends uvm_object;
xxx;
sypedef uvm_pool #(KEY,T) this_type;
static protected this_type m_global_pool;
这里引出uvm_event的第一步使用方式:实例化一个uvm_event_pool;
1. 在环境中实例化uvm_event_pool,方式如下:
uvm_event_pool event_pools = uvm_event_pool::get_global_pool();
//能够用静态调用,是因为get_global_pool()是一个static function;
该函数实现如下功能:
static function this_type get_global_pool();
if(m_global_pool = null) begin
m_global_pool = new("pool")
end
return m_global_pool;
endfunction
即,如果已经实例化,直接返回,否则,创建后返回;
2. 创建和使用event;
uvm_event event_a = event_pool.get("event_name");
其中,get函数实现如下功能:
virtual function T get(KEY key);
if(!pool.exists(key)) begin
T default_value;
pool[key] = default_value;
end
return pool[key];
endfunction
附上uvm_event的使用方式: (101条消息) uvm_event的使用总结_zyj0oo0的博客-CSDN博客_uvm_eventhttps://blog.csdn.net/zyj0oo0/article/details/120264318
附上sv中event的使用方式: