[55] | 1 | |
---|
[1] | 2 | #include <iostream> |
---|
| 3 | #include <fstream> |
---|
| 4 | #include <vector> |
---|
| 5 | |
---|
[55] | 6 | #include "systemc.h" |
---|
| 7 | #include "test.h" |
---|
[1] | 8 | |
---|
| 9 | using namespace std; |
---|
| 10 | |
---|
| 11 | |
---|
[55] | 12 | struct intramoldu : sc_module { |
---|
| 13 | sc_signal<long> reg_long; |
---|
| 14 | intramoldu(sc_module_name n) {} |
---|
[1] | 15 | }; |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | |
---|
[55] | 19 | struct moldu : sc_module { |
---|
| 20 | sc_in<bool> i_bool; |
---|
| 21 | sc_in<int > i_int; |
---|
| 22 | sc_in<sc_int<17> > i_sc_int17; |
---|
| 23 | sc_out<int > o_int; |
---|
| 24 | sc_out<sc_uint<38> > o_sc_uint38; |
---|
| 25 | sc_signal<sc_lv<8> > reg_lv8; |
---|
| 26 | sc_signal<int> reg_int; |
---|
| 27 | sc_signal<unsigned int> reg_uint; |
---|
| 28 | sc_signal<sc_uint<3> > reg_sc_uint3; |
---|
| 29 | sc_signal<sc_int<31> > reg_sc_int31; |
---|
| 30 | sc_in_clk i_clk; |
---|
| 31 | intramoldu microarchitecture; |
---|
| 32 | moldu(sc_module_name n) : |
---|
| 33 | i_bool ("i_bool"), |
---|
| 34 | i_int ("i_int"), |
---|
| 35 | i_sc_int17 ("i_sc_int17"), |
---|
| 36 | o_int ("o_int"), |
---|
| 37 | o_sc_uint38("o_sc_uint38"), |
---|
| 38 | reg_lv8 ("reg_lv8"), |
---|
| 39 | reg_int ("reg_int"), |
---|
| 40 | reg_uint ("reg_uint"), |
---|
| 41 | reg_sc_uint3 ("reg_sc_uint3"), |
---|
| 42 | reg_sc_int31 ("reg_sc_int31"), |
---|
| 43 | microarchitecture ("intern_module_of_moldu") {} |
---|
[1] | 44 | }; |
---|
| 45 | |
---|
| 46 | |
---|
[55] | 47 | void dump_objects (ofstream & o, const vector<sc_object *> & obj_list) { |
---|
| 48 | for (unsigned i = 0; i < obj_list.size(); i++) { |
---|
| 49 | const sc_object * obj = obj_list[i]; |
---|
| 50 | if (obj == NULL) { |
---|
| 51 | o << "\nError : NULL pointer in objects list !\n"; |
---|
| 52 | } |
---|
| 53 | else { |
---|
| 54 | o << ((i != 0) ? ", " : "") << obj->name(); |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | o << "\n"; |
---|
[1] | 58 | } |
---|
| 59 | |
---|
| 60 | |
---|
[55] | 61 | int sc_main (int argc, char ** argv) { |
---|
| 62 | if (argc < 2) { |
---|
| 63 | cerr << "Usage : " << argv[0] << " <filename>\n"; |
---|
| 64 | exit(-1); |
---|
| 65 | } |
---|
[1] | 66 | |
---|
[60] | 67 | // Setup number of threads open-mp to 1 with the macro threads_omp() |
---|
| 68 | threads_omp(); |
---|
| 69 | |
---|
[55] | 70 | ofstream o; |
---|
| 71 | o.open (argv[1], ios::out | ios::trunc); |
---|
| 72 | if (!o.is_open()) { |
---|
| 73 | cerr << "Unable to open '" << argv[1] << "'.\n"; |
---|
| 74 | return 1; |
---|
| 75 | } |
---|
[1] | 76 | |
---|
[55] | 77 | sc_clock s_clk("s_clk"); |
---|
| 78 | sc_signal<bool> s_bool; |
---|
| 79 | sc_signal<int> s_int; |
---|
| 80 | sc_signal< sc_int<17> > s_sc_int17; |
---|
| 81 | sc_signal< sc_uint<38> > s_sc_uint38; |
---|
| 82 | moldu m("m"); |
---|
| 83 | intramoldu microarchitecture("top_level_module"); |
---|
| 84 | m.i_clk(s_clk); |
---|
| 85 | m.i_bool(s_bool); |
---|
| 86 | m.i_int(s_int); |
---|
| 87 | m.i_sc_int17(s_sc_int17); |
---|
| 88 | m.o_int(s_int); |
---|
| 89 | m.o_sc_uint38(s_sc_uint38); |
---|
[1] | 90 | |
---|
[55] | 91 | sc_start(sc_time(0, sc_core::SC_NS)); |
---|
| 92 | o << "Top level :\n"; |
---|
| 93 | dump_objects(o, sc_get_top_level_objects()); |
---|
| 94 | o << "\nChild of \"m\" :\n"; |
---|
| 95 | dump_objects(o, m.get_child_objects()); |
---|
| 96 | o << "\nChild of \"m.intern_module_of_moldu\" :\n"; |
---|
| 97 | dump_objects(o, m.microarchitecture.get_child_objects()); |
---|
| 98 | o << "\nChild of \"top_level_module\" :\n"; |
---|
| 99 | dump_objects(o, microarchitecture.get_child_objects()); |
---|
[1] | 100 | |
---|
[55] | 101 | o.close(); |
---|
| 102 | |
---|
| 103 | return 0; |
---|
[1] | 104 | } |
---|
| 105 | |
---|
[55] | 106 | |
---|
| 107 | /* |
---|
| 108 | # Local Variables: |
---|
| 109 | # tab-width: 4; |
---|
| 110 | # c-basic-offset: 4; |
---|
| 111 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 112 | # indent-tabs-mode: nil; |
---|
| 113 | # End: |
---|
| 114 | # |
---|
| 115 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 116 | */ |
---|
| 117 | |
---|