Changeset 55 for sources/test_regression/16062005a
- Timestamp:
- May 28, 2013, 11:17:14 AM (11 years ago)
- Location:
- sources/test_regression/16062005a
- Files:
-
- 3 deleted
- 2 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
sources/test_regression/16062005a/Makefile
r15 r55 1 1 2 include ../env.mk 3 HIERARCHY = object_hierarchy.txt 4 ERASE = $(HIERARCHY) 5 include ../Makefile.common 2 6 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) 7 HIERARCHY_REF = object_hierarchy_ref.txt 10 8 11 .SECONDARY: 9 test : $(EXE_SCASS) 10 @echo -ne "| Testing $$(basename $$(pwd)): " ; 11 @./$(EXE_SCASS) $(HIERARCHY) 2> /dev/null 12 @if diff $(HIERARCHY) $(HIERARCHY_REF) > /dev/null ; then \ 13 echo "OK" ; \ 14 else echo "KO" ; \ 15 fi ; 12 16 13 main : $(EXE_SCASS)14 17 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 18 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/16062005a/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 } 6 #include "systemc.h" 7 #include "test.h" 12 8 13 9 14 10 using namespace std; 15 11 16 struct D : sc_module 17 { 18 D (sc_module_name) 19 { 20 } 12 struct D : sc_module { 13 D(sc_module_name) {} 21 14 }; 22 15 23 struct C : sc_module 24 { 25 C (sc_module_name) 26 { 27 } 16 17 18 struct C : sc_module { 19 C(sc_module_name) {} 28 20 }; 29 21 30 struct B : sc_module 31 { 32 D d1; 33 D d2; 34 C c; 35 B (sc_module_name) : d1("d1"), d2("d2"), c("c") 36 { 37 } 22 23 struct B : sc_module { 24 D d1; 25 D d2; 26 C c; 27 B(sc_module_name) : d1("d1"), d2("d2"), c("c") {} 38 28 }; 39 29 40 struct A : sc_module 41 { 42 B b; 43 C c; 44 A (sc_module_name) : b("b"), c("c") 45 { 46 } 30 31 struct A : sc_module { 32 B b; 33 C c; 34 A(sc_module_name) : b("b"), c("c") {} 47 35 }; 48 36 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 } 37 38 struct top_level1 : sc_module { 39 A a; 40 D d; 41 top_level1(sc_module_name) : a("a"), d("d") {} 56 42 }; 57 43 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 } 44 45 struct top_level2 : sc_module { 46 B b1; 47 B b2; 48 C c; 49 top_level2(sc_module_name) : b1("b1"), b2("b2"), c("c") {} 66 50 }; 67 51 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; 52 53 void dump_hierarchy(ostream & o, sc_object * obj) { 54 const vector<sc_object *> & children = obj->get_child_objects(); 55 for (unsigned i = 0; i < children.size(); i++) { 56 if (children[i]) { 57 dump_hierarchy(o, children[i]); 58 } 59 } 60 o << obj->name() << " " << obj->kind() << endl; 76 61 } 77 62 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]);63 64 void dump_hierarchy (ostream & o, const vector<sc_object *> & obj_list) { 65 for (unsigned i = 0; i < obj_list.size(); i++) { 66 dump_hierarchy(o, obj_list[i]); 67 } 83 68 } 84 69 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 70 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 } 71 int sc_main (int argc, char ** argv) { 72 if (argc < 2) { 73 cerr << "Usage : " << argv[0] << " <filename>\n"; 74 exit(-1); 75 } 105 76 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 0 133 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 else 148 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 else 154 o << "top1 has a parent.\n"; 155 #endif 77 sc_clock clk("clock"); 78 top_level1 top1("top1"); 79 top_level2 top2("top2"); 156 80 157 o.close (); 81 ofstream o; 82 o.open(argv[1],ios::out | ios::trunc); 83 if (!o.is_open()) { 84 cerr << "Unable to open '" << argv[1] << "'.\n"; 85 return 1; 86 } 158 87 159 return 0; 88 sc_start(sc_time(0, sc_core::SC_NS)); 89 dump_hierarchy(o, sc_get_top_level_objects()); 90 91 ASSERT(sc_find_object("top2.b1" ) == &top2.b1 ); 92 ASSERT(sc_find_object("top2.b1.d1" ) == &top2.b1.d1 ); 93 ASSERT(sc_find_object("top2.b1.d2" ) == &top2.b1.d2 ); 94 ASSERT(sc_find_object("top2.b1.c" ) == &top2.b1.c ); 95 ASSERT(sc_find_object("top2.b2" ) == &top2.b2 ); 96 ASSERT(sc_find_object("top2.c" ) == &top2.c ); 97 ASSERT(sc_find_object("top1.a" ) == &top1.a ); 98 ASSERT(sc_find_object("top1.d" ) == &top1.d ); 99 ASSERT(sc_find_object("top1.a.b" ) == &top1.a.b ); 100 ASSERT(sc_find_object("top1.a.b.d1") == &top1.a.b.d1); 101 ASSERT(sc_find_object("top1.a.b.d2") == &top1.a.b.d2); 102 ASSERT(sc_find_object("top1.a.b.c" ) == &top1.a.b.c ); 103 ASSERT(sc_find_object("top1.a.c" ) == &top1.a.c ); 104 ASSERT(sc_find_object("top1.c" ) == NULL ); 105 ASSERT(sc_find_object("top1" )->get_parent_object() == NULL); 106 ASSERT(sc_find_object("top1.a" )->get_parent_object() == &top1); 107 ASSERT(sc_find_object("top1.a.b" )->get_parent_object() == &top1.a); 108 ASSERT(sc_find_object("top1.a.b.d2")->get_parent_object() == &top1.a.b); 109 ASSERT(sc_find_object("top1.d" )->get_parent_object() == &top1); 110 ASSERT(sc_find_object("top2.b1" )->get_parent_object() == &top2); 111 ASSERT(sc_find_object("top2.b2" )->get_parent_object() == &top2); 112 ASSERT(sc_find_object("top2.c" )->get_parent_object() == &top2); 113 ASSERT(sc_find_object("top2.b1.c" )->get_parent_object() == &top2.b1); 114 115 o.close(); 116 117 return 0; 160 118 } 161 119 120 121 /* 122 # Local Variables: 123 # tab-width: 4; 124 # c-basic-offset: 4; 125 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 126 # indent-tabs-mode: nil; 127 # End: 128 # 129 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 130 */ 131
Note: See TracChangeset
for help on using the changeset viewer.