quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif sc_event

sc_event is same as event in Verilog. It is used for process synchronization. A process instance may be triggered or resumed on the occurrence of an event, that is, when the event is notified.

   

space.gif

event_name.notify() is a member function notify which create an immediate notification. Any and all process instances sensitive to the event shall be made runnable before control is returned from function notify. This is same as -> event_name in Verilog. notify() function can be called with parameters as below.

   

space.gif

  • notify() :Immediate notification
  • notify(SC_ZERO_TIME) :Delta notification
  • notify(1, SC_NS) :Timed notification

event_name.cancel() is is a member function which will delete any pending notification for this event.

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : sc_event
   

space.gif


  1 #include <systemc.h>
  2 
  3 SC_MODULE (events) {
  4   sc_in<bool> clock;
  5 
  6   sc_event  e1;
  7   sc_event  e2;
  8 
  9   void do_test1() {
 10     while (true) {
 11       // Wait for posedge of clock
 12       wait();
 13       cout << "@" << sc_time_stamp() <<" Starting test"<<endl;
 14       // Wait for posedge of clock
 15       wait();
 16       cout << "@" << sc_time_stamp() <<" Triggering e1"<<endl;
 17       // Trigger event e1
 18       e1.notify(5,SC_NS);
 19       // Wait for posedge of clock
 20       wait();
 21       // Wait for event e2
 22       wait(e2);
 23       cout << "@" << sc_time_stamp() <<" Got Trigger e2"<<endl;
 24       // Wait for posedge of clock
 25       wait();
 26       cout<<"Terminating Simulation"<<endl;
 27       sc_stop(); // sc_stop triggers end of simulation
 28     }
 29   }
 30 
 31   void do_test2() {
 32     while (true) {
 33       // Wait for event e2
 34       wait(e1);
 35       cout << "@" << sc_time_stamp() <<" Got Trigger e1"<<endl;
 36       // Wait for 3 posedge of clock
 37       wait(3);
 38       cout << "@" << sc_time_stamp() <<" Triggering e2"<<endl;
 39       // Trigger event e2
 40       e2.notify();
 41     }
 42   }
 43 
 44   SC_CTOR(events) {
 45     SC_CTHREAD(do_test1,clock.pos());
 46     SC_CTHREAD(do_test2,clock.pos());
 47   }
 48 }; 
 49 
 50 int sc_main (int argc, char* argv[]) {
 51   sc_clock clock ("my_clock",1,0.5);
 52 
 53   events  object("events");
 54     object.clock (clock.signal());
 55 
 56   sc_start(0); // First time called will init schedular
 57   sc_start();  // Run the simulation till sc_stop is encountered
 58   return 0;// Terminate simulation
 59 }
You could download file sc_event.cpp here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation Output : sc_event
   

space.gif

 @1 ns Starting test
 @2 ns Triggering e1
 @7 ns Got Trigger e1
 @10 ns Triggering e2
 @11 ns Got Trigger e2
 Terminating Simulation
 SystemC: simulation stopped by user.
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com