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


Tutorials



EVENT TRIGGER

Event Trigger:



This task is used to change the state of an event. Triggering an event unblocks waiting syncs, or blocks subsequent syncs. By default, all events are OFF.

ONE_SHOT ::: The ONE_SHOT trigger is the default trigger type. If you use a ONE_SHOT trigger, any process waiting for a trigger receives it.If there are no processes waiting for the trigger, the trigger is discarded.

ONE_BLAST ::: ONE_BLAST triggers work just as ONE_SHOT triggers do with the exception that they trigger any sync called within the simulation time, regardless of whether or not it was called before the trigger was executed. If a ONE_BLAST trigger is used for the situation diagrammed previously, all the processes are unblocked regardless of execution order.

HAND_SHAKE ::: HAND_SHAKE triggers unblock only one sync, even if multiple syncs are waiting for triggers. It triggers the most recent pending sync, or queues requests. If the order of triggering the unblocking of a sync is important, use a semaphore_get() and semaphore_put() around the sync to maintain order. If a sync has already been called and is waiting for a trigger, the HAND_SHAKE trigger unblocks the sync. If no sync has been called when the trigger occurs, the HAND_SHAKE trigger is stored. When a sync is called, the sync is immediately unblocked and the trigger is removed.


EXAMPLE : ONE_SHOT
#include "vera_defines.vrh"
program vshell
{
event event1;
fork
sync_then_trigger();
trigger_then_sync();
join all

}
task sync_then_trigger()
{
printf("Sync_then_trigger syncing at time %d\n", get_time(LO) );
sync(ALL,event1);
printf("Sync_then_trigger synced at time %d\n",get_time(LO) );
#50;
printf("Sync_then_trigger triggering at time %d\n",get_time(LO) );
trigger (ONE_SHOT, event1);
}
task trigger_then_sync()
{
#20;
printf("trigger_then_sync triggering at time %d\n",get_time(LO) );
trigger(ONE_SHOT, event1);
#10;
printf("trigger_then_sync syncing at time %d\n",get_time(LO) );
sync(ALL,event1);
printf("trigger_then_sync synced at time %d\n",get_time(LO) );
}

RESULTS

Sync_then_trigger syncing at time 0
trigger_then_sync triggering at time 20
Sync_then_trigger synced at time 20
trigger_then_sync syncing at time 30
Sync_then_trigger triggering at time 70
trigger_then_sync synced at time 70


EXAMPLE :ONE_BLAST
#include "vera_defines.vrh"
program vshell
{
event event1, event2, event3;
fork
call_task1();
call_task2();
join none
#150;
printf(" END of program");
}

task call_task1 ()
{
printf("In task call_task1 Sync all events at time %d\n",get_time(LO) );
#30;
sync(ALL,event2,event3);
printf("In task call_task1 Synced at time %d\n", get_time(LO) );
}

task call_task2()
{
printf("In task call_task2 triggering events at time %d\n",get_time(LO) );
#40;
trigger(ONE_BLAST, event2);
#20;
printf("In task call_task2 event2 was triggered and task call_task2 is finished at time %d \n", get_time(LO) );
}

RESULTS

In task call_task1 Sync all events at time 0
In task call_task2 triggering events at time 0
In task call_task2 event2 was triggered and task call_task2 is finished at time 60


EXAMPLE :HAND_SHAKE
#include "vera_defines.vrh"
program vshell {
event my_event = ON;
fork
sync_event1();
sync_event2();
trigger_event1();
join all

}

task sync_event1() {
printf("before sync_event1 at time %0d \n");
sync(ALL,my_event);
printf("after sync_event1 at time %0d \n");
printf("before trigger sync_event1 at time %0d \n");
trigger(ONE_BLAST,my_event);
}

task sync_event2() {
printf("before sync_event2 at time %0d \n");
sync(ALL,my_event);
printf("after sync_event2 at time %0d \n");
printf("before trigger sync_event2 at time %0d \n");
trigger(ONE_BLAST,my_event);
}

task trigger_event1() {
printf("before trigger_event1 at time %0d \n");
trigger(HAND_SHAKE,my_event);
printf("after trigger_event1 at time %0d \n");
sync(ALL,my_event);
printf("after sync trigger_event1 3 at time %0d \n");
}
RESULTS

before sync_event1 at time
before sync_event2 at time
before trigger_event1 at time
after trigger_event1 at time
after sync_event1 at time
before trigger sync_event1 at time
after sync_event2 at time
before trigger sync_event2 at time
after sync trigger_event1 3 at time



Event Variables :



These variables serve as the link between triggers and syncs. They are a unique data type with several important properties.


EXAMPLE : Event Variables
#include "vera_defines.vrh"

task T1 (event trigger_a){
printf("\nT1 syncing at cycle=%0d",get_time(LO) );
sync(ALL, trigger_a); // Blocked: proceed after receiving trigger
printf("\nT1 event trigger_a received at cycle=%0d",get_time(LO) );
delay(70);
printf("\nT1 triggering trigger_a at cycle=%0d",get_time(LO) );
trigger (trigger_a);
}
program trigger_play
{
event trigger1;
fork
T1(trigger1);// start T1 and go on
join none
delay(80); // T1 is blocked waiting for
fork
{
printf("\nPROGRAM triggering trigger1 @cycle=%0d",get_time(LO) );
printf("\nPROGRAM This unblocks T1");
trigger(trigger1); // unblock the waiting T1
}
{ delay(50);
printf("\nPROGRAM syncing @cycle=%0d\n\n",get_time(LO) );
sync (ALL, trigger1) ;// wait for T1 to unblock me
}
join
wait_child();
printf("Trigger play done!");
}

RESULTS

T1 syncing at cycle=0
PROGRAM triggering trigger1 @cycle=80
PROGRAM This unblocks T1
T1 event trigger_a received at cycle=80
PROGRAM syncing @cycle=130



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