|
|
|
|
|
|
|
|
|
|
|
|
next_trigger()
|
|
|
next_trigger() is used with process methods, one's which are not threads. The function next_trigger does not suspend the method process instance; a method process cannot be suspended, but always executes to completion before returning control to the kernel. This is different from wait() method used with threads. |
|
|
|
|
|
- next_trigger() : In the absence of static sensitivity for this particular process instance, the process shall not be triggered again during the current simulation.
- next_trigger(event) : The process shall be triggered when the event passed as an argument is notified.
- next_trigger(double,sc_time_unit) : The process shall be triggered when specified time has elapsed.
- next_trigger(double,sc_time_unit, event) : The process shall be triggered when the given event is notified or after given time, which ever occurs first.
|
|
|
|
|
|
|
|
|
|
|
|
Example : next_trigger()
|
|
|
|
|
|
1 #include <systemc.h>
2
3 SC_MODULE (next_trigger_example) {
4 sc_in<bool> clock;
5
6 sc_event e1,e2;
7 int cnt;
8
9 void do_test1() {
10 switch (cnt) {
11 case 0 : cout << "@" << sc_time_stamp() <<" Default trigger clk triggered"<<endl;
12 next_trigger(e1);
13 break;
14 case 1 : cout << "@" << sc_time_stamp() <<" Event e1 triggered"<<endl;
15 next_trigger(10, SC_NS);
16 break;
17 case 2 : cout << "@" << sc_time_stamp() <<" Event e1 occured or time 10ns passed"<<endl;
18 next_trigger(e1 | e2);
19 break;
20 case 3 : cout << "@" << sc_time_stamp() <<" Event e1 or e2 triggered"<<endl;
21 break;
22 default :cout << "@" << sc_time_stamp() <<" Default trigger clk triggered"<<endl;
23 break;
24 }
25 cnt ++;
26 }
27
28 void do_test2() {
29 while (true) {
30 wait(2);
31 // Trigger event e1
32 cout << "@" << sc_time_stamp() <<" Triggering e1"<<endl;
33 e1.notify();
34 wait(20);
35 cout << "@" << sc_time_stamp() <<" Triggering e2"<<endl;
36 e2.notify();
37 // Wait for 2 posedge of clocks
38 wait(2);
39 cout << "@" << sc_time_stamp() <<" Terminating simulation"<<endl;
40 sc_stop(); // sc_stop triggers end of simulation
41 }
42 }
43
44 SC_CTOR(next_trigger_example) {
45 cnt = 0;
46 SC_METHOD(do_test1);
47 sensitive << clock;
48 SC_CTHREAD(do_test2,clock.pos());
49 }
50 };
51
52 int sc_main (int argc, char* argv[]) {
53 sc_clock clock ("my_clock",1,0.5);
54
55 next_trigger_example object("wait");
56 object.clock (clock.signal());
57
58 sc_start(0); // First time called will init schedular
59 sc_start(); // Run the simulation till sc_stop is encountered
60 return 0;// Terminate simulation
61 }
You could download file next_trigger.cpp here
|
|
|
|
|
|
Simulation Output : next_trigger
|
|
|
|
|
|
@0 s Default trigger clk triggered
@2 ns Triggering e1
@2 ns Event e1 triggered
@12 ns Event e1 occured or time 10ns passed
@22 ns Triggering e2
@22 ns Event e1 or e2 triggered
@22500 ps Default trigger clk triggered
@23 ns Default trigger clk triggered
@23500 ps Default trigger clk triggered
@24 ns Default trigger clk triggered
@24 ns Terminating simulation
SystemC: simulation stopped by user.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|