test106.cpp revision 12855:588919e0e4aa
1#include <systemc>
2
3using sc_core::sc_delta_count;
4using sc_core::sc_is_running;
5using sc_core::SC_ZERO_TIME;
6using sc_core::sc_start;
7using sc_core::sc_event;
8using sc_core::SC_NS;
9using std::cout;
10using std::endl;
11
12// D.1 6) sc_delta_count()
13
14SC_MODULE(M)
15{
16  SC_CTOR(M)
17  {
18    SC_THREAD(T);
19  }
20  void T()
21  {
22    cout << "T() " << sc_is_running() << "  " << sc_delta_count() << endl;
23    wait(10, SC_NS);
24    cout << "T() " << sc_is_running() << "  " << sc_delta_count() << endl;
25    wait(10, SC_NS);
26    cout << "T() " << sc_is_running() << "  " << sc_delta_count() << endl;
27    wait(10, SC_NS);
28    cout << "T() " << sc_is_running() << "  " << sc_delta_count() << endl;
29  }
30};
31
32SC_MODULE(Top)
33{
34  M *m;
35  SC_CTOR(Top)
36  {
37    m = new M("m");
38  }
39};
40
41int sc_main(int argc, char* argv[])
42{
43  sc_assert(sc_delta_count() == 0);
44
45  Top top("top");
46  sc_start();
47
48  cout << endl << "Success" << endl;
49  return 0;
50}
51