summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/compliance_1666/test202/test202.cpp
blob: 8d8fec5ddaae14b7961daa6bf4a8777898816e47 (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
#include <systemc>
#include <cstring>
using namespace sc_core;
using namespace sc_dt;
using std::cout;
using std::endl;

// 2) sc_clock - start_time and posedge_first (in addition to period and duty_cycle)

SC_MODULE(M)
{
  SC_CTOR(M)
  {
    SC_THREAD(T);
  }
  void T()
  {
    wait(10, SC_NS);
    sc_stop();
  }
};

struct Top: sc_module
{
  sc_clock clk;
  M *m;
  Top(sc_module_name)
    : clk("clk", 20, SC_NS, 0.75, 5, SC_NS, false)
  {
    m = new M("m");
    sc_assert(strcmp(clk.name(), "top.clk") == 0);
    sc_assert(strcmp(clk.kind(), "sc_clock") == 0);
    sc_assert(clk.period() == sc_time(20, SC_NS));
    sc_assert(clk.duty_cycle() == 0.75);
    sc_assert(clk.start_time() == sc_time(5, SC_NS));
    sc_assert(clk.posedge_first() == false);
  }
};

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

  Top top("top");
  sc_start();

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