[55] | 1 | // QM : je ne sais ce que cherche à tester ce test |
---|
| 2 | // Dans le doute j'applique un traitement par défaut (diff sc) avec un cout "OK" |
---|
| 3 | |
---|
[1] | 4 | #include <systemc.h> |
---|
| 5 | |
---|
[55] | 6 | #include "test.h" |
---|
[1] | 7 | |
---|
[55] | 8 | |
---|
[1] | 9 | using namespace std; |
---|
| 10 | |
---|
| 11 | template<typename datatype> |
---|
| 12 | class module_base : public sc_module { |
---|
| 13 | |
---|
[55] | 14 | public: |
---|
| 15 | sc_in_clk clk; |
---|
| 16 | sc_in<datatype> i1; |
---|
| 17 | sc_out<datatype> o1; |
---|
| 18 | sc_signal<datatype> reg1; |
---|
[1] | 19 | |
---|
[55] | 20 | private: |
---|
| 21 | void trans_module_base() {} |
---|
| 22 | void gen_module_base() { |
---|
| 23 | this->kikoo (); |
---|
| 24 | } |
---|
| 25 | virtual void kikoo() = 0; |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | public: |
---|
| 29 | SC_HAS_PROCESS(module_base); |
---|
| 30 | module_base (sc_module_name n) : sc_module (n), |
---|
| 31 | clk("clk"), i1("i1"), o1("o1"), reg1("reg1") { |
---|
| 32 | SC_METHOD(trans_module_base); |
---|
| 33 | sensitive << clk.pos(); |
---|
| 34 | dont_initialize(); |
---|
| 35 | |
---|
| 36 | SC_METHOD(gen_module_base); |
---|
| 37 | sensitive << clk.neg(); |
---|
| 38 | dont_initialize(); |
---|
| 39 | } |
---|
[1] | 40 | }; |
---|
| 41 | |
---|
[55] | 42 | |
---|
[1] | 43 | template<typename datatype> |
---|
| 44 | class test : public module_base<datatype> { |
---|
| 45 | |
---|
[55] | 46 | public: |
---|
| 47 | sc_in<datatype> i2; |
---|
| 48 | sc_out<datatype> o2; |
---|
| 49 | sc_signal<datatype> reg2; |
---|
[1] | 50 | |
---|
[55] | 51 | private: |
---|
| 52 | void trans() {} |
---|
[1] | 53 | |
---|
[55] | 54 | void gen() {} |
---|
| 55 | |
---|
| 56 | virtual void kikoo() {} |
---|
| 57 | |
---|
| 58 | public: |
---|
| 59 | SC_HAS_PROCESS(test); |
---|
| 60 | test(sc_module_name n) : module_base<datatype> (n), |
---|
[1] | 61 | i2("i2"), |
---|
| 62 | o2("o2"), |
---|
[55] | 63 | reg2("reg2") { |
---|
| 64 | SC_METHOD(trans); |
---|
| 65 | this->sensitive << this->clk.pos(); |
---|
| 66 | this->dont_initialize(); |
---|
| 67 | |
---|
| 68 | SC_METHOD(gen); |
---|
| 69 | this->sensitive << this->clk.neg(); |
---|
| 70 | this->dont_initialize(); |
---|
| 71 | } |
---|
[1] | 72 | }; |
---|
| 73 | |
---|
| 74 | |
---|
[55] | 75 | int sc_main(int argc, char * argv[]) { |
---|
| 76 | sc_clock signal_clk("my_clock"); |
---|
| 77 | sc_signal<int> s01("s01"), s02("s02"), s03("s03"), s04("s04"); |
---|
[1] | 78 | |
---|
[60] | 79 | // Setup number of threads open-mp to 1 with the macro threads_omp() |
---|
| 80 | threads_omp(); |
---|
| 81 | |
---|
[55] | 82 | test<int> test1("test1"); |
---|
| 83 | test1.clk(signal_clk); |
---|
| 84 | test1.i1(s01); |
---|
| 85 | test1.i2(s02); |
---|
| 86 | test1.o1(s03); |
---|
| 87 | test1.o2(s04); |
---|
[1] | 88 | |
---|
[55] | 89 | // Init & run |
---|
| 90 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
| 91 | |
---|
| 92 | cout << "OK" << endl; |
---|
| 93 | return EXIT_SUCCESS; |
---|
[1] | 94 | } |
---|
| 95 | |
---|
[55] | 96 | |
---|
| 97 | /* |
---|
| 98 | # Local Variables: |
---|
| 99 | # tab-width: 4; |
---|
| 100 | # c-basic-offset: 4; |
---|
| 101 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 102 | # indent-tabs-mode: nil; |
---|
| 103 | # End: |
---|
| 104 | # |
---|
| 105 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 106 | */ |
---|
| 107 | |
---|