|HOME |ABOUT |ARTICLES |ACK |FEEDBACK |TOC |LINKS |BLOG |JOBS |


Tutorials



EVENT SYNC


Event Methods:



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");
}

task call(){
fork
{
delay(10);
printf("time : %0d , triggering event1 \n",get_time(LO)) ;
trigger(event1);
delay(10);
printf("time : %0d , triggering event1 \n",get_time(LO) );
trigger(event2);
}
join none
}


RESULTS

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");
}

task call(){
fork{
delay(10);
printf("time : %0d , triggering event1 \n",get_time(LO) );
trigger(event1);
delay(10);
printf("time : %0d , triggering event1 \n",get_time(LO) );
trigger(event2);
}
join none
}


RESULTS

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");
}

task call(){
fork{
delay(10);
printf("time : %0d , triggering event1 \n",get_time(LO) );
trigger(event2);
delay(10);
printf("time : %0d , triggering event1 \n",get_time(LO) );
trigger(event1);
delay(10);
printf("time : %0d , triggering event1 \n",get_time(LO) );
trigger(event2);
}
join none
}

RESULTS

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");
}

task call(){
fork{
trigger(ON,event1);
delay(10);
printf("time : %0d , triggering event1 \n",get_time(LO) );
trigger(event1);
delay(10);
printf("time : %0d , triggering event1 \n",get_time(LO) );
trigger(event2);
}
join

RESULTS

time : 0 After sync check_bit is 1
time : 10 , triggering event1
time : 20 , triggering event1
END OF SIMUALTION

Index
Introduction
Data Types
Linked List
Operators Part 1
Operators Part 2
Operators Part 3
Operator Precedence
Control Statements
Procedures And Methods
Interprocess
Fork Join
Shadow Variables
Fork Join Control
Wait Var
Event Sync
Event Trigger
Semaphore
Regions
Mailbox
Timeouts
Oop
Casting
Randomization
Randomization Methods
Constraint Block
Constraint Expression
Variable Ordaring
Aop
Predefined Methods
String Methods
Queue Methods
Dut Communication
Functional Coverage

Report a Bug or Comment on This section - Your input is what keeps Testbench.in improving with time!





<< PREVIOUS PAGE

TOP

NEXT PAGE >>

copyright 2007-2017 :: all rights reserved www.testbench.in::Disclaimer