Last change
on this file since 56 was
55,
checked in by meunier, 11 years ago
|
Tried to clean the test_regression directory:
- Code formatting
- Supressed warnings
- Made comprehensible outputs
- Factorized Makefiles
There's still a lot to do (many tests don't pass for either good or bad reasons)
|
File size:
3.1 KB
|
Line | |
---|
1 | #include <signal.h> |
---|
2 | |
---|
3 | #include "systemc.h" |
---|
4 | #include "test.h" |
---|
5 | |
---|
6 | |
---|
7 | using namespace std; |
---|
8 | |
---|
9 | struct M1_3i3o : sc_module { |
---|
10 | sc_in_clk clk; |
---|
11 | sc_in<bool> i1; |
---|
12 | sc_in<bool> i2; |
---|
13 | sc_in<bool> i3; |
---|
14 | sc_out<bool> o1; |
---|
15 | sc_out<bool> o2; |
---|
16 | sc_out<bool> o3; |
---|
17 | |
---|
18 | sc_signal<bool> reg; |
---|
19 | |
---|
20 | void eval_mealy1() { |
---|
21 | o1 = ~i1; |
---|
22 | } |
---|
23 | |
---|
24 | void eval_mealy2() { |
---|
25 | o2 = ~i2; |
---|
26 | } |
---|
27 | |
---|
28 | void tr_moore() { |
---|
29 | reg = i3; |
---|
30 | } |
---|
31 | |
---|
32 | void gen_moore() { |
---|
33 | o3 = ~reg; |
---|
34 | } |
---|
35 | |
---|
36 | SC_CTOR (M1_3i3o) : clk("clk"), i1("i1"), i2("i2"), i3("i3"), o1("o1"), |
---|
37 | o2("o2"), o3("o3") { |
---|
38 | SC_METHOD(eval_mealy1); |
---|
39 | sensitive << clk.neg(); |
---|
40 | sensitive << i1; |
---|
41 | dont_initialize(); |
---|
42 | #ifdef SYSTEMCASS_SPECIFIC |
---|
43 | o1(i1); |
---|
44 | #endif |
---|
45 | |
---|
46 | SC_METHOD(eval_mealy2); |
---|
47 | sensitive << clk.neg(); |
---|
48 | sensitive << i2; |
---|
49 | dont_initialize(); |
---|
50 | |
---|
51 | #ifdef SYSTEMCASS_SPECIFIC |
---|
52 | o2(i2); |
---|
53 | #endif |
---|
54 | SC_METHOD(tr_moore); |
---|
55 | sensitive << clk.pos(); |
---|
56 | dont_initialize(); |
---|
57 | |
---|
58 | SC_METHOD(gen_moore); |
---|
59 | sensitive << clk.neg(); |
---|
60 | dont_initialize(); |
---|
61 | } |
---|
62 | |
---|
63 | }; |
---|
64 | |
---|
65 | |
---|
66 | struct M2_4i4o : sc_module { |
---|
67 | sc_in_clk clk; |
---|
68 | sc_in<bool> i1; |
---|
69 | sc_in<bool> i2; |
---|
70 | sc_in<bool> i3; |
---|
71 | sc_in<bool> i4; |
---|
72 | sc_out<bool> o1; |
---|
73 | sc_out<bool> o2; |
---|
74 | sc_out<bool> o3; |
---|
75 | sc_out<bool> o4; |
---|
76 | sc_signal<sc_uint<2> > reg; |
---|
77 | |
---|
78 | void tr_moore() { |
---|
79 | reg = ((i1.read() & i3.read()) ? 2 : 0) + (i2.read() | i4.read()); |
---|
80 | } |
---|
81 | |
---|
82 | void gen_moore() { |
---|
83 | o1 = reg.read() & 1; |
---|
84 | o2 = reg.read() & 2; |
---|
85 | o3 = ~(reg.read() & 1); |
---|
86 | o4 = ~(reg.read() & 2); |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | SC_CTOR (M2_4i4o) : clk("clk"), i1("i1"), i2("i2"), i3("i3"), i4("i4"), o1("o1"), o2("o2"), o3("o3"), o4("o4") { |
---|
91 | SC_METHOD(tr_moore); |
---|
92 | sensitive << clk.pos(); |
---|
93 | dont_initialize(); |
---|
94 | |
---|
95 | SC_METHOD(gen_moore); |
---|
96 | sensitive << clk.neg(); |
---|
97 | dont_initialize(); |
---|
98 | } |
---|
99 | |
---|
100 | }; |
---|
101 | |
---|
102 | |
---|
103 | int sc_main (int argc, char * argv[]) { |
---|
104 | sc_clock signal_clk("my_clock"); |
---|
105 | sc_signal<bool> s1 ("s01"), |
---|
106 | s2 ("s02"), |
---|
107 | s3 ("s03"), |
---|
108 | s4 ("s04"), |
---|
109 | s5 ("s05"), |
---|
110 | s6 ("s06"), |
---|
111 | s7 ("s07"), |
---|
112 | s8 ("s08"), |
---|
113 | s9 ("s09"), |
---|
114 | s10("s10"), |
---|
115 | s11("s11"), |
---|
116 | s12("s12"), |
---|
117 | s13("s13"), |
---|
118 | s14("s14"), |
---|
119 | s15("s15"); |
---|
120 | |
---|
121 | |
---|
122 | M1_3i3o a("a"); |
---|
123 | M1_3i3o b("b"); |
---|
124 | M2_4i4o Moore("Moore"); |
---|
125 | |
---|
126 | a.clk(signal_clk); |
---|
127 | b.clk(signal_clk); |
---|
128 | Moore.clk(signal_clk); |
---|
129 | |
---|
130 | Moore.o1(s1); |
---|
131 | a.i1(s1); |
---|
132 | |
---|
133 | a.o1(s2); |
---|
134 | b.i1(s2); |
---|
135 | |
---|
136 | b.o1(s3); |
---|
137 | Moore.i1(s3); |
---|
138 | |
---|
139 | Moore.o2(s4); |
---|
140 | b.i2(s4); |
---|
141 | |
---|
142 | b.o2(s5); |
---|
143 | a.i2(s5); |
---|
144 | |
---|
145 | a.o2(s6); |
---|
146 | Moore.i2(s6); |
---|
147 | |
---|
148 | Moore.o3(s7); |
---|
149 | b.i3(s7); |
---|
150 | |
---|
151 | Moore.o4(s8); |
---|
152 | a.i3(s8); |
---|
153 | |
---|
154 | b.o3(s9); |
---|
155 | Moore.i4(s9); |
---|
156 | |
---|
157 | a.o3(s10); |
---|
158 | Moore.i3(s10); |
---|
159 | |
---|
160 | // Init & run |
---|
161 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
162 | |
---|
163 | return EXIT_SUCCESS; |
---|
164 | } |
---|
165 | |
---|
166 | /* |
---|
167 | # Local Variables: |
---|
168 | # tab-width: 4; |
---|
169 | # c-basic-offset: 4; |
---|
170 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
171 | # indent-tabs-mode: nil; |
---|
172 | # End: |
---|
173 | # |
---|
174 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
175 | */ |
---|
176 | |
---|
Note: See
TracBrowser
for help on using the repository browser.