uvm_event_pool is a pool that stores the uvm_events.
uvm_event is used to synchronize the two processes. If the processes to trigger and wait for a trigger of an event are running in different components then it is required to share the event handle across the components. the uvm_event class makes it easy by providing uvm_event_pool.
Calling uvm_event_pool::get_global(“event_name”) method returns an event handle.
get_global Returns the specified item instance from the global item pool.
Refer to the uvm_pool for more details.
一、uvm event pool example
The below example consists of two components comp_a and comp_b. event triggering is in comp_a and wait for the event trigger in comp_b. it is required to share the same event handle across the components.
uvm_event_pool::get_global(“ev_ab”) is used to get the event handle. it will return the handle with the event name ev_ab.
Note: In both component’s event is retrieved with the key “ev_ab”.
(1)comp_a
class component_a extends uvm_component;
`uvm_component_utils(component_a)
uvm_event ev; //Step-1. Declaring the event
//---------------------------------------
// Constructor
//---------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
//---------------------------------------
// run_phase
//---------------------------------------
virtual task run_phase(uvm_phase phase);
phase.raise_objection(this);
//Step-2. Get the event handle from event pool
ev = uvm_event_pool::get_global("ev_ab");
`uvm_info(get_type_name(),$sformatf(" Before triggering the event"),UVM_LOW)
#10;
//Step-3. Triggering an event
ev.trigger();
`uvm_info(get_type_name(),$sformatf(" After triggering the event"),UVM_LOW)
phase.drop_objection(this);
endtask : run_phase
endclass : component_a
(2)comp_b
class component_b extends uvm_component;
`uvm_component_utils(component_b)
uvm_event ev; //Step-1. Declaring the event
//---------------------------------------
// Constructor
//---------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
//---------------------------------------
// run_phase
//---------------------------------------
virtual task run_phase(uvm_phase phase);
phase.raise_objection(this);
//Step-2. Get the event handle from event pool
ev = uvm_event_pool::get_global("ev_ab");
`uvm_info(get_type_name(),$sformatf(" waiting for the event trigger"),UVM_LOW)
//Step-3. waiting for event trigger
ev.wait_trigger;
`uvm_info(get_type_name(),$sformatf(" event got triggerd"),UVM_LOW)
phase.drop_objection(this);
endtask : run_phase
endclass : component_b
Simulator Output
UVM_INFO @ 0: reporter [RNTST] Running test basic_test…
————————————–
Name Type Size Value
————————————–
uvm_test_top basic_test – @1832
comp_a component_a – @1901
comp_b component_b – @1932
————————————–
UVM_INFO component_b.sv(26) @ 0: uvm_test_top.comp_b [component_b] waiting for the event trigger
UVM_INFO component_a.sv(26) @ 0: uvm_test_top.comp_a [component_a] Before triggering the event
UVM_INFO component_a.sv(31) @ 10: uvm_test_top.comp_a [component_a] After triggering the event
UVM_INFO component_b.sv(30) @ 10: uvm_test_top.comp_b [component_b] event got triggerd
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_objection.svh(1271) @ 10: reporter [TEST_DONE]
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_report_server.svh(847) @ 10: reporter [UVM/REPORT/SERVER]
(3)retrieving event with different key
The below example is similar to the above example, but the event from the global_pool is retrieved with the different key. i.e, both components will not use the same event, which leads to triggering one event and waiting for another event trigger.
In comp_a event is retrieved with key ev_ab.
ev = uvm_event_pool::get_global("ev_ab");
In comp_b event is retrieved with key ev_ba.
ev = uvm_event_pool::get_global("ev_ba");
Simulator Output
UVM_INFO @ 0: reporter [RNTST] Running test basic_test…
————————————–
Name Type Size Value
————————————–
uvm_test_top basic_test – @1832
comp_a component_a – @1901
comp_b component_b – @1932
————————————–
UVM_INFO component_b.sv(26) @ 0: uvm_test_top.comp_b [component_b] waiting for the event trigger
UVM_INFO component_a.sv(26) @ 0: uvm_test_top.comp_a [component_a] Before triggering the event
UVM_INFO component_a.sv(31) @ 10: uvm_test_top.comp_a [component_a] After triggering the event
UVM_FATAL /playground_lib/uvm-1.2/src/base/uvm_phase.svh(1491) @ 9200000000000: reporter
[PH_TIMEOUT] Default timeout of 9200000000000 hit, indicating a probable testbench issue
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_report_server.svh(847) @ 9200000000000: reporter [UVM/REPORT/SERVER]