blob: e336d541baf2e3c0958479cbef669dc53ac47b17 (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#include <systemc>
using namespace sc_core;
using namespace sc_dt;
using std::cout;
using std::endl;
// 11) sc_is_running()
struct my_port: sc_port<sc_signal_in_if<int> >
{
my_port()
{
sc_assert(sc_is_running() == false);
}
~my_port()
{
sc_assert(sc_is_running() == false);
}
void before_end_of_elaboration()
{
sc_assert(sc_is_running() == false);
}
void end_of_elaboration()
{
sc_assert(sc_is_running() == false);
}
void start_of_simulation()
{
sc_assert(sc_is_running() == false);
}
void end_of_simulation()
{
sc_assert(sc_is_running() == false);
}
int read()
{
sc_assert(sc_is_running() == true);
return (*this)->read();
}
};
SC_MODULE(M)
{
my_port p;
SC_CTOR(M)
{
sc_assert(sc_is_running() == false);
SC_THREAD(T);
SC_METHOD(ME);
}
~M()
{
sc_assert(sc_is_running() == false);
}
void T()
{
int i = p.read();
sc_assert(sc_is_running() == true);
wait (1, SC_NS);
sc_assert(sc_is_running() == true);
wait (1, SC_NS);
sc_assert(sc_is_running() == true);
wait (1, SC_NS);
}
void ME()
{
sc_assert(sc_is_running() == true);
}
void before_end_of_elaboration()
{
sc_assert(sc_is_running() == false);
}
void end_of_elaboration()
{
sc_assert(sc_is_running() == false);
}
void start_of_simulation()
{
sc_assert(sc_is_running() == false);
}
void end_of_simulation()
{
sc_assert(sc_is_running() == false);
}
};
struct Top: sc_module
{
M *m;
sc_signal<int> sig;
Top(sc_module_name)
{
sc_assert(sc_is_running() == false);
m = new M("m");
m->p.bind(sig);
}
};
int sc_main(int argc, char* argv[])
{
cout << "Should be silent..." << endl;
sc_assert(sc_is_running() == false);
Top top("top");
sc_assert(sc_is_running() == false);
sc_start();
cout << endl << "Success" << endl;
return 0;
}
|