PDA

View Full Version : ovm_barrier



ankit1
02-03-2008, 11:28 PM
Hi All,

can anybody explain me ovm_barrier with an exampl

dlong
02-04-2008, 01:59 AM
Hi,

ovm_barrier can be used to force a set of independently executing processes (e.g. virtual sequences) to wait until they have all reached a particular point. The barrier provides a flexible synchronisation mechanism between the processes: its threshold can be programmed to set the number of processes that must reach the synchronisation point before the barrier is 'lifted'.

OVM provides a global barrier pool which makes it easier to access a named barrier across multiple processes.

I have included the main points in the example code below:



package my_pkg;
import ovm_pkg::*;

//Global barrier to synchronise sequence ends with environment run method
//initialised by environment class constructor
ovm_barrier_pool global_barrier;
ovm_barrier all_seq_done;

class my_virtual_sequence extends ovm_sequence;
...
virtual task body();
...
//wait until all sequences complete
all_seq_done.wait_for();
endtask // body

endclass: my_virtual_sequence

class my_virtual_sequence2 extends ovm_sequence;
...
virtual task body();
...
//wait until all sequences complete
all_seq_done.wait_for();
endtask // body

endclass: my_virtual_sequence2

class simple_env extends ovm_env;
...

virtual function void build();
super.build();
global_barrier = ovm_barrier_pool::get_global_pool();
all_seq_done= global_barrier.get("all_seq_done");
...
//set barrier threshold to expected number of master sequences
all_seq_done.set_threshold(nmasters);
endfunction: build

endclass: simple_env

endpackage: my_pkg



Hope that helps.
Regards,
Dave