Last change
on this file since 23 was
1,
checked in by buchmann, 17 years ago
|
Initial import from CVS repository
|
File size:
3.4 KB
|
Line | |
---|
1 | #include <systemc.h> |
---|
2 | #include <signal.h> |
---|
3 | #include "chrono.h" |
---|
4 | |
---|
5 | using namespace std; |
---|
6 | |
---|
7 | struct M1_1i1o : sc_module { |
---|
8 | sc_in_clk clk; |
---|
9 | sc_in<bool> i1; |
---|
10 | sc_out<bool> o1; |
---|
11 | |
---|
12 | void eval_mealy1 () { |
---|
13 | o1 = ~i1; |
---|
14 | }; |
---|
15 | |
---|
16 | SC_CTOR (M1_1i1o) : clk("clk"), i1("i1"), o1("o1") { |
---|
17 | SC_METHOD(eval_mealy1); |
---|
18 | sensitive << clk.neg(); |
---|
19 | sensitive << i1; |
---|
20 | #ifdef SYSTEMCASS_SPECIFIC |
---|
21 | o1(i1); |
---|
22 | #endif |
---|
23 | }; |
---|
24 | }; |
---|
25 | |
---|
26 | struct M1_3i2o : sc_module { |
---|
27 | sc_in_clk clk; |
---|
28 | sc_in<bool> i1; |
---|
29 | sc_in<bool> i2; |
---|
30 | sc_in<bool> i3; |
---|
31 | sc_out<bool> o1; |
---|
32 | sc_out<bool> o2; |
---|
33 | |
---|
34 | void eval_mealy1 () { |
---|
35 | o1 = ~i1 & i2; |
---|
36 | o2 = ~i2 & i3; |
---|
37 | }; |
---|
38 | |
---|
39 | SC_CTOR (M1_3i2o) : clk("clk"), i1("i1"), o1("o1"), i2("i2"), o2("o2"), i3("i3") { |
---|
40 | SC_METHOD(eval_mealy1); |
---|
41 | sensitive << clk.neg(); |
---|
42 | sensitive << i1 << i2; |
---|
43 | sensitive << i3; |
---|
44 | #ifdef SYSTEMCASS_SPECIFIC |
---|
45 | o1(i1); |
---|
46 | o1(i2); |
---|
47 | o2(i2); |
---|
48 | o2(i3); |
---|
49 | #endif |
---|
50 | }; |
---|
51 | }; |
---|
52 | |
---|
53 | struct M2_1i1o : sc_module { |
---|
54 | sc_in_clk clk; |
---|
55 | sc_in<bool> i1; |
---|
56 | sc_out<bool> o1; |
---|
57 | |
---|
58 | sc_signal<bool> reg; |
---|
59 | |
---|
60 | void tr_moore1 () { |
---|
61 | reg = ~i1; |
---|
62 | } |
---|
63 | |
---|
64 | void gen_moore1 () { |
---|
65 | o1 = ~reg; |
---|
66 | }; |
---|
67 | |
---|
68 | SC_CTOR (M2_1i1o) : clk("clk"), i1("i1"), o1("o1") { |
---|
69 | SC_METHOD(tr_moore1); |
---|
70 | sensitive << clk.pos(); |
---|
71 | #ifdef SYSTEMCASS_SPECIFIC |
---|
72 | // no needs |
---|
73 | #endif |
---|
74 | SC_METHOD(gen_moore1); |
---|
75 | sensitive << clk.neg(); |
---|
76 | #ifdef SYSTEMCASS_SPECIFIC |
---|
77 | // no needs |
---|
78 | #endif |
---|
79 | }; |
---|
80 | }; |
---|
81 | |
---|
82 | int sc_main (int argc, char *argv[]) |
---|
83 | { |
---|
84 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
85 | sc_signal<bool> s1 ("s01"), |
---|
86 | s2 ("s02"), |
---|
87 | s3 ("s03"), |
---|
88 | s4 ("s04"), |
---|
89 | s5 ("s05"), |
---|
90 | s6 ("s06"), |
---|
91 | s7 ("s07"), |
---|
92 | s8 ("s08"), |
---|
93 | s9 ("s09"), |
---|
94 | s10("s10"), |
---|
95 | s11("s11"), |
---|
96 | s12("s12"), |
---|
97 | s13("s13"), |
---|
98 | s14("s14"), |
---|
99 | s15("s15"); |
---|
100 | |
---|
101 | |
---|
102 | M1_3i2o a ("a"); |
---|
103 | M1_1i1o b ("b"); |
---|
104 | M1_3i2o c ("c"); |
---|
105 | M1_1i1o d ("d"); |
---|
106 | M1_1i1o e ("e"); |
---|
107 | |
---|
108 | a.clk (signal_clk); |
---|
109 | b.clk (signal_clk); |
---|
110 | c.clk (signal_clk); |
---|
111 | d.clk (signal_clk); |
---|
112 | e.clk (signal_clk); |
---|
113 | |
---|
114 | a.i1 (s1); |
---|
115 | |
---|
116 | a.o1 (s2); |
---|
117 | b.i1 (s2); |
---|
118 | |
---|
119 | b.o1 (s3); |
---|
120 | c.i1 (s3); |
---|
121 | |
---|
122 | c.o1 (s4); |
---|
123 | |
---|
124 | a.i2 (s5); |
---|
125 | |
---|
126 | a.o2 (s6); |
---|
127 | c.i2 (s6); |
---|
128 | d.i1 (s6); |
---|
129 | |
---|
130 | c.o2 (s7); |
---|
131 | |
---|
132 | a.i3 (s8); |
---|
133 | |
---|
134 | d.o1 (s9); |
---|
135 | e.i1 (s9); |
---|
136 | |
---|
137 | e.o1 (s10); |
---|
138 | c.i3 (s10); |
---|
139 | |
---|
140 | // Init & run |
---|
141 | sc_initialize (); |
---|
142 | |
---|
143 | if (argc == 1) |
---|
144 | { |
---|
145 | cout << "Usage :\n" << argv[0] << " [#cycles]\n"; |
---|
146 | return EXIT_SUCCESS; |
---|
147 | } |
---|
148 | |
---|
149 | chrono_t chrono; |
---|
150 | chrono.start (); |
---|
151 | |
---|
152 | sc_start (atoi(argv[1])); |
---|
153 | |
---|
154 | chrono.stop (); |
---|
155 | unsigned int t = chrono; |
---|
156 | cout << "Time elapsed (sec) : " << t << endl; |
---|
157 | cout << "Cycles done : " << sc_simulation_time () << endl; |
---|
158 | cout << "Performance : " << sc_simulation_time () / t << endl; |
---|
159 | return EXIT_SUCCESS; |
---|
160 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.