Last change
on this file since 64 was
60,
checked in by meunier, 8 years ago
|
- Intégration des modifications de Clément,
qui a intégré la version parallélisée de systemcass
faite par Manuel.
|
File size:
2.7 KB
|
Rev | Line | |
---|
[55] | 1 | |
---|
[1] | 2 | #include <signal.h> |
---|
| 3 | |
---|
[55] | 4 | #include "systemc.h" |
---|
| 5 | #include "test.h" |
---|
[1] | 6 | |
---|
| 7 | |
---|
[55] | 8 | using namespace std; |
---|
[1] | 9 | |
---|
| 10 | |
---|
[55] | 11 | struct M1_1i1o : sc_module { |
---|
| 12 | sc_in_clk clk; |
---|
| 13 | sc_in<bool> i1; |
---|
| 14 | sc_out<bool> o1; |
---|
[1] | 15 | |
---|
[55] | 16 | void eval_mealy1() { |
---|
| 17 | o1 = ~i1; |
---|
| 18 | } |
---|
[1] | 19 | |
---|
[55] | 20 | SC_CTOR (M1_1i1o) : clk("clk"), i1("i1"), o1("o1") { |
---|
| 21 | SC_METHOD(eval_mealy1); |
---|
| 22 | sensitive << clk.neg(); |
---|
| 23 | sensitive << i1; |
---|
| 24 | dont_initialize(); |
---|
[1] | 25 | #ifdef SYSTEMCASS_SPECIFIC |
---|
[55] | 26 | o1(i1); |
---|
[1] | 27 | #endif |
---|
[55] | 28 | } |
---|
| 29 | |
---|
[1] | 30 | }; |
---|
| 31 | |
---|
| 32 | |
---|
[55] | 33 | struct M1_3i2o : sc_module { |
---|
| 34 | sc_in_clk clk; |
---|
| 35 | sc_in<bool> i1; |
---|
| 36 | sc_in<bool> i2; |
---|
| 37 | sc_in<bool> i3; |
---|
| 38 | sc_out<bool> o1; |
---|
| 39 | sc_out<bool> o2; |
---|
[1] | 40 | |
---|
[55] | 41 | void eval_mealy1() { |
---|
| 42 | o1 = ~i1 & i2; |
---|
| 43 | o2 = ~i2 & i3; |
---|
| 44 | } |
---|
[1] | 45 | |
---|
| 46 | |
---|
[55] | 47 | SC_CTOR (M1_3i2o) : clk("clk"), i1("i1"), i2("i2"), i3("i3"), o1("o1"), o2("o2") { |
---|
| 48 | SC_METHOD(eval_mealy1); |
---|
| 49 | sensitive << clk.neg(); |
---|
| 50 | sensitive << i1 << i2; |
---|
| 51 | sensitive << i3; |
---|
| 52 | dont_initialize(); |
---|
[1] | 53 | #ifdef SYSTEMCASS_SPECIFIC |
---|
[55] | 54 | o1(i1); |
---|
| 55 | o1(i2); |
---|
| 56 | o2(i2); |
---|
| 57 | o2(i3); |
---|
[1] | 58 | #endif |
---|
[55] | 59 | } |
---|
| 60 | |
---|
[1] | 61 | }; |
---|
| 62 | |
---|
| 63 | |
---|
[55] | 64 | struct M2_1i1o : sc_module { |
---|
| 65 | sc_in_clk clk; |
---|
| 66 | sc_in<bool> i1; |
---|
| 67 | sc_out<bool> o1; |
---|
[1] | 68 | |
---|
[55] | 69 | sc_signal<bool> reg; |
---|
[1] | 70 | |
---|
[55] | 71 | void tr_moore1() { |
---|
| 72 | reg = ~i1; |
---|
| 73 | } |
---|
[1] | 74 | |
---|
[55] | 75 | void gen_moore1() { |
---|
| 76 | o1 = ~reg; |
---|
| 77 | }; |
---|
| 78 | |
---|
| 79 | SC_CTOR (M2_1i1o) : clk("clk"), i1("i1"), o1("o1") { |
---|
| 80 | SC_METHOD(tr_moore1); |
---|
| 81 | sensitive << clk.pos(); |
---|
| 82 | dont_initialize(); |
---|
| 83 | |
---|
| 84 | SC_METHOD(gen_moore1); |
---|
| 85 | sensitive << clk.neg(); |
---|
| 86 | dont_initialize(); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | }; |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | int sc_main (int argc, char * argv[]) { |
---|
| 93 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
| 94 | sc_signal<bool> s1 ("s01"), |
---|
| 95 | s2 ("s02"), |
---|
| 96 | s3 ("s03"), |
---|
| 97 | s4 ("s04"), |
---|
| 98 | s5 ("s05"), |
---|
| 99 | s6 ("s06"), |
---|
| 100 | s7 ("s07"), |
---|
| 101 | s8 ("s08"), |
---|
| 102 | s9 ("s09"), |
---|
| 103 | s10("s10"), |
---|
| 104 | s11("s11"), |
---|
| 105 | s12("s12"), |
---|
| 106 | s13("s13"), |
---|
| 107 | s14("s14"), |
---|
| 108 | s15("s15"); |
---|
| 109 | |
---|
[60] | 110 | // Setup number of threads open-mp to 1 with the macro threads_omp() |
---|
| 111 | threads_omp(); |
---|
[55] | 112 | |
---|
| 113 | M1_3i2o a("a"); |
---|
| 114 | M1_1i1o b("b"); |
---|
| 115 | M1_3i2o c("c"); |
---|
| 116 | M1_1i1o d("d"); |
---|
| 117 | M1_1i1o e("e"); |
---|
| 118 | |
---|
| 119 | a.clk(signal_clk); |
---|
| 120 | b.clk(signal_clk); |
---|
| 121 | c.clk(signal_clk); |
---|
| 122 | d.clk(signal_clk); |
---|
| 123 | e.clk(signal_clk); |
---|
| 124 | |
---|
| 125 | a.i1(s1); |
---|
| 126 | |
---|
| 127 | a.o1(s2); |
---|
| 128 | b.i1(s2); |
---|
| 129 | |
---|
| 130 | b.o1(s3); |
---|
| 131 | c.i1(s3); |
---|
| 132 | |
---|
| 133 | c.o1(s4); |
---|
| 134 | |
---|
| 135 | a.i2(s5); |
---|
| 136 | |
---|
| 137 | a.o2(s6); |
---|
| 138 | c.i2(s6); |
---|
| 139 | d.i1(s6); |
---|
| 140 | |
---|
| 141 | c.o2(s7); |
---|
| 142 | |
---|
| 143 | a.i3(s8); |
---|
| 144 | |
---|
| 145 | d.o1(s9); |
---|
| 146 | e.i1(s9); |
---|
| 147 | |
---|
| 148 | e.o1(s10); |
---|
| 149 | c.i3(s10); |
---|
| 150 | |
---|
| 151 | // Init & run |
---|
| 152 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
| 153 | |
---|
[1] | 154 | return EXIT_SUCCESS; |
---|
[55] | 155 | } |
---|
[1] | 156 | |
---|
| 157 | |
---|
[55] | 158 | /* |
---|
| 159 | # Local Variables: |
---|
| 160 | # tab-width: 4; |
---|
| 161 | # c-basic-offset: 4; |
---|
| 162 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 163 | # indent-tabs-mode: nil; |
---|
| 164 | # End: |
---|
| 165 | # |
---|
| 166 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 167 | */ |
---|
[1] | 168 | |
---|
Note: See
TracBrowser
for help on using the repository browser.