summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/compliance_1666/test205/test205.cpp
blob: 2e0810abbbb257f4f4949d1141876411d7ae1a12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <systemc>
using namespace sc_core;
using namespace sc_dt;
using sc_core::wait;
using std::cout;
using std::endl;

// 5) wait( int ) for SC_THREAD, primitives and global

void global()
{
  wait();
  sc_assert(sc_time_stamp() == sc_time(0, SC_NS));
  wait(3);
  sc_assert(sc_time_stamp() == sc_time(3, SC_NS));
}

struct Prim: sc_prim_channel
{
  void method()
  {
    wait();
    sc_assert(sc_time_stamp() == sc_time(4, SC_NS));
    wait(3);
    sc_assert(sc_time_stamp() == sc_time(7, SC_NS));
  }
};

SC_MODULE(M)
{
  sc_in_clk clk;
  Prim prim;
  SC_CTOR(M)
  {
    SC_THREAD(T);
    sensitive << clk.pos();
  }
  void T()
  {
    global();
    prim.method();
    wait();
    sc_assert(sc_time_stamp() == sc_time(8, SC_NS));
    wait(3);
    sc_assert(sc_time_stamp() == sc_time(11, SC_NS));
    sc_stop();
  }
};

struct Top: sc_module
{
  M *m;
  sc_clock clk;
  Top(sc_module_name)
  {
    m = new M("m");
    m->clk.bind(clk);
  }
};

int sc_main(int argc, char* argv[])
{
  cout << "Should be silent..." << endl;
  Top top("top");
  sc_start();

  cout << endl << "Success" << endl;
  return 0;
}