Last change
on this file since 64 was
1,
checked in by buchmann, 17 years ago
|
Initial import from CVS repository
|
File size:
2.8 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 M2_1i1o : sc_module { |
---|
27 | sc_in_clk clk; |
---|
28 | sc_in<bool> i1; |
---|
29 | sc_out<bool> o1; |
---|
30 | |
---|
31 | sc_signal<bool> reg; |
---|
32 | |
---|
33 | void tr_moore1 () { |
---|
34 | reg = ~i1; |
---|
35 | } |
---|
36 | |
---|
37 | void gen_moore1 () { |
---|
38 | o1 = ~reg; |
---|
39 | }; |
---|
40 | |
---|
41 | SC_CTOR (M2_1i1o) : clk("clk"), i1("i1"), o1("o1") { |
---|
42 | SC_METHOD(tr_moore1); |
---|
43 | sensitive << clk.pos(); |
---|
44 | #ifdef SYSTEMCASS_SPECIFIC |
---|
45 | // no needs |
---|
46 | #endif |
---|
47 | SC_METHOD(gen_moore1); |
---|
48 | sensitive << clk.neg(); |
---|
49 | #ifdef SYSTEMCASS_SPECIFIC |
---|
50 | // no needs |
---|
51 | #endif |
---|
52 | }; |
---|
53 | }; |
---|
54 | |
---|
55 | int sc_main (int argc, char *argv[]) |
---|
56 | { |
---|
57 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
58 | sc_signal<bool> s1 ("s01"), |
---|
59 | s2 ("s02"), |
---|
60 | s3 ("s03"), |
---|
61 | s4 ("s04"), |
---|
62 | s5 ("s05"), |
---|
63 | s6 ("s06"), |
---|
64 | s7 ("s07"), |
---|
65 | s8 ("s08"), |
---|
66 | s9 ("s09"), |
---|
67 | s10("s10"), |
---|
68 | s11("s11"), |
---|
69 | s12("s12"), |
---|
70 | s13("s13"), |
---|
71 | s14("s14"), |
---|
72 | s15("s15"); |
---|
73 | |
---|
74 | |
---|
75 | M1_1i1o a ("a"); |
---|
76 | M1_1i1o b ("b"); |
---|
77 | M1_1i1o c ("c"); |
---|
78 | M1_1i1o d ("d"); |
---|
79 | M1_1i1o e ("e"); |
---|
80 | M2_1i1o f ("f"); |
---|
81 | M1_1i1o g ("g"); |
---|
82 | |
---|
83 | a.clk (signal_clk); |
---|
84 | b.clk (signal_clk); |
---|
85 | c.clk (signal_clk); |
---|
86 | d.clk (signal_clk); |
---|
87 | e.clk (signal_clk); |
---|
88 | f.clk (signal_clk); |
---|
89 | g.clk (signal_clk); |
---|
90 | |
---|
91 | a.i1 (s1); |
---|
92 | |
---|
93 | a.o1 (s2); |
---|
94 | b.i1 (s2); |
---|
95 | d.i1 (s2); |
---|
96 | |
---|
97 | b.o1 (s3); |
---|
98 | c.i1 (s3); |
---|
99 | |
---|
100 | c.o1 (s4); |
---|
101 | |
---|
102 | d.o1 (s5); |
---|
103 | e.i1 (s5); |
---|
104 | |
---|
105 | e.o1 (s6); |
---|
106 | f.i1 (s6); |
---|
107 | |
---|
108 | f.o1 (s7); |
---|
109 | g.i1 (s7); |
---|
110 | |
---|
111 | g.o1 (s8); |
---|
112 | |
---|
113 | // Init & run |
---|
114 | sc_initialize (); |
---|
115 | |
---|
116 | if (argc == 1) |
---|
117 | { |
---|
118 | cout << "Usage :\n" << argv[0] << " [#cycles]\n"; |
---|
119 | return EXIT_SUCCESS; |
---|
120 | } |
---|
121 | |
---|
122 | chrono_t chrono; |
---|
123 | chrono.start (); |
---|
124 | |
---|
125 | sc_start (atoi(argv[1])); |
---|
126 | |
---|
127 | chrono.stop (); |
---|
128 | unsigned int t = chrono; |
---|
129 | cout << "Time elapsed (sec) : " << t << endl; |
---|
130 | cout << "Cycles done : " << sc_simulation_time () << endl; |
---|
131 | cout << "Performance : " << sc_simulation_time () / t << endl; |
---|
132 | return EXIT_SUCCESS; |
---|
133 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.