uvm_event array
Table of Contents
This section shows declaring the uvm_event with,
- Fixed size array of uvm_event
- A dynamic array of uvm_event
- An associative array of uvm_event
Fixed size array of uvm_event
In the below example uvm_event is declared as a fixed size array with size 2.
There are four threads, two of which trigger the events and the other two will wait for the trigger.
module uvm_events_ex; uvm_event ev[2]; //declaring uvm_event ev_1 initial begin foreach(ev[i]) ev[i] = new(); //Creating the event fork //------------------ ev[0] -------------------------- //process-1, triggers the event begin #40; $display($time," [ev-0] Triggering the Event"); ev[0].trigger; end //process-2, wait for the event to trigger begin $display($time," [ev-0] Waiting for the Event to trigger"); ev[0].wait_trigger; $display($time," [ev-0] Event triggered"); end //---------------------------------------------------- //------------------ ev[1] -------------------------- //process-1, triggers the event begin #50; $display($time," [ev-1] Triggering the Event"); ev[1].trigger; end //process-2, wait for the event to trigger begin $display($time," [ev-1] Waiting for the Event to trigger"); ev[1].wait_trigger; $display($time," [ev-1] Event triggered"); end //---------------------------------------------------- join end endmodule
Simulator Output
0 [ev-0] Waiting for the Event to trigger 0 [ev-1] Waiting for the Event to trigger 40 [ev-0] Triggering the Event 40 [ev-0] Event triggered 50 [ev-1] Triggering the Event 50 [ev-1] Event triggered
A dynamic array of uvm_event
In the below example uvm_event is declared as a dynamic array and created the size 2.
There are four threads, two of which trigger the events and the other two will wait for the trigger.
module uvm_events_ex; uvm_event ev[]; initial begin ev = new[2]; foreach(ev[i]) ev[i] = new(); //Creating the event fork //------------------ ev[0] -------------------------- //process-1, triggers the event begin #40; $display($time," [ev-0] Triggering the Event"); ev[0].trigger; end //process-2, wait for the event to trigger begin $display($time," [ev-0] Waiting for the Event to trigger"); ev[0].wait_trigger; $display($time," [ev-0] Event triggered"); end //---------------------------------------------------- //------------------ ev[1] -------------------------- //process-1, triggers the event begin #50; $display($time," [ev-1] Triggering the Event"); ev[1].trigger; end //process-2, wait for the event to trigger begin $display($time," [ev-1] Waiting for the Event to trigger"); ev[1].wait_trigger; $display($time," [ev-1] Event triggered"); end //---------------------------------------------------- join end endmodule
Simulator Output
0 [ev-0] Waiting for the Event to trigger 0 [ev-1] Waiting for the Event to trigger 40 [ev-0] Triggering the Event 40 [ev-0] Event triggered 50 [ev-1] Triggering the Event 50 [ev-1] Event triggered
An associative array of uvm_event
In the below example uvm_event is declared as an associative array with the type string.
There are four threads, two of which trigger the events and the other two will wait for the trigger.
module uvm_events_ex; uvm_event ev[string]; initial begin ev["ev_1"] = new(); //Creating the event ev["ev_2"] = new(); fork //------------------ ev[ev_1] -------------------------- //process-1, triggers the event begin #40; $display($time," [ev_1] Triggering the Event"); ev["ev_1"].trigger; end //process-2, wait for the event to trigger begin $display($time," [ev_1] Waiting for the Event to trigger"); ev["ev_1"].wait_trigger; $display($time," [ev_1] Event triggered"); end //---------------------------------------------------- //------------------ ev[ev_2] -------------------------- //process-1, triggers the event begin #50; $display($time," [ev-2] Triggering the Event"); ev["ev_2"].trigger; end //process-2, wait for the event to trigger begin $display($time," [ev-2] Waiting for the Event to trigger"); ev["ev_2"].wait_trigger; $display($time," [ev-2] Event triggered"); end //---------------------------------------------------- join end endmodule
Simulator Output
0 [ev_1] Waiting for the Event to trigger 0 [ev-2] Waiting for the Event to trigger 40 [ev_1] Triggering the Event 40 [ev_1] Event triggered 50 [ev-2] Triggering the Event 50 [ev-2] Event triggered