Ignore:
Timestamp:
May 28, 2013, 11:17:14 AM (11 years ago)
Author:
meunier
Message:

Tried to clean the test_regression directory:

  • Code formatting
  • Supressed warnings
  • Made comprehensible outputs
  • Factorized Makefiles

There's still a lot to do (many tests don't pass for either good or bad reasons)

Location:
sources/test_regression/17032005
Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • sources/test_regression/17032005/Makefile

    r35 r55  
     1
    12include ../env.mk
     3TRACE1 = trace_file_scass.vcd
     4TRACE2 = trace_file_systemc.vcd
     5ERASE = $(TRACE1) $(TRACE2)
     6include ../Makefile.common
    27
    3 EXE     = system_systemc.x system_systemcass.x
    4 OBJECTS = $(EXE:.x=.o)
    5 LINKS   = $(OBJECTS:.o=.cpp)
     8TRACE = trace_file.vcd
     9TRACE_REF = trace_file_reference.vcd
    610
    7 .SECONDARY:
     11test: all
     12        @echo -ne "| Testing $$(basename $$(pwd)): " ;
     13        @./$(EXE_SCASS) > $(LOG_SCASS) 2> /dev/null
     14        @mv $(TRACE) $(TRACE1)
     15        @./$(EXE_SC) > $(LOG_SC) 2> /dev/null
     16        @mv $(TRACE) $(TRACE2)
     17        @if tail -n +8 $(TRACE1) | diff $(TRACE_REF) - > /dev/null ; then \
     18                if tail -n +8 $(TRACE2) | diff $(TRACE_REF) - > /dev/null ; then \
     19                        echo "OK" ; \
     20                else \
     21                        echo "KO" ; \
     22                fi ; \
     23        else \
     24                echo "KO" ; \
     25        fi ;
    826
    9 main : $(EXE)
    1027
    11 test : system-23.vcd system-23_reference.vcd
    12         -diff system-23.vcd system-23_reference.vcd
    13         @echo Test OK.
    1428
    15 system-23.vcd : system_systemcass.x
    16         ./system_systemcass.x --nodynamiclink system 23
    17         tail -n +8 system.vcd > system-23.vcd
    18         rm system.vcd
    19 
    20 system-23_reference.vcd : system_systemc.x
    21         ./system_systemc.x system 23
    22         tail -n +8 system.vcd > system-23_reference.vcd
    23         rm system.vcd
    24 
    25 %_systemc.x : %_systemc.o $(SYSTEMC_LIB)
    26         $(CXX) -o $@ $*_systemc.o $(LFLAGS_SYSTEMC)
    27 
    28 %_systemcass.x : %_systemcass.o  $(SYSTEMCASS_LIB)
    29         $(CXX) -o $@ $*_systemcass.o $(LFLAGS_SYSTEMCASS)
    30 
    31 -include Makefile.deps
    32 
    33 %_systemc.cpp : %.cpp
    34         ln -s $*.cpp $*_systemc.cpp
    35 
    36 %_systemcass.cpp : %.cpp
    37         ln -s $*.cpp $*_systemcass.cpp
    38 
    39 %_systemc.o : %_systemc.cpp
    40         $(CXX) $(CFLAGS_SYSTEMC) -MM $*_systemc.cpp >> Makefile.deps
    41         $(CXX) $(CFLAGS_SYSTEMC) -c $*_systemc.cpp -o $*_systemc.o
    42 
    43 %_systemcass.o : %_systemcass.cpp
    44         $(CXX) $(CFLAGS_SYSTEMCASS) -MM $*_systemcass.cpp >> Makefile.deps
    45         $(CXX) $(CFLAGS_SYSTEMCASS) -c $*_systemcass.cpp -o $*_systemcass.o
    46 
    47 clean :
    48         rm -f Makefile.deps
    49         -rm -f *.o gmon.out
    50         -rm -f *.txt
    51         -rm -f $(EXE) $(OBJECTS)
    52         -for i in $(LINKS) ; do unlink $$i ; done 2> /dev/null
    53         -rm -f core*
    54         -rm -f *~
    55         -rm -rf generated_by_systemcass
    56         -rm -rf trace_system_systemcass.x.vcd trace_system_systemc.x.vcd
    57         -rm -rf system-23.vcd
    58         -rm -rf system_systemcass.log
    59        
  • sources/test_regression/17032005/system.cpp

    r35 r55  
    1 #include <systemc.h>
    21#include <signal.h>
    32#include <iostream>
     
    54#include <cstdlib> //exit
    65
    7 #define ASSERT(x) \
    8   { \
    9     if (!(x)) \
    10     { \
    11     cerr << "ASSERT : '" #x "' at cycle number " << sc_simulation_time () << "\n"; \
    12     exit (1); \
    13     } \
    14   }
     6#include "systemc.h"
     7#include "test.h"
    158
    169using namespace std;
    17        
    18 struct sc_test : public sc_module
    19 {
    20   sc_in<bool>     clk;
    21   sc_in<bool>     resetn;
    22   sc_signal<sc_uint<6>     > ui6;
    23   sc_signal<sc_uint<16>    > ui16;
    24   sc_signal<sc_uint<31>    > ui31;
    25   sc_signal<sc_uint<32>    > ui32;
    26   sc_signal<sc_uint<64>    > ui64;
    27   sc_signal<sc_int<6>      > i6;
    28   sc_signal<sc_int<16>     > i16;
    29   sc_signal<sc_int<31>     > i31;
    30   sc_signal<sc_int<32>     > i32;
    31   sc_signal<sc_int<64>     > i64;
    3210
    33   unsigned int ui6_c_type :6;
    34   sc_uint<6>   ui6_sc_uint;
    35 //  sc_signal<sc_biguint<64> > bui64;
    36 //  long long unsigned int     bui64b;
    37 //  sc_signal<sc_biguint<96> > bui96;
     11struct sc_test : public sc_module {
     12    sc_in<bool> clk;
     13    sc_in<bool> resetn;
     14    sc_signal<sc_uint<6> >  ui6;
     15    sc_signal<sc_uint<16> > ui16;
     16    sc_signal<sc_uint<31> > ui31;
     17    sc_signal<sc_uint<32> > ui32;
     18    sc_signal<sc_uint<64> > ui64;
     19    sc_signal<sc_int<6> > i6;
     20    sc_signal<sc_int<16> > i16;
     21    sc_signal<sc_int<31> > i31;
     22    sc_signal<sc_int<32> > i32;
     23    sc_signal<sc_int<64> > i64;
    3824
    39   void eval ()
    40   {
    41     if (resetn == false)
    42     {
    43       ui6   = 0xF; ui6_c_type = 0xF; ui6_sc_uint = 0xF;
    44       ui16  = 0x3F;
    45       ui31  = 0x100;
    46       ui32  = 0x211;
    47       ui64  = 0xABCF1234ULL;
    48       i6    = 0xF;
    49       i16   = 0x3F;
    50       i31   = 0x11112222;
    51       i32   = 0x43214321;
    52       i64   = 0x4444abcdULL;
    53 //      bui64 = 0xFFFFFFFF;
    54 //      bui64b= 0xFFFFFFFF;
    55 //      bui96 = 0xABCDEF01;
    56     } else {
    57       cerr << hex << ui6.read () << " "
    58                   << ui6_c_type  << " "
    59                   << ui6_sc_uint << endl;
    60       ASSERT(ui6.read() == ui6_c_type);
    61       ui6         = (ui6   .read() * 2) + 1;
    62       ui6_c_type  = (ui6_c_type    * 2) + 1;
    63       ui6_sc_uint = (ui6_sc_uint   * 2) + 1;
    64       ui16  = (ui16  .read() * 2) + 1;
    65       ui31  = (ui31  .read() * 2) + 1;
    66       ui32  = (ui32  .read() * 2) + 1;
    67       ui64  = (ui64  .read() * 2) + 1;
    68       i6    = (i6    .read() * 2) + 1;
    69       i16   = (i16   .read() * 2) + 1;
    70       i31   = (i31   .read() * 2) + 1;
    71       i32   = (i32   .read() * 2) + 1;
    72       i64   = (i64   .read() * 2) + 1;
    73 //      bui64 = (bui64 .read() * 2) + 1;
    74 //      bui64b= bui64b        * 2; bui64b= bui64b        + 1;
    75 //      bui96 = bui96 .read() * 2; bui96 = bui96 .read() + 1;
    76 #if 0
    77       cout << bui64.read() << " ";
    78       cout << bui64b << "\n";
    79 #endif
     25    unsigned int ui6_c_type : 6;
     26    sc_uint<6> ui6_sc_uint;
     27
     28    void eval() {
     29        if (resetn == false) {
     30            ui6 = 0xF; ui6_c_type = 0xF;
     31            ui6_sc_uint = 0xF;
     32            ui16 = 0x3F;
     33            ui31 = 0x100;
     34            ui32 = 0x211;
     35            ui64 = 0xABCF1234ULL;
     36            i6 = 0xF;
     37            i16 = 0x3F;
     38            i31 = 0x11112222;
     39            i32 = 0x43214321;
     40            i64 = 0x4444abcdULL;
     41        }
     42        else {
     43            cout << hex << ui6.read() << " "
     44                 << ui6_c_type  << " "
     45                 << ui6_sc_uint << endl;
     46            ASSERT(ui6.read() == ui6_c_type);
     47            ui6 = (ui6.read() * 2) + 1;
     48            ui6_c_type = (ui6_c_type * 2) + 1;
     49            ui6_sc_uint = (ui6_sc_uint * 2) + 1;
     50            ui16 = (ui16.read() * 2) + 1;
     51            ui31 = (ui31.read() * 2) + 1;
     52            ui32 = (ui32.read() * 2) + 1;
     53            ui64 = (ui64.read() * 2) + 1;
     54            i6 = (i6.read() * 2) + 1;
     55            i16 = (i16.read() * 2) + 1;
     56            i31 = (i31.read() * 2) + 1;
     57            i32 = (i32.read() * 2) + 1;
     58            i64 = (i64.read() * 2) + 1;
     59        }
    8060    }
    81   }
    8261
    83   SC_CTOR(sc_test)
    84   {
    85     SC_METHOD(eval);
    86     dont_initialize ();
    87     sensitive << clk.pos();
    88   }
     62    SC_CTOR(sc_test) {
     63        SC_METHOD(eval);
     64        sensitive << clk.pos();
     65        dont_initialize();
     66    }
     67
    8968};
    9069
    91 int sc_main (int argc, char *argv[])
    92 {
    93   int errnum = 1;
    94   cout << "Tests ok\n";
    95   sc_clock        clk("clk");
    96   sc_signal<bool> resetn("resetn");
    97  
    98   sc_test test("test");
    99   test.clk    (clk);
    100   test.resetn (resetn);
    101  
    102   sc_trace_file *tf;
    10370
    104   if (argc != 3)
    105   {
    106     cerr << "Usage : " << argv[0] << " <trace filename> <#cycles>\n";
    107     exit (-1);
    108   }
     71int sc_main(int argc, char * argv[]) {
     72    sc_clock clk("clk");
     73    sc_signal<bool> resetn("resetn");
    10974
    110   string trace_filename = argv[1];
    111   tf = sc_create_vcd_trace_file (trace_filename.c_str());
    112   sc_trace (tf, test.ui6  , "ui6"  );
    113   sc_trace (tf, test.ui16 , "ui16" );
    114   sc_trace (tf, test.ui31 , "ui31" );
    115   sc_trace (tf, test.ui32 , "ui32" );
    116   sc_trace (tf, test.ui64 , "ui64" );
    117   sc_trace (tf, test.i6   , "i6"   );
    118   sc_trace (tf, test.i16  , "i16"  );
    119   sc_trace (tf, test.i31  , "i31"  );
    120   sc_trace (tf, test.i32  , "i32"  );
    121   sc_trace (tf, test.i64  , "i64"  );
    122   sc_trace (tf, clk       , "clk"  );
    123 //  sc_trace (tf, test.bui64, "bui64");
    124 //  sc_trace (tf, test.bui96, "bui96");
     75    sc_test test("test");
     76    test.clk(clk);
     77    test.resetn(resetn);
    12578
    126   ASSERT(test.ui6.read() == 0);
    127   ASSERT(test.ui31.read() == 0);
    128   ASSERT(test.ui32.read() == 0);
    129   ASSERT(test.ui64.read() == 0);
    130   ASSERT(test.i6.read() == 0);
    131   ASSERT(test.i64.read() == 0);
     79    sc_trace_file * tf;
    13280
    133   sc_initialize ();
     81    tf = sc_create_vcd_trace_file("trace_file");
     82    sc_trace(tf, test.ui6 , "ui6");
     83    sc_trace(tf, test.ui16, "ui16");
     84    sc_trace(tf, test.ui31, "ui31");
     85    sc_trace(tf, test.ui32, "ui32");
     86    sc_trace(tf, test.ui64, "ui64");
     87    sc_trace(tf, test.i6, "i6");
     88    sc_trace(tf, test.i16, "i16");
     89    sc_trace(tf, test.i31, "i31");
     90    sc_trace(tf, test.i32, "i32");
     91    sc_trace(tf, test.i64, "i64");
     92    sc_trace(tf, clk, "clk");
    13493
    135   resetn = false;
    136  
    137   sc_start (3);
    138   resetn = true;
    139   sc_start (20);
     94    ASSERT(test.ui6.read() == 0);
     95    ASSERT(test.ui31.read() == 0);
     96    ASSERT(test.ui32.read() == 0);
     97    ASSERT(test.ui64.read() == 0);
     98    ASSERT(test.i6.read() == 0);
     99    ASSERT(test.i64.read() == 0);
    140100
    141 #if 1
    142   cout << "0x3f"            << " 0x" << hex << (unsigned int) (sc_uint<6> )test.ui6   << endl;
    143   cout << "0x100fffff"      << " 0x" << hex << (unsigned int) (sc_uint<31>)test.ui31  << endl; 
    144   cout << "0x211fffff"      << " 0x" << hex << (unsigned int) (sc_uint<32>)test.ui32  << endl;
    145   cout << "0xabcf1234fffff" << " 0x" << hex << (long long unsigned int) (sc_uint<64>)test.ui64  << endl; 
     101    sc_start(sc_time(0, sc_core::SC_NS));
     102
     103    resetn = false;
     104
     105    sc_start(sc_time(3, sc_core::SC_NS));
     106    resetn = true;
     107    sc_start(sc_time(20, sc_core::SC_NS));
     108
     109#if 0
     110    cout << "0x3f"            << " 0x" << hex << (unsigned int) (sc_uint<6> )test.ui6   << endl;
     111    cout << "0x100fffff"      << " 0x" << hex << (unsigned int) (sc_uint<31>)test.ui31  << endl; 
     112    cout << "0x211fffff"      << " 0x" << hex << (unsigned int) (sc_uint<32>)test.ui32  << endl;
     113    cout << "0xabcf1234fffff" << " 0x" << hex << (long long unsigned int) (sc_uint<64>)test.ui64  << endl; 
    146114#endif
    147   cerr << test.ui6.read() << endl;
     115    cout << test.ui6.read() << endl;
    148116
    149   union t {
    150     int v1:3;
    151     int v2;
    152   };
    153117
    154   t t1,t2;
    155   t1.v1 = 7;
    156   cerr << t1.v1 << " " << t1.v2 << endl;
    157   t2.v2 = 7;
    158   cerr << t2.v1 << " " << t2.v2 << endl;
     118    union t {
     119        int v1:3;
     120        int v2;
     121    };
    159122
    160   ASSERT(test.ui6.read() == 0x3f);
    161   ASSERT(test.ui31.read() == 0x100fffff);
    162   ASSERT(test.ui32.read() == 0x211fffff);
    163123
    164   long long unsigned int ui64_reference = 0xabcf1234ULL;
    165   ui64_reference <<= 20;
    166   ui64_reference += 0xfffffULL;
     124    t t1, t2;
     125    t1.v1 = 7;
     126    cout << t1.v1 << " " << t1.v2 << endl;
     127    t2.v2 = 7;
     128    cout << t2.v1 << " " << t2.v2 << endl;
     129
     130    ASSERT(test.ui6.read() == 0x3f);
     131    ASSERT(test.ui31.read() == 0x100fffff);
     132    ASSERT(test.ui32.read() == 0x211fffff);
     133
     134    long long unsigned int ui64_reference = 0xabcf1234ULL;
     135    ui64_reference <<= 20;
     136    ui64_reference += 0xfffffULL;
     137
    167138#if 0
    168   cout << "0xffffffff"      << " 0x" << hex << (int) (sc_int<6>)test.i6    << endl;
    169   cout << "0x222fffff"      << " 0x" << hex << (int) (sc_int<31>)test.i31   << endl; 
    170   cout << "0x321fffff"      << " 0x" << hex << (int) (sc_int<32>)test.i32   << endl;
    171   cout << "0x4444abcdfffff" << " 0x" << hex << (long long signed int) (sc_int<64>)test.i64   << endl;   
     139    cout << "0xffffffff"      << " 0x" << hex << (int) (sc_int<6>)test.i6    << endl;
     140    cout << "0x222fffff"      << " 0x" << hex << (int) (sc_int<31>)test.i31   << endl; 
     141    cout << "0x321fffff"      << " 0x" << hex << (int) (sc_int<32>)test.i32   << endl;
     142    cout << "0x4444abcdfffff" << " 0x" << hex << (long long signed int) (sc_int<64>)test.i64   << endl;   
    172143#endif
    173144
    174   ASSERT(test.ui64.read() == ui64_reference);
    175   ASSERT(test.i6.read() == (sc_int<6>)~0);
    176   ASSERT(test.i31.read() == 0x222fffff);
    177   ASSERT(test.i32.read() == 0x321fffff)
     145    ASSERT(test.ui64.read() == ui64_reference);
     146    ASSERT(test.i6.read() == (sc_int<6>) ~ 0);
     147    ASSERT(test.i31.read() == 0x222fffff);
     148    ASSERT(test.i32.read() == 0x321fffff);
    178149
    179   long long signed int i64_reference = 0x4444abcdULL;
    180   i64_reference <<= 20;
    181   i64_reference += 0xfffffULL;
    182   ASSERT(test.i64.read() == i64_reference);
     150    long long signed int i64_reference = 0x4444abcdULL;
     151    i64_reference <<= 20;
     152    i64_reference += 0xfffffULL;
     153    ASSERT(test.i64.read() == i64_reference);
    183154
    184 //  cout << "0x4294967315" << " 0x" << hex << test.bui64 << endl;   
    185   cout << "Test OK.\n";
    186155
    187   sc_close_vcd_trace_file (tf);
     156    sc_close_vcd_trace_file(tf);
    188157
    189   return EXIT_SUCCESS;
     158    return EXIT_SUCCESS;
    190159}
     160
     161/*
     162# Local Variables:
     163# tab-width: 4;
     164# c-basic-offset: 4;
     165# c-file-offsets:((innamespace . 0)(inline-open . 0));
     166# indent-tabs-mode: nil;
     167# End:
     168#
     169# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     170*/
     171
Note: See TracChangeset for help on using the changeset viewer.