forked from TUK-SCVP/SCVP.Exercise4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
executable file
·80 lines (71 loc) · 1.51 KB
/
main.cpp
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
#include <systemc.h>
#include "transition.h"
#include "place.h"
// TOPLEVEL
SC_MODULE(subnet)
{
public:
transition<1, 1, 1> ACT;
transition<1, 1, 0> RD, PRE, WR;
place<1, 1> ACTIVE;
SC_CTOR(subnet) : ACT("ACT"), RD("RD"), PRE("PRE"), WR("WR"),
ACTIVE(0)
{
ACT.out(ACTIVE);
ACT.inhibitors(ACTIVE);
RD.in(ACTIVE);
RD.out(ACTIVE);
PRE.in(ACTIVE);
WR.in(ACTIVE);
WR.out(ACTIVE);
}
};
SC_MODULE(toplevel)
{
public:
subnet s1, s2;
place<1, 1> IDLE;
SC_CTOR(toplevel) : s1("s1"), s2("s2"),
IDLE(2)
{
SC_THREAD(process);
s1.ACT.in(IDLE);
s1.PRE.out(IDLE);
s2.ACT.in(IDLE);
s2.PRE.out(IDLE);
}
void process()
{
while(true)
{
wait(10,SC_NS);
s1.ACT.fire();
wait(10,SC_NS);
s1.ACT.fire();
wait(10,SC_NS);
s1.RD.fire();
wait(10,SC_NS);
s1.WR.fire();
wait(10,SC_NS);
s1.PRE.fire();
wait(10,SC_NS);
s1.ACT.fire();
wait(10,SC_NS);
s2.ACT.fire();
wait(10,SC_NS);
s2.ACT.fire();
wait(10,SC_NS);
s1.PRE.fire();
wait(10,SC_NS);
s2.PRE.fire();
wait(10,SC_NS);
sc_stop();
}
}
};
int sc_main(int argc, char* argv[])
{
toplevel t("t");
sc_start();
return 0;
}