Changeset 55 for sources/test_regression/28102005
- Timestamp:
- May 28, 2013, 11:17:14 AM (11 years ago)
- Location:
- sources/test_regression/28102005
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/test_regression/28102005/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 : main16 @./system_systemcass.x || eval ${failcom}17 18 %.gif : %.dot19 dot -Tgif -o $*.gif $*.dot20 21 %_systemc.x : %_systemc.o $(SYSTEMC_LIB)22 $(CXX) -o $@ $*_systemc.o $(LFLAGS_SYSTEMC) 2>&1 | $(CPPFILT)23 24 %_systemcass.x : %_systemcass.o $(SYSTEMCASS_LIB)25 $(CXX) -o $@ $*_systemcass.o $(LFLAGS_SYSTEMCASS) 2>&1 | $(CPPFILT)26 27 -include Makefile.deps28 29 %_systemc.cpp : %.cpp30 ln -s $*.cpp $*_systemc.cpp31 32 %_systemcass.cpp : %.cpp33 ln -s $*.cpp $*_systemcass.cpp34 35 %_systemc.o : %_systemc.cpp36 $(CXX) $(CFLAGS_SYSTEMC) -Wno-deprecated -MM $*_systemc.cpp >> Makefile.deps37 $(CXX) $(CFLAGS_SYSTEMC) -Wno-deprecated -c $*_systemc.cpp -o $*_systemc.o38 39 %_systemcass.o : %_systemcass.cpp40 $(CXX) $(CFLAGS_SYSTEMCASS) -MM $*_systemcass.cpp >> Makefile.deps41 $(CXX) $(CFLAGS_SYSTEMCASS) -c $*_systemcass.cpp -o $*_systemcass.o42 43 clean :44 rm -f Makefile.deps45 -rm -f *.o gmon.out *~46 -rm -f ${LOG}47 -rm -f signal_order.txt module_order.dot signal_graph.dot48 -rm -f module_order.gif signal_graph.gif49 -rm -f $(EXE) $(OBJECTS)50 -for i in $(LINKS) ; do unlink $$i ; done 2> /dev/null51 -rm -f core*52 -rm -rf generated_by_systemcass53 -rm -rf system_systemcass.x.vcd system_systemc.x.vcd54 -
sources/test_regression/28102005/system.cpp
r35 r55 1 #include <systemc.h> 1 2 2 #include <iostream> 3 3 #include <cstring> 4 4 5 #define ASSERT(x) \ 6 { errnum++; \ 7 if (!(x)) \ 8 { \ 9 cerr << "ASSERT : " #x "\n"; \ 10 exit (errnum); \ 11 } \ 12 } 13 14 #ifdef DEBUG 15 #define CERR(x) \ 16 { cerr << "" #x " = " << x << "\n"; } 17 #else 18 #define CERR(x) 19 #endif 5 #include "systemc.h" 6 #include "test.h" 20 7 21 8 22 9 using namespace std; 23 10 24 static int errnum = 0;25 11 26 void 27 check_time (int i) 28 { 29 const sc_time &t = sc_time_stamp (); 30 CERR(i); 31 CERR(t.to_double()); 12 void check_time(int i) { 13 const sc_time & t = sc_time_stamp(); 14 cout << i << endl; 15 32 16 #ifdef SYSTEMCASS_SPECIFIC 33 ASSERT((int) (t.to_double()) == i);17 ASSERT((int) (t.to_double()) == i); 34 18 #else 35 ASSERT((int) (t.to_double()) == i * 1000);19 ASSERT((int) (t.to_double()) == i * 1000); 36 20 #endif 37 CERR(t.to_seconds ()); 38 double seconds = t.to_seconds()*1000000000; 39 CERR(seconds); 40 ASSERT(((int)seconds) == i); 41 char s[256]; 42 const char *unit; 21 22 cout << t.to_seconds() << endl; 23 double seconds = t.to_seconds() * 1000000000; 24 cout << seconds << endl; 25 ASSERT(((int) seconds) == i); 26 char s[256]; 27 const char * unit; 28 43 29 #ifdef SYSTEMCASS_SPECIFIC 44 unit = "NS";30 unit = "NS"; 45 31 #else 46 if (i == 0)47 unit = "s";48 else if (i < 1000)49 unit = "ns";50 else51 unit = "ns";32 if (i == 0) { 33 unit = "s"; 34 } 35 else { 36 unit = "ns"; 37 } 52 38 #endif 53 sprintf (s, "%d %s", i,unit); 54 CERR(s);55 CERR(t.to_string()); 56 ASSERT(strcmp (t.to_string ().c_str(), s)== 0);39 40 sprintf(s, "%d %s", i, unit); 41 42 ASSERT(strcmp(t.to_string().c_str(), s) == 0); 57 43 } 58 44 59 int60 sc_main (int argc, char ** argv)61 {62 sc_clock clk ("clock");63 45 64 check_time (0); 65 sc_start (0);46 int sc_main (int argc, char ** argv) { 47 sc_clock clk("clock"); 66 48 67 check_time (0); 68 sc_start (1); 69 check_time (1); 49 check_time(0); 50 sc_start(sc_time(0, sc_core::SC_NS)); 70 51 71 sc_start (15); 72 check_time (16); 52 check_time(0); 53 sc_start(sc_time(1, sc_core::SC_NS)); 54 check_time(1); 73 55 74 sc_start (7);75 check_time (23);56 sc_start(sc_time(15, sc_core::SC_NS)); 57 check_time(16); 76 58 77 sc_start (100);78 check_time (123);59 sc_start(sc_time(7, sc_core::SC_NS)); 60 check_time(23); 79 61 80 sc_start (1000); 81 check_time (1123); 82 cerr << "Test OK.\n"; 83 return 0; 62 sc_start(sc_time(100, sc_core::SC_NS)); 63 check_time(123); 64 65 sc_start(sc_time(1000, sc_core::SC_NS)); 66 check_time(1123); 67 68 return 0; 84 69 } 85 70 71 72 /* 73 # Local Variables: 74 # tab-width: 4; 75 # c-basic-offset: 4; 76 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 77 # indent-tabs-mode: nil; 78 # End: 79 # 80 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 81 */ 82
Note: See TracChangeset
for help on using the changeset viewer.