|
|
|
|
|
|
|
|
|
|
|
|
wait()
|
|
|
wait() suspends the thread or clocked thread process instance from which it is called for the very next occasion on which that process instance is resumed, and for that occasion only. The dynamic sensitivity is determined by the arguments passed to function wait (Example clock). |
|
|
|
|
|
A call to the function wait with an empty argument list or with a single integer argument shall use the static sensitivity of the process instance. This is the only form of wait permitted within a clocked thread process. A call to the function wait with one or more non-integer arguments shall override the static sensitivity of the process instance. |
|
|
|
|
|
When calling function wait with a passed-by-reference parameter, the application shall be obliged to ensure that the lifetimes of any actual arguments passed-by-reference extend from the time the function is called to the time the function call completes, and moreover in the case of a parameter of type sc_time, the application shall not modify the value of the actual argument during that period. |
|
|
|
|
|
Note :It is error to call function wait from a method process. |
|
|
|
|
|
wait takes parameter, some of which are listed below |
|
|
|
|
|
- wait() : Wait for the sensitive list event to occur.
- wait(int) : Wait for n events to occur, events are the one in sensitive list.
- wait(event) : Wait for the event mentioned as parameter to occur.
- wait(double,sc_time_unit) : Wait for specified time.
- wait(double,sc_time_unit, event) : Wait for specified time or event to occur.
|
|
|
|
|
|
|
|
|
|
|
|
Example : wait()
|
|
|
|
|
|
1 #include <systemc.h>
2
3 SC_MODULE (wait_example) {
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 5 posedge of clock
15 wait(5);
16 cout << "@" << sc_time_stamp() <<" Triggering e1"<<endl;
17 // Trigger event e1
18 e1.notify(5,SC_NS);
19 // Wait for 3 NS
20 cout << "@" << sc_time_stamp() <<" Time before wait 3 ns"<<endl;
21 wait(3, SC_NS);
22 cout << "@" << sc_time_stamp() <<" Time after wait 3 ns"<<endl;
23 // Wait for event e2
24 wait(e2);
25 cout << "@" << sc_time_stamp() <<" Got Trigger e2"<<endl;
26 // Wait for posedge of clock
27 wait(30);
28 cout<<"Terminating Simulation"<<endl;
29 sc_stop(); // sc_stop triggers end of simulation
30 }
31 }
32
33 void do_test2() {
34 while (true) {
35 // Wait for event e2
36 wait(e1);
37 cout << "@" << sc_time_stamp() <<" Got Trigger e1"<<endl;
38 // Wait for 3 posedge of clock
39 wait(20);
40 cout << "@" << sc_time_stamp() <<" Triggering e2"<<endl;
41 // Trigger event e2
42 e2.notify();
43 // Wait for either 20ns or event e1
44 wait(20,SC_NS,e1);
45 cout << "@" << sc_time_stamp() <<" Done waiting for 20ns or event e1"<<endl;
46 }
47 }
48
49 SC_CTOR(wait_example) {
50 SC_CTHREAD(do_test1,clock.pos());
51 SC_CTHREAD(do_test2,clock.pos());
52 }
53 };
54
55 int sc_main (int argc, char* argv[]) {
56 sc_clock clock ("my_clock",1,0.5);
57
58 wait_example object("wait");
59 object.clock (clock.signal());
60
61 sc_start(0); // First time called will init schedular
62 sc_start(); // Run the simulation till sc_stop is encountered
63 return 0;// Terminate simulation
64 }
You could download file wait.cpp here
|
|
|
|
|
|
Simulation Output : sc_wait
|
|
|
|
|
|
@1 ns Starting test
@6 ns Triggering e1
@6 ns Time before wait 3 ns
@9 ns Time after wait 3 ns
@11 ns Got Trigger e1
@31 ns Triggering e2
@32 ns Got Trigger e2
@51 ns Done waiting for 20ns or event e1
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
|
|