Events are variables that synchronize concurrent processes. When a sync is called, a process blocks until another process sends a trigger to unblock it. Events act as the go-between for triggers and syncs.
sync() ::This method synchronizes statement execution to one or more triggers.
ALL :::The ALL sync type suspends the process until all of the specified events are triggered.
For example:
sync(ALL, event_a, event_b, event_c);
ANY :::The ANY sync type suspends the process until any of the specified events is triggered.
For example:
sync(ANY, event_a, event_b, event_c);
ORDER :::The ORDER sync type suspends the process until any of the specified events is triggered.
For example:
sync(ORDER, event_a, event_b, event_c);
CHECK :::The CHECK sync type is called as a function. It does not suspend the thread. It returns a 1 if the trigger is ON and a 0 if it is not.This sync type can only be used with ON and OFF trigger types.This sync type can only be used with a single event per call.
For example:
sync(CHECK,event_a);
EXAMPLE : sync ANY
#include "vera_defines.vrh"
program main {
event event1,event2;
call();
sync(ANY,event1,event2);
printf(" time : %0d After sync \n",get_time(LO) );
delay(40);
printf(" END OF SIMUALTION \n");
}
time : 10 , triggering event1 time : 10 After sync time : 20 , triggering event1 END OF SIMUALTION
EXAMPLE : sync ALL
#include "vera_defines.vrh"
program main {
event event1,event2;
call();
sync(ALL,event1,event2);
printf(" time : %0d After sync \n",get_time(LO) );
delay(40);
printf(" END OF SIMUALTION \n");
}
time : 10 , triggering event1 time : 20 , triggering event1 time : 20 After sync END OF SIMUALTION
EXAMPLE : sync ORDER
#include "vera_defines.vrh"
program main {
event event1,event2;
call();
sync(ORDER,event2,event1);
printf(" time : %0d After sync \n",get_time(LO) );
delay(40);
printf(" END OF SIMUALTION \n");
}
time : 10 , triggering event1 time : 20 , triggering event1 time : 20 After sync time : 30 , triggering event1 END OF SIMUALTION
EXAMPLE : sync CHECK
#include "vera_defines.vrh"
program main {
event event1,event2;
bit check_bit;
call();
check_bit = sync(CHECK,event1);
printf(" time : %0d After sync check_bit is %d \n",get_time(LO),check_bit);
delay(40);
printf(" END OF SIMUALTION \n");
}