Changeset 55 for sources/test_regression/02052006
- Timestamp:
- May 28, 2013, 11:17:14 AM (11 years ago)
- Location:
- sources/test_regression/02052006
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/test_regression/02052006/Makefile
r13 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} 7 OBJECTS = $(EXE:.x=.o) 8 LINKS = $(OBJECTS:.o=.cpp) 5 test: all 6 @echo -ne "| Testing $$(basename $$(pwd)): " ; 7 @./$(EXE_SCASS) --p > $(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 -e "$(OK)" ; \ 11 else \ 12 echo -e "$(KO)" ; \ 13 fi ; 9 14 10 .SECONDARY:11 12 main : $(EXE)13 14 test : main15 @./system_systemcass.x --p || eval ${failcom}16 17 %.gif : %.dot18 dot -Tgif -o $*.gif $*.dot19 20 %_systemc.x : %_systemc.o $(SYSTEMC_LIB)21 $(CXX) -o $@ $*_systemc.o $(LFLAGS_SYSTEMC)22 23 %_systemcass.x : %_systemcass.o $(SYSTEMCASS_LIB)24 $(CXX) -o $@ $*_systemcass.o $(LFLAGS_SYSTEMCASS)25 26 %_socview.x : %_socview.o $(SOCVIEW_LIB)27 $(CXX) -o $@ $*_socview.o $(LFLAGS_SOCVIEW)28 29 -include Makefile.deps30 31 %_systemc.cpp : %.cpp32 ln -s $*.cpp $*_systemc.cpp33 34 %_systemcass.cpp : %.cpp35 ln -s $*.cpp $*_systemcass.cpp36 37 %_socview.cpp : %.cpp38 ln -s $*.cpp $*_socview.cpp39 40 %_systemc.o : %_systemc.cpp41 $(CXX) $(CFLAGS_SYSTEMC) -MM $*_systemc.cpp >> Makefile.deps42 $(CXX) $(CFLAGS_SYSTEMC) -c $*_systemc.cpp -o $*_systemc.o43 44 %_systemcass.o : %_systemcass.cpp45 $(CXX) $(CFLAGS_SYSTEMCASS) -DCHECK_MULTIWRITE -MM $*_systemcass.cpp >> Makefile.deps46 $(CXX) $(CFLAGS_SYSTEMCASS) -DCHECK_MULTIWRITE -c $*_systemcass.cpp -o $*_systemcass.o47 48 %_socview.o : %_socview.cpp49 $(CXX) $(CFLAGS_SOCVIEW) -MM $*_socview.cpp >> Makefile.deps50 $(CXX) $(CFLAGS_SOCVIEW) -c $*_socview.cpp -o $*_socview.o51 52 clean :53 -rm -f Makefile.deps54 -rm -f gmon.out *~55 -rm -f $(EXE) $(OBJECTS)56 -for i in $(LINKS) ; do unlink $$i ; done 2> /dev/null57 -rm -f core*58 -rm -rf generated_by_systemcass59 -
sources/test_regression/02052006/system.cpp
r23 r55 1 1 2 #include <systemc.h> 3 #include <typeinfo> 2 4 3 # define ASSERT(x) \4 { \ 5 if (!(x)) \ 6 { \ 7 cerr << "ASSERT : " #x "\n"; \ 8 exit (1); \ 9 } \ 10 } 5 #include "test.h" 6 7 8 // Tests deactivated (not supported in SystemCass): 9 // - sc_signal applied to float values (QM) 10 // Tests failing: 11 // - sc_int<X> with X different from 16, 32 and 64 12 11 13 12 14 using namespace std; 13 15 14 16 struct test : sc_module { 15 int32_t reg; 16 sc_signal<bool> reg_bool; 17 sc_signal<int> reg_int; 18 sc_signal<unsigned int> reg_unsigned_int; 19 sc_signal<char> reg_char; 20 sc_signal<double> reg_double; 21 sc_signal<long> reg_long; 22 sc_signal<sc_uint<32> > reg_ui32; 23 sc_signal<sc_uint<16> > reg_ui16; 24 sc_signal<sc_uint<6> > reg_ui6; 25 sc_signal<sc_int<32> > reg_i32; 26 sc_signal<sc_int<16> > reg_i16; 27 sc_signal<sc_int<6> > reg_i6; 28 29 sc_in_clk clk; 30 sc_in<bool> resetn; 17 int32_t reg; 18 sc_signal<bool> reg_bool; 19 sc_signal<int> reg_int; 20 sc_signal<unsigned int> reg_unsigned_int; 21 sc_signal<char> reg_char; 22 #ifdef ALL_TESTS 23 sc_signal<float> reg_float; 24 sc_signal<double> reg_double; 25 #endif 26 sc_signal<long> reg_long; 27 sc_signal< sc_uint<32> > reg_ui32; 28 sc_signal< sc_uint<16> > reg_ui16; 29 sc_signal< sc_uint<6> > reg_ui6; 30 sc_signal< sc_int<32> > reg_i32; 31 sc_signal< sc_int<16> > reg_i16; 32 sc_signal< sc_int<6> > reg_i6; 33 sc_in<bool> clk; 34 sc_in<bool> resetn; 31 35 32 void trans () 33 { 34 if (resetn.read() == true) 35 { 36 ASSERT(((reg & 1)) == reg_bool .read()); 37 ASSERT(((int) reg) == reg_int .read()); 38 ASSERT(((unsigned int)reg) == reg_unsigned_int .read()); 39 ASSERT(((char) reg) == reg_char .read()); 40 #if 0 41 cout << (double)reg << " " << reg_double.read() << endl; 42 cout << sizeof (double) << " " << sizeof (reg_double.read()) << endl; 36 void trans() { 37 if (resetn.read() == true) { 38 //ASSERT(((reg & 1)) == reg_bool.read()); 39 //ASSERT(((int) reg) == reg_int.read()); 40 //ASSERT(((unsigned int) reg) == reg_unsigned_int.read()); 41 //ASSERT(((char) reg) == reg_char.read()); 42 #ifdef ALL_TEST 43 //ASSERT(((float) reg) == reg_float.read()); 44 //ASSERT(((double) reg) == reg_double.read()); 43 45 #endif 44 ASSERT(((double)reg) == reg_double.read()); 45 ASSERT(((long) reg) == reg_long .read()); 46 ASSERT(((unsigned int) reg & 0xFFFFFFFF) == (unsigned int) (reg_ui32 .read())); 47 ASSERT(((unsigned int) reg & 0x0000FFFF) == (unsigned int) (reg_ui16 .read())); 48 #if 0 49 cerr << reg_ui6.read() << " " << (reg & 0x0000003F) << endl; 46 //ASSERT(((long) reg) == reg_long.read()); 47 //ASSERT(((unsigned int) reg & 0xFFFFFFFF) == (unsigned int) (reg_ui32.read())); 48 //ASSERT(((unsigned int) reg & 0x0000FFFF) == (unsigned int) (reg_ui16.read())); 49 //ASSERT(((unsigned int) reg & 0x0000003F) == (unsigned int) (reg_ui6.read())); 50 //ASSERT(((signed int) (reg & 0xFFFFFFFF)) == (signed int) (reg_i32.read())); 51 //ASSERT(((signed int) (reg & 0x0000FFFF)) == (signed int) (reg_i16.read())); 52 //cout << "reg & 0x3F : " << (signed int) (reg & 0x3F) << endl; 53 //cout << "reg_i6 : " << reg_i6.read() << endl; 54 //ASSERT(((reg & 0x3F) < 32 && ((signed int) (reg & 0x3F)) == (signed int) (reg_i6.read())) || ((reg & 0x3F) >= 32 && (signed int) (reg & 0x3F) != (signed int) (reg_i6.read()))); 55 cout << "reg_bool : " << reg_bool << endl; 56 cout << "reg_int : " << reg_int << endl; 57 cout << "reg_unsigned_int : " << reg_unsigned_int << endl; 58 cout << "reg_char : " << (unsigned int) reg_char << endl; 59 #ifdef ALL_TESTS 60 cout << "reg_float : " << reg_float << endl; 61 cout << "reg_double : " << reg_double << endl; 50 62 #endif 51 ASSERT(((unsigned int) reg & 0x0000003F) == (unsigned int) (reg_ui6 .read())); 52 ASSERT(((signed int) reg & 0xFFFFFFFF) == (signed int) (reg_i32 .read())); 53 ASSERT(((signed int) reg & 0x0000FFFF) == (signed int) (reg_i16 .read())); 54 ASSERT(((signed int) reg & 0x0000003F) == (signed int) (reg_i6 .read())); 55 reg = reg + 1; 56 reg_bool = reg & 1; 57 reg_int = reg; 58 reg_unsigned_int = reg; 59 reg_char = reg; 60 reg_double .write(reg); 61 reg_long = reg; 62 reg_ui32 = reg; 63 reg_ui16 = reg; 64 reg_ui6 = reg; 65 reg_i32 = reg; 66 reg_i16 = reg; 67 reg_i6 = reg; 68 } else { 69 reg = 0; 70 reg_bool = 0; 71 reg_int = 0; 72 reg_unsigned_int = 0; 73 reg_char = 0; 74 reg_double = 0; 75 reg_long = 0; 76 reg_ui32 = 0; 77 reg_ui16 = 0; 78 reg_ui6 = 0; 79 reg_i32 = 0; 80 reg_i16 = 0; 81 reg_i6 = 0; 63 cout << "reg_long : " << reg_long << endl; 64 cout << "reg_ui32 : " << reg_ui32 << endl; 65 cout << "reg_ui16 : " << reg_ui16 << endl; 66 cout << "reg_ui6 : " << reg_ui6 << endl; 67 cout << "reg_i32 : " << reg_i32 << endl; 68 cout << "reg_i16 : " << reg_i16 << endl; 69 cout << "reg_i6 : " << reg_i6 << endl; 70 71 reg = reg + 1; 72 reg_bool = reg & 1; 73 reg_int = reg; 74 reg_unsigned_int = reg; 75 reg_char = reg; 76 #ifdef ALL_TESTS 77 reg_float.write(reg); 78 reg_double.write(reg); 79 #endif 80 reg_long = reg; 81 reg_ui32 = reg; 82 reg_ui16 = reg; 83 reg_ui6 = reg; 84 reg_i32 = reg; 85 reg_i16 = reg; 86 reg_i6 = reg; 87 } 88 else { 89 reg = 0; 90 reg_bool = 0; 91 reg_int = 0; 92 reg_unsigned_int = 0; 93 reg_char = 0; 94 #ifdef ALL_TESTS 95 reg_float = 0; 96 reg_double = 0; 97 #endif 98 reg_long = 0; 99 reg_ui32 = 0; 100 reg_ui16 = 0; 101 reg_ui6 = 0; 102 reg_i32 = 0; 103 reg_i16 = 0; 104 reg_i6 = 0; 105 } 82 106 } 83 }84 107 85 SC_HAS_PROCESS(test);86 test 87 clk("clk") 88 {89 SC_METHOD(trans);90 sensitive << clk.pos();91 dont_initialize();92 }; 108 SC_HAS_PROCESS(test); 109 test(sc_module_name n) : sc_module (n), 110 clk("clk") { 111 SC_METHOD(trans); 112 sensitive << clk.pos(); 113 dont_initialize(); 114 } 115 93 116 }; 94 117 95 int sc_main (int argc, char *argv[])96 {97 sc_clock signal_clk("my_clock",1, 0.5);98 sc_signal<bool> resetn("resetn");99 118 100 test test1("test1"); 101 test1.clk (signal_clk);102 test1.resetn (resetn);119 int sc_main (int argc, char * argv[]) { 120 sc_clock signal_clk("my_clock", sc_time(1, sc_core::SC_NS)); 121 sc_signal<bool> resetn("resetn"); 103 122 104 // Init & run 105 sc_start (0); 123 test test1("test1"); 124 test1.clk(signal_clk); 125 test1.resetn(resetn); 106 126 107 resetn = false; 108 sc_start (4); 109 resetn = true; 110 sc_start (100); 127 // Init & run 128 sc_start(sc_time(0, sc_core::SC_NS)); 111 129 112 return EXIT_SUCCESS; 130 resetn = false; 131 sc_start(sc_time(4, sc_core::SC_NS)); 132 resetn = true; 133 sc_start(sc_time(100, sc_core::SC_NS)); 134 135 return EXIT_SUCCESS; 113 136 } 114 137 115 138 #undef sc_inout 139 140 /* 141 # Local Variables: 142 # tab-width: 4; 143 # c-basic-offset: 4; 144 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 145 # indent-tabs-mode: nil; 146 # End: 147 # 148 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 149 */ 150
Note: See TracChangeset
for help on using the changeset viewer.