Changeset 55 for sources/test_regression/09092005c
- Timestamp:
- May 28, 2013, 11:17:14 AM (11 years ago)
- Location:
- sources/test_regression/09092005c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/test_regression/09092005c/Makefile
r15 r55 1 1 2 include ../env.mk 3 include ../Makefile.common 2 4 3 SYSTEM = system.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) 5 test: all 6 @echo -ne "| Testing $$(basename $$(pwd)): " ; 7 @./$(EXE_SCASS) > $(LOG_SCASS) 2> /dev/null 8 @./$(EXE_SC) > $(LOG_SC) 2> /dev/null 9 @if diff $(LOG_SC) $(LOG_SCASS) > /dev/null ; then \ 10 echo "OK" ; \ 11 else echo "KO" ; \ 12 fi ; 10 13 11 .SECONDARY:12 14 13 main : $(EXE)14 15 test : $(EXE_SCASS) ${EXE_SC}16 @for i in ${EXE_SCASS} ${EXE_SC} ; do \17 echo Testing $$i... ; \18 ./$$i || eval ${failcom} ; \19 done;20 21 %.gif : %.dot22 dot -Tgif -o $*.gif $*.dot23 24 %_systemc.x : %_systemc.o $(SYSTEMC_LIB)25 $(CXX) -o $@ $*_systemc.o $(LFLAGS_SYSTEMC) 2>&1 | $(CPPFILT)26 27 %_systemcass.x : %_systemcass.o $(SYSTEMCASS_LIB)28 $(CXX) -o $@ $*_systemcass.o $(LFLAGS_SYSTEMCASS) 2>&1 | $(CPPFILT)29 30 -include Makefile.deps31 32 %_systemc.cpp : %.cpp33 ln -s $*.cpp $*_systemc.cpp34 35 %_systemcass.cpp : %.cpp36 ln -s $*.cpp $*_systemcass.cpp37 38 %_systemc.o : %_systemc.cpp39 $(CXX) $(CFLAGS_SYSTEMC) -MM $*_systemc.cpp >> Makefile.deps40 $(CXX) $(CFLAGS_SYSTEMC) -c $*_systemc.cpp -o $*_systemc.o41 42 %_systemcass.o : %_systemcass.cpp43 $(CXX) $(CFLAGS_SYSTEMCASS) -MM $*_systemcass.cpp >> Makefile.deps44 $(CXX) $(CFLAGS_SYSTEMCASS) -c $*_systemcass.cpp -o $*_systemcass.o45 46 clean :47 rm -f Makefile.deps48 -rm -f *.o gmon.out *~49 -rm -f ${LOG}50 -rm -f signal_order.txt module_order.dot signal_graph.dot51 -rm -f module_order.gif signal_graph.gif52 -rm -f $(EXE) $(OBJECTS)53 -for i in $(LINKS) ; do unlink $$i ; done 2> /dev/null54 -rm -f core*55 -rm -rf generated_by_systemcass56 -rm -rf system_systemcass.x.vcd system_systemc.x.vcd57 -
sources/test_regression/09092005c/system.cpp
r1 r55 1 1 2 #include "systemc.h" 3 2 4 #include <iostream> 5 6 #include "test.h" 3 7 4 8 using namespace std; 5 9 6 #define ASSERT(x) \7 { errnum++; \8 if (!(x)) \9 { \10 cerr << "ASSERT : " #x "\n"; \11 exit (errnum); \12 } \13 }14 10 15 using namespace std; 11 struct observer : sc_module { 12 sc_in_clk clk; 16 13 17 struct observer : sc_module 18 { 19 sc_in_clk clk; 14 sc_in<int> i; 20 15 21 sc_in<int> i;16 void f() {} 22 17 23 void f () 24 { 25 #if 0 26 cerr << i.read(); 27 #endif 28 } 29 30 SC_HAS_PROCESS(observer); 31 observer(sc_module_name) : clk ("clk"), 32 i ("i") 33 34 { 35 SC_METHOD(f); 36 dont_initialize(); 37 sensitive << clk.pos(); 38 #ifdef SYSTEMCASS_SPECIFIC 39 #endif 40 } 18 SC_HAS_PROCESS(observer); 19 observer(sc_module_name) : clk ("clk"), 20 i("i") { 21 SC_METHOD(f); 22 sensitive << clk.pos(); 23 dont_initialize(); 24 } 41 25 }; 42 26 43 struct generator : sc_module44 {45 sc_in_clk clk;46 27 47 sc_out<int> o; 28 struct generator : sc_module { 29 sc_in_clk clk; 30 sc_out<int> o; 48 31 49 void f () 50 { 51 int t = (int) (sc_time_stamp ().to_double()); 52 #if 0 53 cerr << "f = " << t << endl; 54 #endif 55 o.write(t); 56 } 32 void f() { 33 int t = (int) (sc_time_stamp().to_double()); 34 o.write(t); 35 } 57 36 58 SC_HAS_PROCESS(generator); 59 generator(sc_module_name) : clk ("clk"), 60 o ("o") 61 { 62 SC_METHOD(f); 63 dont_initialize(); 64 sensitive << clk.neg(); 65 #ifdef SYSTEMCASS_SPECIFIC 66 #endif 67 } 37 SC_HAS_PROCESS(generator); 38 generator(sc_module_name) : clk("clk"), o("o") { 39 SC_METHOD(f); 40 sensitive << clk.neg(); 41 dont_initialize(); 42 } 43 68 44 }; 69 45 70 struct top_level : sc_module71 {72 sc_in_clk clk;73 74 sc_out<int> o;75 // sc_out<int> io;76 // sc_signal<int> s;77 // sc_signal<int> s2;78 46 79 generator g;80 observer obs1, obs2;81 82 SC_HAS_PROCESS(top_level);83 top_level(sc_module_name) : g ("generator"),84 obs1("observer1"),85 obs2("observer2"),86 clk ("clk"),87 o ("o")/*,88 s ("s")*/89 {90 g.clk (clk);91 obs1.clk (clk);92 obs2.clk (clk);93 47 94 g.o (o); 95 obs1.i(o); 96 obs2.i(o); 97 } 48 struct top_level : sc_module { 49 sc_in_clk clk; 50 51 sc_out<int> o; 52 53 generator g; 54 observer obs1, obs2; 55 56 SC_HAS_PROCESS(top_level); 57 top_level(sc_module_name) : 58 clk("clk"), 59 o("o"), 60 g("generator"), 61 obs1("observer1"), 62 obs2("observer2"){ 63 g.clk(clk); 64 obs1.clk(clk); 65 obs2.clk(clk); 66 67 g.o(o); 68 obs1.i(o); 69 obs2.i(o); 70 } 71 98 72 }; 99 73 100 int101 sc_main (int argc, char ** argv)102 {103 int errnum = 0;104 sc_clock clk("top_clk");105 sc_signal<int> out("top_out");106 74 107 top_level t("top_level"); 75 int sc_main (int argc, char ** argv) { 76 sc_clock clk("top_clk"); 77 sc_signal<int> out("top_out"); 108 78 109 t.clk (clk); 110 t.o (out); 79 top_level t("top_level"); 111 80 81 t.clk(clk); 82 t.o (out); 83 84 // QM : pourquoi est-ce tout commenté ?? 112 85 #if 0 113 /* Open trace file */ 114 sc_trace_file *system_trace_file; 115 system_trace_file = sc_create_vcd_trace_file ("trace_file"); 116 117 /* clks waveforms are always useful */ 118 sc_trace(system_trace_file, clk1, "clk1"); 119 sc_trace(system_trace_file, clk2, "clk2"); 86 /* Open trace file */ 87 sc_trace_file *system_trace_file; 88 system_trace_file = sc_create_vcd_trace_file ("trace_file"); 120 89 121 /* others signals */ 122 for (int i = 0; i < 10; ++i) 123 sc_trace(system_trace_file, s[i], sc_gen_unique_name ("s")); 90 /* clks waveforms are always useful */ 91 sc_trace(system_trace_file, clk1, "clk1"); 92 sc_trace(system_trace_file, clk2, "clk2"); 93 94 /* others signals */ 95 for (int i = 0; i < 10; ++i) 96 sc_trace(system_trace_file, s[i], sc_gen_unique_name ("s")); 124 97 #endif 125 98 126 /* initilization */ 127 #if 0 128 cout << "initilization...\n"; 129 #endif 130 sc_initialize (); 99 sc_start(sc_time(0, sc_core::SC_NS)); 131 100 132 /* simulation */ 133 #if 0 134 cout << "simulation...\n"; 135 #endif 136 int i = 0; 137 while (i++ < 5) 138 { 139 sc_start (1); 140 ASSERT(out.read() == t.obs1.i.read()) 141 ASSERT(out.read() == t.obs2.i.read()) 142 } 143 144 #if 0 145 cout << "\ndone.\n"; 146 #endif 147 148 return 0; 101 /* simulation */ 102 int i = 0; 103 while (i++ < 5) { 104 sc_start(sc_time(1, sc_core::SC_NS)); 105 cout << out.read() << " - " << t.obs1.i.read() << " - " << t.obs2.i.read() << endl; 106 } 107 return 0; 149 108 } 150 109 110 111 /* 112 # Local Variables: 113 # tab-width: 4; 114 # c-basic-offset: 4; 115 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 116 # indent-tabs-mode: nil; 117 # End: 118 # 119 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 120 */ 121
Note: See TracChangeset
for help on using the changeset viewer.