I’ve recently used uvm_event and I got it to work as I wanted by setting it in the uvm_config_db as follows :
class file1 extends uvm_sequence;
uvm_event event_name;
function new(string name="file1");
super.new(name);
event_name = new("event_name");
uvm_config_db#(uvm_event)::set(null, "*", "pass_event", event_name);
endfunction: new
task some_task;
//data manipulation
event_name.trigger();
endtask : some_task
endclass : file1
class file2 extends uvm_component;
uvm_event event_name;
virtual task run_phase(uvm_phase phase);
uvm_config_dv#(uvm_event)::get(this, "*", "pass_event", event_name);
forever begin
event_name.wait_trigger();
// do something
end
endtask : run_phase
endclass : file2
This is working in my case. But I want to use get_event_pool instead. Can someone explain how does my code change if I use get_event_pool?
I was also wondering if it is a good practice to set uvm_event in config_db like shown above. If not, why do we have get_event_pool for? Are there any possible advantages or disadvantages in either case?
The uvm_event_pool manages a pool of events that can be accessed using a string name. Finally it is an associative array of uvm_events indexed by name (string). It allows accesses from multiple components.
See the code below:
The name of the event is ‘driver1_ev’. The get command gets this event or creates one if it does not exist.
The get command in driver2 deals also with this event and waits for it. If it gets the event it is working with the data belonging to these event.
I am wondering whether there is a way to detect whether the event already exists?
Because might face give the wrong evetn_string and cause two different event created, hence can never wait the event to happen.
Is there a way to see the created uvm_event in uvm_event_pool?
`include "uvm_macros.svh"
module top;
import uvm_pkg::*;
uvm_event ev;
initial begin
ev = uvm_event_pool::get_global("ev_ab");
#10 ev.trigger();
$display("%t: event ev triggered", $time);
end
initial begin
string ev_name = "EVENT_X";
// get a reference to the global singleton object by
// calling a static method
static uvm_event_pool ev_pool = uvm_event_pool::get_global_pool();
// either create a uvm_event or return a reference to it
if(ev_pool.exists(ev_name)) begin
`uvm_info("TB", $sformatf("event named = %s EXISTS", ev_name), UVM_NONE)
end
else begin
`uvm_info("TB", $sformatf("event named = %s DOES NOT EXISTS",ev_name ), UVM_NONE)
end
ev_name = "ev_ab";
if(ev_pool.exists(ev_name)) begin
`uvm_info("TB", $sformatf("event named = %s EXISTS", ev_name), UVM_NONE)
end
else begin
`uvm_info("TB", $sformatf("event named = %s DOES NOT EXISTS",ev_name ), UVM_NONE)
end
// wait for the trigger
ev.wait_trigger();
$display("%t: event ev trigger received", $time);
end
endmodule
# KERNEL: UVM_INFO /home/runner/testbench.sv(25) @ 0: reporter [TB] event named = EVENT_X DOES NOT EXISTS
# KERNEL: UVM_INFO /home/runner/testbench.sv(31) @ 0: reporter [TB] event named = ev_ab EXISTS
Please note in this code there could be a race condition between the two threads
HTH,
-R
In reply to rgarcia07:
Thanks.
This can work if two uvm_event are in the same event_pool.
But what if there are multiple pools.
Is there a way to get all existing pools?
There is no method available which reports all event names used. In any way you have to search for specofoc names.