Last change
on this file since 65 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:
1.4 KB
|
Rev | Line | |
---|
[55] | 1 | |
---|
[41] | 2 | #include <signal.h> |
---|
| 3 | |
---|
[55] | 4 | #include "systemc.h" |
---|
| 5 | #include "test.h" |
---|
| 6 | |
---|
[41] | 7 | using namespace std; |
---|
[55] | 8 | |
---|
[41] | 9 | struct A : sc_module { |
---|
[55] | 10 | sc_in_clk clk; |
---|
| 11 | sc_in <int> i1; |
---|
| 12 | sc_signal <int> r1; |
---|
| 13 | sc_out <int> o1; |
---|
[41] | 14 | |
---|
[55] | 15 | void transition() { |
---|
| 16 | int i; |
---|
| 17 | for (i = 0; i < 1000; ++i); |
---|
| 18 | r1 = i1; |
---|
| 19 | } |
---|
[41] | 20 | |
---|
[55] | 21 | void gen_moore() { |
---|
| 22 | int i; |
---|
| 23 | for (i = 0; i < 1000; ++i); |
---|
| 24 | o1 = r1; |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | SC_CTOR (A) : clk("clk"), o1("o1") { |
---|
| 28 | SC_METHOD(transition); |
---|
| 29 | sensitive << clk.pos(); |
---|
| 30 | dont_initialize(); |
---|
| 31 | |
---|
| 32 | SC_METHOD(gen_moore); |
---|
| 33 | sensitive << clk.neg(); |
---|
| 34 | dont_initialize(); |
---|
| 35 | } |
---|
| 36 | |
---|
[41] | 37 | }; |
---|
| 38 | |
---|
| 39 | |
---|
[55] | 40 | int sc_main (int argc, char * argv[]) { |
---|
| 41 | sc_clock signal_clk("my_clock"); |
---|
| 42 | sc_signal<int> s1("s1"), s2("s2"), s3("s3"), s4("s4"); |
---|
[41] | 43 | |
---|
[60] | 44 | // Setup number of threads open-mp to 1 with the macro threads_omp() |
---|
| 45 | threads_omp(); |
---|
| 46 | |
---|
[55] | 47 | A a("a"); |
---|
| 48 | A b("b"); |
---|
[41] | 49 | |
---|
[55] | 50 | a.clk(signal_clk); |
---|
| 51 | b.clk(signal_clk); |
---|
[41] | 52 | |
---|
[55] | 53 | a.i1(s1); |
---|
| 54 | a.o1(s2); |
---|
[41] | 55 | |
---|
[55] | 56 | b.i1(s3); |
---|
| 57 | b.o1(s4); |
---|
[41] | 58 | |
---|
[55] | 59 | // Init & run |
---|
| 60 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
[41] | 61 | |
---|
[55] | 62 | s1.write(1); |
---|
[41] | 63 | |
---|
[55] | 64 | sc_start(sc_time(100000, sc_core::SC_NS)); |
---|
| 65 | |
---|
| 66 | cout << s1.read() << endl; |
---|
| 67 | cout << s2.read() << endl; |
---|
| 68 | |
---|
| 69 | return EXIT_SUCCESS; |
---|
[41] | 70 | } |
---|
[55] | 71 | |
---|
| 72 | |
---|
| 73 | /* |
---|
| 74 | # Local Variables: |
---|
| 75 | # tab-width: 4; |
---|
| 76 | # c-basic-offset: 4; |
---|
| 77 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 78 | # indent-tabs-mode: nil; |
---|
| 79 | # End: |
---|
| 80 | # |
---|
| 81 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 82 | */ |
---|
| 83 | |
---|
Note: See
TracBrowser
for help on using the repository browser.