Changeset 55 for sources/test_regression/16062005b
- Timestamp:
- May 28, 2013, 11:17:14 AM (11 years ago)
- Location:
- sources/test_regression/16062005b
- Files:
-
- 3 deleted
- 2 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
sources/test_regression/16062005b/Makefile
r15 r55 1 include ../env.mk2 1 3 SYSTEM = system.cpp system2.cpp 4 EXE_SCASS = $(SYSTEM:.cpp=_systemcass.x) 5 EXE_SC = $(SYSTEM:.cpp=_systemc.x) 6 EXE = ${EXE_SCASS} ${EXE_SC} 7 LOG = $(SYSTEM:.cpp=.log) 8 OBJECTS = $(EXE:.x=.o) 9 LINKS = $(OBJECTS:.o=.cpp) 2 include ../16062005a/Makefile 10 3 11 .SECONDARY:12 4 13 main : $(EXE_SCASS)14 15 test : main16 ./system_systemcass.x object_hierarchy1.txt17 diff object_hierarchy1_reference.txt object_hierarchy1.txt18 ./system2_systemcass.x object_hierarchy2.txt19 diff object_hierarchy2_reference.txt object_hierarchy2.txt20 @echo Test OK.21 22 %.gif : %.dot23 dot -Tgif -o $*.gif $*.dot24 25 %_systemc.x : %_systemc.o $(SYSTEMC_LIB)26 $(CXX) -o $@ $*_systemc.o $(LFLAGS_SYSTEMC) 2>&1 | $(CPPFILT)27 28 %_systemcass.x : %_systemcass.o $(SYSTEMCASS_LIB)29 $(CXX) -o $@ $*_systemcass.o $(LFLAGS_SYSTEMCASS) 2>&1 | $(CPPFILT)30 31 -include Makefile.deps32 33 %_systemc.cpp : %.cpp34 ln -s $*.cpp $*_systemc.cpp35 36 %_systemcass.cpp : %.cpp37 ln -s $*.cpp $*_systemcass.cpp38 39 %_systemc.o : %_systemc.cpp40 $(CXX) $(CFLAGS_SYSTEMC) -MM $*_systemc.cpp >> Makefile.deps41 $(CXX) $(CFLAGS_SYSTEMC) -c $*_systemc.cpp -o $*_systemc.o42 43 %_systemcass.o : %_systemcass.cpp44 $(CXX) $(CFLAGS_SYSTEMCASS) -MM $*_systemcass.cpp >> Makefile.deps45 $(CXX) $(CFLAGS_SYSTEMCASS) -c $*_systemcass.cpp -o $*_systemcass.o46 47 clean :48 rm -f Makefile.deps49 -rm -f *.o gmon.out *~50 -rm -f ${LOG}51 -rm -f signal_order.txt module_order.dot signal_graph.dot52 -rm -f module_order.gif signal_graph.gif53 -rm -f $(EXE) $(OBJECTS)54 -for i in $(LINKS) ; do unlink $$i ; done 2> /dev/null55 -rm -f core*56 -rm -rf generated_by_systemcass57 -rm -rf system_systemcass.x.vcd system_systemc.x.vcd58 -
sources/test_regression/16062005b/object_hierarchy_ref.txt
r51 r55 1 clock sc_clock 2 top1.a.b.d1 sc_object 3 top1.a.b.d2 sc_object 4 top1.a.b.c sc_object 5 top1.a.b sc_object 6 top1.a.c sc_object 7 top1.a sc_object 8 top1.d sc_object 9 top1 sc_object 10 top2.b1.d1 sc_object 11 top2.b1.d2 sc_object 12 top2.b1.c sc_object 13 top2.b1 sc_object 14 top2.b2.d1 sc_object 15 top2.b2.d2 sc_object 16 top2.b2.c sc_object 17 top2.b2 sc_object 18 top2.c sc_object 19 top2 sc_object 1 Top level : 2 s_clk, noname_0, noname_1, noname_2, noname_3, m, top_level_module 3 4 Child of "m" : 5 m.i_bool, m.i_int, m.i_sc_int17, m.o_int, m.o_sc_uint38, m.reg_lv8, m.reg_int, m.reg_uint, m.reg_sc_uint3, m.reg_sc_int31, m.noname_4, m.intern_module_of_moldu 6 7 Child of "m.intern_module_of_moldu" : 8 m.intern_module_of_moldu.noname_5 9 10 Child of "top_level_module" : 11 top_level_module.noname_6 -
sources/test_regression/16062005b/system.cpp
r1 r55 1 #include "systemc.h" 1 2 2 #include <iostream> 3 3 #include <fstream> 4 4 #include <vector> 5 5 6 #define ASSERT(x) { if (!(x)) { \ 7 cerr << "ASSERT : " #x \ 8 << " in function '" << __FUNCTION__ \ 9 << "'\n"; exit (-1); \ 10 } \ 11 } 12 6 #include "systemc.h" 7 #include "test.h" 13 8 14 9 using namespace std; 15 10 16 struct D : sc_module 17 { 18 D (sc_module_name) 19 { 20 } 11 12 struct intramoldu : sc_module { 13 sc_signal<long> reg_long; 14 intramoldu(sc_module_name n) {} 21 15 }; 22 16 23 struct C : sc_module 24 { 25 C (sc_module_name) 26 { 27 } 17 18 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") {} 28 44 }; 29 45 30 struct B : sc_module31 {32 D d1;33 D d2;34 C c;35 B (sc_module_name) : d1("d1"), d2("d2"), c("c")36 {37 }38 };39 46 40 struct A : sc_module 41 { 42 B b; 43 C c; 44 A (sc_module_name) : b("b"), c("c") 45 { 46 } 47 }; 48 49 struct top_level1 : sc_module 50 { 51 A a; 52 D d; 53 top_level1(sc_module_name) : a("a"), d("d") 54 { 55 } 56 }; 57 58 struct top_level2 : sc_module 59 { 60 B b1; 61 B b2; 62 C c; 63 top_level2(sc_module_name) : b1("b1"), b2("b2"), c("c") 64 { 65 } 66 }; 67 68 void 69 dump_hierarchy (ostream &o, sc_object *obj) 70 { 71 const std::vector<sc_object*> &children = obj->get_child_objects(); 72 for (unsigned i = 0; i < children.size(); i++) 73 if (children[i]) 74 dump_hierarchy (o,children[i]); 75 o << obj->name () << " " << obj->kind() << endl; 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"; 76 58 } 77 59 78 void 79 dump_hierarchy (ostream &o, const std::vector<sc_object*> &obj_list) 80 { 81 for (unsigned i = 0; i < obj_list.size(); i++) 82 dump_hierarchy(o, obj_list[i]); 60 61 int sc_main (int argc, char ** argv) { 62 if (argc < 2) { 63 cerr << "Usage : " << argv[0] << " <filename>\n"; 64 exit(-1); 65 } 66 67 ofstream o; 68 o.open (argv[1], ios::out | ios::trunc); 69 if (!o.is_open()) { 70 cerr << "Unable to open '" << argv[1] << "'.\n"; 71 return 1; 72 } 73 74 sc_clock s_clk("s_clk"); 75 sc_signal<bool> s_bool; 76 sc_signal<int> s_int; 77 sc_signal< sc_int<17> > s_sc_int17; 78 sc_signal< sc_uint<38> > s_sc_uint38; 79 moldu m("m"); 80 intramoldu microarchitecture("top_level_module"); 81 m.i_clk(s_clk); 82 m.i_bool(s_bool); 83 m.i_int(s_int); 84 m.i_sc_int17(s_sc_int17); 85 m.o_int(s_int); 86 m.o_sc_uint38(s_sc_uint38); 87 88 sc_start(sc_time(0, sc_core::SC_NS)); 89 o << "Top level :\n"; 90 dump_objects(o, sc_get_top_level_objects()); 91 o << "\nChild of \"m\" :\n"; 92 dump_objects(o, m.get_child_objects()); 93 o << "\nChild of \"m.intern_module_of_moldu\" :\n"; 94 dump_objects(o, m.microarchitecture.get_child_objects()); 95 o << "\nChild of \"top_level_module\" :\n"; 96 dump_objects(o, microarchitecture.get_child_objects()); 97 98 o.close(); 99 100 return 0; 83 101 } 84 102 85 int86 sc_main (int argc, char ** argv)87 {88 if (argc < 2)89 {90 cerr << "Usage : " << argv[0] << " <filename>\n";91 exit (-1);92 }93 103 94 sc_clock clk("clock"); 95 top_level1 top1("top1"); 96 top_level2 top2("top2"); 97 98 ofstream o; 99 o.open (argv[1],ios::out | ios::trunc); 100 if (o.is_open () == false) 101 { 102 cerr << "Unable to open '" << argv[1] << "'.\n"; 103 return 1; 104 } 104 /* 105 # Local Variables: 106 # tab-width: 4; 107 # c-basic-offset: 4; 108 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 109 # indent-tabs-mode: nil; 110 # End: 111 # 112 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 113 */ 105 114 106 sc_start(0);107 dump_hierarchy (o,sc_get_top_level_objects());108 109 ASSERT(sc_find_object("top2.b1" ) == &top2.b1 );110 ASSERT(sc_find_object("top2.b1.d1" ) == &top2.b1.d1 );111 ASSERT(sc_find_object("top2.b1.d2" ) == &top2.b1.d2 );112 ASSERT(sc_find_object("top2.b1.c" ) == &top2.b1.c );113 ASSERT(sc_find_object("top2.b2" ) == &top2.b2 );114 ASSERT(sc_find_object("top2.c" ) == &top2.c );115 ASSERT(sc_find_object("top1.a" ) == &top1.a );116 ASSERT(sc_find_object("top1.d" ) == &top1.d );117 ASSERT(sc_find_object("top1.a.b" ) == &top1.a.b );118 ASSERT(sc_find_object("top1.a.b.d1") == &top1.a.b.d1);119 ASSERT(sc_find_object("top1.a.b.d2") == &top1.a.b.d2);120 ASSERT(sc_find_object("top1.a.b.c" ) == &top1.a.b.c );121 ASSERT(sc_find_object("top1.a.c" ) == &top1.a.c );122 ASSERT(sc_find_object("top1.c" ) == NULL );123 ASSERT(sc_find_object("top1" )->get_parent_object() == NULL);124 ASSERT(sc_find_object("top1.a" )->get_parent_object() == &top1);125 ASSERT(sc_find_object("top1.a.b" )->get_parent_object() == &top1.a);126 ASSERT(sc_find_object("top1.a.b.d2")->get_parent_object() == &top1.a.b);127 ASSERT(sc_find_object("top1.d" )->get_parent_object() == &top1);128 ASSERT(sc_find_object("top2.b1" )->get_parent_object() == &top2);129 ASSERT(sc_find_object("top2.b2" )->get_parent_object() == &top2);130 ASSERT(sc_find_object("top2.c" )->get_parent_object() == &top2);131 ASSERT(sc_find_object("top2.b1.c" )->get_parent_object() == &top2.b1);132 #if 0133 o << sc_find_object("top2.b1.d1")->name() << endl;134 o << sc_find_object("top2.b1.d2")->name() << endl;135 o << sc_find_object("top2.b1.c")->name() << endl;136 o << sc_find_object("top2.b2")->name() << endl;137 o << sc_find_object("top2.c")->name() << endl;138 o << sc_find_object("top1.a")->name() << endl;139 o << sc_find_object("top1.d")->name() << endl;140 o << sc_find_object("top1.a.b")->name() << endl;141 o << sc_find_object("top1.a.b.d1")->name() << endl;142 o << sc_find_object("top1.a.b.d2")->name() << endl;143 o << sc_find_object("top1.a.b.c")->name() << endl;144 o << sc_find_object("top1.a.c")->name() << endl;145 if (sc_find_object("top1.c") == NULL)146 o << "top1.c not found.\n";147 else148 o << "top1.c found.\n";149 o << sc_find_object("top2.b1.c")->get_parent_object()->name () << endl;150 o << sc_find_object("top1.a")->get_parent_object()->name () << endl;151 if (top1.get_parent_object() == NULL)152 o << "top1 has no parent.\n";153 else154 o << "top1 has a parent.\n";155 #endif156 157 o.close ();158 159 return 0;160 }161
Note: See TracChangeset
for help on using the changeset viewer.