Changeset 35 for sources


Ignore:
Timestamp:
Jun 29, 2009, 6:03:59 PM (15 years ago)
Author:
buchmann
Message:

Code cleanup.

Add --dynamiclink option to systemcass executable.

Location:
sources
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • sources/src/casc.h

    r27 r35  
    4949{
    5050#ifdef CONFIG_CHECK_FSM_RULES
    51         casc_fsm_step = TRANSITION;
     51  casc_fsm_step = TRANSITION;
    5252#endif
    5353  transition ();
    5454  update     ();
    5555#ifdef CONFIG_CHECK_FSM_RULES
    56         casc_fsm_step = GEN_MOORE;
     56  casc_fsm_step = GEN_MOORE;
    5757#endif
    5858  moore_generation ();
    5959#ifdef CONFIG_CHECK_FSM_RULES
    60         casc_fsm_step = GEN_MEALY;
     60  casc_fsm_step = GEN_MEALY;
    6161#endif
    6262  mealy_generation ();
    6363#ifdef CONFIG_CHECK_FSM_RULES
    64         casc_fsm_step = STIMULI;
     64  casc_fsm_step = STIMULI;
    6565#endif
    6666}
  • sources/src/gen_code.cc

    r31 r35  
    7979ostream& operator << (ostream &o, const SC_ENTRY_FUNC &f)
    8080{
    81         register fct p;
    82         p.pmf = f;
    83         return o << "0x" << hex << p.integer << "ULL";
     81  register fct p;
     82  p.integer = 0;
     83  p.pmf = f;
     84  return o << "0x" << hex << p.integer << "ULL";
    8485}
    8586
     
    242243  o << "\nextern void mealy_generation (void)\n{\n";
    243244  o << "  register fct p;\n"
    244           << "\n\n  /* fonctions de mealy */\n";
    245         ProcessDependencyList::iterator it;
    246         for (it = mealy_func_list.begin(); it != mealy_func_list.end(); ++it)
    247         {
    248                 const method_process_t *m = *it;
    249           PrintCall (o, *m);
    250         }
     245    << "\n\n  /* fonctions de mealy */\n";
     246  ProcessDependencyList::iterator it;
     247  for (it = mealy_func_list.begin(); it != mealy_func_list.end(); ++it)
     248  {
     249    const method_process_t *m = *it;
     250    PrintCall (o, *m);
     251  }
    251252}
    252253
     
    260261    cerr << "Generating C code for scheduling...\n";
    261262
    262         // open temporary file
    263         ofstream o;
     263  // open temporary file
     264  ofstream o;
    264265  char base_name[PATH_MAX];
    265         open_temp (o, base_name);
     266  open_temp (o, base_name);
    266267 
    267         if (! o.good ()) {
     268  if (! o.good ()) {
    268269    perror("scheduling: open file\n");
    269270    exit(-1);
     
    271272
    272273  o << "// generated by " << sc_version () << endl
    273                 << "#include <casc.h>\n\n"
    274                 << "#include <cstdio>\n\n"
    275 //              << "#include <iostream>\n\n"
    276                 << "namespace sc_core {\n"
     274    << "#include <casc.h>\n\n"
     275    << "#include <cstdio>\n\n"
     276//  << "#include <iostream>\n\n"
     277    << "namespace sc_core {\n"
    277278    << " typedef void (sc_module::*SC_ENTRY_FUNC)();\n"
    278                 << " typedef void (*CASC_ENTRY_FUNC)(void *);\n";
     279    << " typedef void (*CASC_ENTRY_FUNC)(void *);\n";
    279280  const char *pmf_type = (sizeof (SC_ENTRY_FUNC) == 4)?
    280281                         // G4 pointer-to-member-function style
     
    286287    << " integer; SC_ENTRY_FUNC pmf; CASC_ENTRY_FUNC pf; } fct;\n";
    287288       
    288         gen_transition (o, transition_func_list);       
    289         gen_moore      (o, moore_func_list);   
    290         gen_mealy      (o, strongcomponents);
     289  gen_transition (o, transition_func_list);     
     290  gen_moore      (o, moore_func_list); 
     291  gen_mealy      (o, strongcomponents);
    291292
    292293  o << " \n}\n";
     
    340341    << " typedef union { unsigned long long int integer; SC_ENTRY_FUNC pmf; CASC_ENTRY_FUNC pf; } fct;\n";
    341342       
    342         gen_transition (o, transition_func_list);       
    343         gen_moore      (o, moore_func_list);   
    344         gen_mealy      (o, mealy_func_list);
     343  gen_transition (o, transition_func_list);     
     344  gen_moore      (o, moore_func_list); 
     345  gen_mealy      (o, mealy_func_list);
    345346
    346347  o << "\n}\n";
     
    567568{
    568569#ifdef CONFIG_CHECK_FSM_RULES
    569         casc_fsm_step = TRANSITION;
     570  casc_fsm_step = TRANSITION;
    570571#endif
    571572  call_functions (pf[0]); // transition
    572573  update     ();
    573574#ifdef CONFIG_CHECK_FSM_RULES
    574         casc_fsm_step = GEN_MOORE;
     575  casc_fsm_step = GEN_MOORE;
    575576#endif
    576577  call_functions (pf[1]); // moore generation
    577578#ifdef CONFIG_CHECK_FSM_RULES
    578         casc_fsm_step = GEN_MEALY;
     579  casc_fsm_step = GEN_MEALY;
    579580#endif
    580581  call_functions (pf[2]); // mealy generation
    581582#ifdef CONFIG_CHECK_FSM_RULES
    582         casc_fsm_step = STIMULI;
     583  casc_fsm_step = STIMULI;
    583584#endif
    584585}
     
    626627{
    627628#ifdef CONFIG_CHECK_FSM_RULES
    628         casc_fsm_step = TRANSITION;
     629  casc_fsm_step = TRANSITION;
    629630#endif
    630631  method_process_list_t::iterator mm;
     
    636637  update     ();
    637638#ifdef CONFIG_CHECK_FSM_RULES
    638         casc_fsm_step = GEN_MOORE;
     639  casc_fsm_step = GEN_MOORE;
    639640#endif
    640641  for( mm = func_list[1].begin(); mm != func_list[1].end(); ++mm)
     
    644645  }
    645646#ifdef CONFIG_CHECK_FSM_RULES
    646         casc_fsm_step = GEN_MEALY;
     647  casc_fsm_step = GEN_MEALY;
    647648#endif
    648649  quasistatic_mealy_generation ();
    649650#ifdef CONFIG_CHECK_FSM_RULES
    650         casc_fsm_step = STIMULI;
     651  casc_fsm_step = STIMULI;
    651652#endif
    652653}
  • sources/src/port_dependency.h

    r1 r35  
    2222// Port Dependency Graph
    2323struct PortDependency {
    24         const method_process_t *method;
    25         const sc_port_base     *source;
    26         const sc_port_base     *destination;
     24  const method_process_t *method;
     25  const sc_port_base     *source;
     26  const sc_port_base     *destination;
    2727};
    2828typedef std::list<PortDependency> PortDependencyGraph;
  • sources/src/process_dependency.h

    r1 r35  
    1919// Signal Dependency Graph
    2020struct ProcessDependency {
    21         const method_process_t *source;
    22         const method_process_t *destination;
    23         bool operator < (const ProcessDependency &) const;
     21  const method_process_t *source;
     22  const method_process_t *destination;
     23  bool operator < (const ProcessDependency &) const;
    2424};
    2525
  • sources/src/sc_main.cc

    r27 r35  
    187187                 << "modules filename : dump module hierarchy graph into specified dot file (tons of bugs inside)\n"
    188188                 << "nobanner: do not print SystemCASS splash screen\n"
    189                  << "nodynamiclink: do not link dynamically scheduling code\n"
     189                 << "dynamiclink: dynamically link the scheduling code\n"
    190190                 << "nosim   : run until elaboration stage. Don't simulate\n"
    191191                 << "notrace : disable all tracing functions\n"
     
    226226          case 'c' :
    227227            print_schedule = true;
     228            continue;
     229          case 'd' :
     230            if (strcmp (argv[i]+2, "dynamiclink") == 0)
     231              dynamic_link_of_scheduling_code = true;
     232            else
     233              check_port_dependencies = true;
    228234            continue;
    229235          case 'e' :
     
    279285            scheduling_method = BUCHMANN_SCHEDULING;
    280286            continue;
    281           case 'd' :
    282             check_port_dependencies = true;
    283             continue;
    284287          default :
    285288            break;
  • sources/src/sc_module.cc

    r27 r35  
    139139{
    140140  name = nm;
    141         func = fn;
     141  func = fn;
    142142  module = &mod;
    143143  dont_initialize = false;
  • sources/src/sc_module.h

    r27 r35  
    1414#define __SC_MODULE_H__
    1515
    16 #include "sc_module_ext.h"
    17 
    1816#include <list>
    1917#include <set>
    2018#include <stack>
     19
     20#include "internal.h"
     21
    2122#include "sc_fwd.h"
    22 #include "internal.h"
     23#include "sc_module_ext.h"
    2324#include "sc_object.h"
    2425#include "sc_sensitive.h"
     
    5657public: const char *name; // function name
    5758#ifdef DUMP_SCHEDULE_STATS
    58         long long int number_of_calls;
     59  long long int number_of_calls;
    5960#endif 
    6061public:
  • sources/src/sc_port.cc

    r27 r35  
    138138}
    139139
    140 static bool check_multiwriting2port_error_message = 1;
     140static bool check_multiwriting2port_error_message = true;
    141141void
    142142sc_port_base::check_multiwriting2port () const
  • sources/src/sc_port_ext.h

    r27 r35  
    1717#include <iostream>
    1818#include <cstdlib>
    19 #include "sc_fwd.h"
    20 #include "sc_nbdefs.h"
    21 //#include "sc_event_finder.h"
    22 #include "sc_event.h"
    23 #include "sc_object.h"
    24 #include "sc_interface.h"
     19
     20#ifdef HAVE_CONFIG_H
     21#include "config.h"
     22#endif
     23
     24#include "fsm_rules.h"
    2525#include "internal_ext.h"
    2626#include "port_dependency_ext.h"
    27 #include "fsm_rules.h"
     27#include "sc_event.h"
     28#include "sc_fwd.h"
     29#include "sc_interface.h"
     30#include "sc_nbdefs.h"
     31#include "sc_object.h"
    2832
    2933
     
    4549//
    4650
    47         using namespace sc_dt;
     51  using namespace sc_dt;
    4852
    4953const char *get_name        (const tab_t *pointer);
    5054
    5155#define READ_SIGNAL(value_type_,pointer_) \
    52         ((value_type_&) (*((value_type_*) (pointer_))))
    53 
    54         ///////////////////// DEPRECATED
     56  ((value_type_&) (*((value_type_*) (pointer_))))
     57
     58  ///////////////////// DEPRECATED
    5559// C ANSI-only since it is needed to link with extern "C"
    5660// this declaration is not in casc.h since the CONFIG_CHECK_FSM_RULES macro
     
    7478  typedef sc_port_base                        base_type;
    7579public:
    76         ///////////
    77         // Internal
    78         const sc_module &get_module () const;
    79         void             init ();
     80  ///////////
     81  // Internal
     82  const sc_module &get_module () const;
     83  void             init ();
    8084  void             check_multiwriting2port () const;
    81         ///////////             
     85  ///////////   
    8286 
    8387  friend std::ostream& operator << (std::ostream &, const sc_port_base &);
     
    114118  typedef sc_signal<data_type>          signal_type;
    115119
    116         ///////////
    117         // Internal
     120  ///////////
     121  // Internal
    118122  void init ();
    119         /*
    120         public: virtual size_t data_size () const
    121         { return sizeof (data_type); }
    122         */
    123         ///////////
     123  /*
     124  public: virtual size_t data_size () const
     125  { return sizeof (data_type); }
     126  */
     127  ///////////
    124128public:
    125129  // constructors
     
    130134  explicit sc_in(const base_type& parent_ ): base_type( parent_ ) { init (); }
    131135
    132         /*
     136  /*
    133137  // LRM error !
    134138  //static const char *const kind_string; this is a template !
    135         */
     139  */
    136140//  virtual const char *kind () const
    137141//  { return "sc_in"; };
     
    171175sc_in<T>::init()
    172176{
    173         set_kind (sc_in_string);
    174         sc_interface::init (sizeof (data_type));
     177  set_kind (sc_in_string);
     178  sc_interface::init (sizeof (data_type));
    175179}
    176180
     
    182186#ifdef DUMP_READ
    183187  std::cerr << "read " << READ_SIGNAL(const T&, get_pointer())
    184                 << " on signal " << name () << "\n";
     188     << " on signal " << name () << "\n";
    185189#endif
    186190#ifdef CONFIG_CHECK_FSM_RULES
    187         if (casc_fsm_step == GEN_MOORE) {
    188                 std::cerr << "FSM rules error : trying to read on input port '"
    189                           << name ()
    190                           << "' from " <<  get_step_name () << " function.\n";
    191                 exit (-1);
    192         }               
     191  if (casc_fsm_step == GEN_MOORE) {
     192    std::cerr << "FSM rules error : trying to read on input port '"
     193              << name ()
     194        << "' from " <<  get_step_name () << " function.\n";
     195    exit (-1);
     196  }   
    193197#endif
    194198  return READ_SIGNAL(const T, get_pointer());
     
    212216class sc_inout : public sc_port_base
    213217{
    214         ///////////
    215         // Internal
     218  ///////////
     219  // Internal
    216220protected:
    217221  void init ();
    218         T val;
     222  T val;
    219223private:
    220224  typedef T                                   data_type;
     
    223227  typedef sc_signal<data_type>                signal_type;
    224228
    225         /*
    226         public: virtual size_t data_size () const
    227         { return sizeof (data_type); }
    228         */
    229         ///////////
     229  /*
     230  public: virtual size_t data_size () const
     231  { return sizeof (data_type); }
     232  */
     233  ///////////
    230234public:
    231235  // contructeurs
     
    234238  explicit sc_inout(const char* name_): base_type(name_) { init (); };
    235239
    236         /*
     240  /*
    237241  // LRM error !
    238242  //static const char *const kind_string; this is a template !
    239         */
     243  */
    240244  //virtual const char *kind () const
    241245  //{ return "sc_inout"; };
     
    273277sc_inout<T>::init ()
    274278{
    275         set_pointer ((tab_t*)(void*)&val);
    276         sc_object::set_kind    (sc_inout_string);
    277         sc_interface::init (sizeof (data_type));
     279  set_pointer ((tab_t*)(void*)&val);
     280  sc_object::set_kind    (sc_inout_string);
     281  sc_interface::init (sizeof (data_type));
    278282  /*ref*/ val = (0);
    279283  //sc_inout::write (0);
     
    292296#ifdef DUMP_READ
    293297  std::cerr << "read " << READ_SIGNAL(const T, get_pointer()) // val
    294                 << " on signal " << name () << "\n";
     298     << " on signal " << name () << "\n";
    295299#endif
    296300#ifdef CONFIG_CHECK_FSM_RULES
    297         if (casc_fsm_step == GEN_MOORE) {
    298                 std::cerr << "FSM rules error : trying to read on input/output port "
    299                         << name () //get_name (get_pointer())
    300                         << " from " << get_step_name () << " function.\n";
    301                 exit (-1);
    302         }               
     301  if (casc_fsm_step == GEN_MOORE) {
     302    std::cerr << "FSM rules error : trying to read on input/output port "
     303      << name () //get_name (get_pointer())
     304      << " from " << get_step_name () << " function.\n";
     305    exit (-1);
     306  }   
    303307#endif
    304308//  return val;
     
    317321#endif
    318322#ifdef CONFIG_CHECK_FSM_RULES
    319         if ((casc_fsm_step != GEN_MOORE) && ( casc_fsm_step != GEN_MEALY)) {
    320                 std::cerr << "FSM rules error : trying to write on output port "
    321                         << name ()
    322                         << " from an " << get_step_name () << " function.\n";
    323                 exit (-1);
    324         }               
    325 #endif
    326 //      T& ref = *(T*)(get_pointer());
     323  if ((casc_fsm_step != GEN_MOORE) && ( casc_fsm_step != GEN_MEALY)) {
     324    std::cerr << "FSM rules error : trying to write on output port "
     325      << name ()
     326      << " from an " << get_step_name () << " function.\n";
     327    exit (-1);
     328  }   
     329#endif
     330//  T& ref = *(T*)(get_pointer());
    327331#if defined(CONFIG_CHECK_MULTIWRITING2PORT)
    328332  check_multiwriting2port ();
     
    369373class sc_out : public sc_inout<T>
    370374{
    371         ///////////
    372         // Internal
     375  ///////////
     376  // Internal
    373377  void init ();
    374         ///////////
     378  ///////////
    375379public:
    376380  // typedefs
     
    386390  sc_out (const char *name_, this_type & parent_);
    387391
    388         /*
     392  /*
    389393  // LRM error !
    390394  //static const char *const kind_string; this is a template !
    391         */
     395  */
    392396  //virtual const char *kind () const
    393397  //{ return "sc_out"; };
     
    404408  { bind (*this,parent_); }
    405409
    406         //////////////////////
    407         // Systemcass specific
     410  //////////////////////
     411  // Systemcass specific
    408412  void operator () (sc_port_base &o)
    409413  { set_port_dependency (&o, (sc_port_base&)(*this)); }
     
    412416  { set_port_dependency (NULL, (sc_port_base&)(*this)); }
    413417*/
    414         //////////////////////
     418  //////////////////////
    415419
    416420
     
    428432{
    429433  sc_inout<T>::init ();
    430 //      tab_t *t = &(sc_inout<T>::val);
    431 //      sc_interface::set_pointer (t);
    432         sc_object::set_kind (sc_out_string);
    433 //      sc_interface::init (sizeof (data_type));
     434//  tab_t *t = &(sc_inout<T>::val);
     435//  sc_interface::set_pointer (t);
     436  sc_object::set_kind (sc_out_string);
     437//  sc_interface::init (sizeof (data_type));
    434438//  /*ref*/ sc_inout<T>::val = 0;
    435439  //sc_inout<T>::write (0);
  • sources/src/signal_dependency.h

    r1 r35  
    2424// Signal Dependency Graph
    2525struct SignalDependency {
    26         const method_process_t *method;
    27         const equi_t           *source;
    28         const equi_t           *destination;
    29         bool operator < (const SignalDependency &a) const;
    30 //      friend int operator < (const SignalDependency &a, const SignalDependency &b);
     26  const method_process_t *method;
     27  const equi_t           *source;
     28  const equi_t           *destination;
     29  bool operator < (const SignalDependency &a) const;
     30//  friend int operator < (const SignalDependency &a, const SignalDependency &b);
    3131};
    3232
  • sources/test_regression/05042006/system.cpp

    r1 r35  
    11#include <systemc.h>
    2 
    3 #define ASSERT(x) \
    4   { errnum++; \
    5     if (!(x)) \
    6     { \
    7     cerr << "ASSERT : " #x "\n"; \
    8     exit (errnum); \
    9     } \
    10   }
    112
    123using namespace std;
    134
    145struct test : sc_module {
    15         sc_in_clk                       clk;
     6  sc_in_clk                       clk;
    167  sc_in<int>                      i1;
    178  sc_out<int>                     o1;
     
    3627
    3728  SC_HAS_PROCESS(test);
    38         test (sc_module_name n) : sc_module (n),
     29  test (sc_module_name n) : sc_module (n),
    3930    clk("clk"),
    4031    i1("i1"),
     
    4435    reg2("reg2")
    4536  {
    46                 SC_METHOD(trans);
    47                 sensitive << clk.pos();
     37    SC_METHOD(trans);
     38    sensitive << clk.pos();
    4839    dont_initialize();
    49                 SC_METHOD(gen);
    50                 sensitive << clk.neg();
     40    SC_METHOD(gen);
     41    sensitive << clk.neg();
    5142    dont_initialize();
    52         };
     43  };
    5344};
    5445
    5546int sc_main (int argc, char *argv[])
    5647{
    57   int errnum = 0;
    58         sc_clock        signal_clk("my_clock",1, 0.5);
     48  sc_clock        signal_clk("my_clock",1, 0.5);
    5949  sc_signal<int>     s01("s01");
    6050  sc_signal<int>     s02("s02");
     
    6757  test1.o2 (s03);
    6858
    69         // Init & run
    70         sc_start (0);
     59  // Init & run
     60  sc_start (0);
    7161
    7262  sc_start (10);
    7363
    74         return EXIT_SUCCESS;
     64  return EXIT_SUCCESS;
    7565}
    7666
  • sources/test_regression/07122006/system2.cpp

    r34 r35  
    3434  sc_signal<int>  reg;
    3535
    36   void transition ();
     36  virtual void transition ();
    3737  void gen_moore  ();
    3838  void gen_mealy  ();
     
    8989
    9090  cout << "Test OK.\n";
    91         return EXIT_SUCCESS;
     91  return EXIT_SUCCESS;
    9292}
  • sources/test_regression/16112005/system.cpp

    r1 r35  
    1 #include "systemc.h"
     1#include <systemc.h>
    22#include <iostream>
    33#include <string>
     
    2020  sc_in<int>     i;
    2121  sc_out<int>    o;
    22         internal_model (sc_module_name n) : sc_module (n),
     22  internal_model (sc_module_name n) : sc_module (n),
    2323    i("i"),
    24                 o("o")
     24    o("o")
    2525  {
    2626  }
     
    3131  sc_in<int>     i1, i2, i3;
    3232  sc_out<int>    o1, o2, o3;
    33         sc_signal<int> r1, r2;
     33  sc_signal<int> r1, r2;
    3434  internal_model internal;
    35         model (sc_module_name n) : sc_module (n),
     35
     36  model (sc_module_name n) : sc_module (n),
    3637    i1("i1"), i2("i2"), i3("i3"),
    37                 o1("o1"), o2("o2"), o3("o3"),
    38                 r1("r1"), r2("r2"),
     38    o1("o1"), o2("o2"), o3("o3"),
     39    r1("r1"), r2("r2"),
    3940    internal ("internal")
    4041  {
  • sources/test_regression/16122005/system.cpp

    r18 r35  
    1 #include "systemc.h"
     1#include <systemc.h>
    22#include <iostream>
    33#include <fstream>
  • sources/test_regression/17032005/Makefile

    r15 r35  
    1414
    1515system-23.vcd : system_systemcass.x
    16         ./system_systemcass.x system 23
     16        ./system_systemcass.x --nodynamiclink system 23
    1717        tail -n +8 system.vcd > system-23.vcd
    1818        rm system.vcd
  • sources/test_regression/17032005/system.cpp

    r18 r35  
    2020  sc_in<bool>     clk;
    2121  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;
     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;
    2626  sc_signal<sc_uint<64>    > ui64;
    2727  sc_signal<sc_int<6>      > i6;
     
    4545      ui31  = 0x100;
    4646      ui32  = 0x211;
    47       ui64  = 0xABCF1234;
     47      ui64  = 0xABCF1234ULL;
    4848      i6    = 0xF;
    4949      i16   = 0x3F;
    5050      i31   = 0x11112222;
    5151      i32   = 0x43214321;
    52       i64   = 0x4444abcd;
     52      i64   = 0x4444abcdULL;
    5353//      bui64 = 0xFFFFFFFF;
    5454//      bui64b= 0xFFFFFFFF;
     
    9191int sc_main (int argc, char *argv[])
    9292{
    93         int errnum = 1;
    94         cout << "Tests ok\n";
     93  int errnum = 1;
     94  cout << "Tests ok\n";
    9595  sc_clock        clk("clk");
    9696  sc_signal<bool> resetn("resetn");
     
    100100  test.resetn (resetn);
    101101 
    102         sc_trace_file *tf;
     102  sc_trace_file *tf;
    103103
    104104  if (argc != 3)
     
    109109
    110110  string trace_filename = argv[1];
    111         tf = sc_create_vcd_trace_file (trace_filename.c_str());
     111  tf = sc_create_vcd_trace_file (trace_filename.c_str());
    112112  sc_trace (tf, test.ui6  , "ui6"  );
    113113  sc_trace (tf, test.ui16 , "ui16" );
     
    139139  sc_start (20);
    140140
    141   sc_close_vcd_trace_file (tf);
    142 
    143141#if 1
    144142  cout << "0x3f"            << " 0x" << hex << (unsigned int) (sc_uint<6> )test.ui6   << endl;
     
    148146#endif
    149147  cerr << test.ui6.read() << endl;
     148
    150149  union t {
    151150    int v1:3;
    152151    int v2;
    153152  };
     153
    154154  t t1,t2;
    155155  t1.v1 = 7;
     
    161161  ASSERT(test.ui31.read() == 0x100fffff);
    162162  ASSERT(test.ui32.read() == 0x211fffff);
    163   long long unsigned int ui64_reference = 0xabcf1234;
     163
     164  long long unsigned int ui64_reference = 0xabcf1234ULL;
    164165  ui64_reference <<= 20;
    165   ui64_reference += 0xfffff;
     166  ui64_reference += 0xfffffULL;
    166167#if 0
    167168  cout << "0xffffffff"      << " 0x" << hex << (int) (sc_int<6>)test.i6    << endl;
     
    170171  cout << "0x4444abcdfffff" << " 0x" << hex << (long long signed int) (sc_int<64>)test.i64   << endl;   
    171172#endif
     173
    172174  ASSERT(test.ui64.read() == ui64_reference);
    173175  ASSERT(test.i6.read() == (sc_int<6>)~0);
    174176  ASSERT(test.i31.read() == 0x222fffff);
    175177  ASSERT(test.i32.read() == 0x321fffff)
    176   long long signed int i64_reference = 0x4444abcd;
     178
     179  long long signed int i64_reference = 0x4444abcdULL;
    177180  i64_reference <<= 20;
    178   i64_reference += 0xfffff;
     181  i64_reference += 0xfffffULL;
    179182  ASSERT(test.i64.read() == i64_reference);
     183
    180184//  cout << "0x4294967315" << " 0x" << hex << test.bui64 << endl;   
    181185  cout << "Test OK.\n";
    182         return EXIT_SUCCESS;
     186
     187  sc_close_vcd_trace_file (tf);
     188
     189  return EXIT_SUCCESS;
    183190}
  • sources/test_regression/25032005/system.cpp

    r1 r35  
    44
    55using namespace std;
    6        
     6 
    77struct A : sc_module {
    8         sc_in_clk                       clk;
    9         sc_out<bool>                    o1;
     8  sc_in_clk                       clk;
     9  sc_out<bool>                    o1;
    1010
    11         void eval () {
     11  void eval () {
    1212    o1 = (rand()%2) == 0;
    13         }
     13  }
    1414
    15         SC_CTOR (A) : clk ("clk"), o1("o1") {
    16                 SC_METHOD(eval);
    17                 sensitive << clk.neg();
     15  SC_CTOR (A) : clk ("clk"), o1("o1") {
     16    SC_METHOD(eval);
     17    sensitive << clk.neg();
    1818#ifdef SYSTEMCASS_SPECIFIC
    19 //              s1();
     19//    s1();
    2020#endif
    21         };
     21  };
    2222};
    2323
    2424struct B : sc_module {
    25         sc_in_clk                       clk;
    26         sc_in<bool>                     i1;
    27         sc_in<bool>                     i2;
    28         sc_out<bool>                    o1;
    29         sc_out<bool>                    o2;
     25  sc_in_clk                       clk;
     26  sc_in<bool>                     i1;
     27  sc_in<bool>                     i2;
     28  sc_out<bool>                    o1;
     29  sc_out<bool>                    o2;
    3030
    31         void eval1 () {
     31  void eval1 () {
    3232    o1 = ~i1;
    33         }
    34         void eval2 () {
     33  }
     34  void eval2 () {
    3535    o2 = ~i2;
    36         }
     36  }
    3737
    38         SC_CTOR (B) : clk ("clk"), i1 ("i1"), o1("o1"), i2 ("i2"), o2 ("o2") {
    39                 SC_METHOD(eval1);
    40                 sensitive << clk.neg();
    41                 sensitive << i1;
     38  SC_CTOR (B) : clk ("clk"), i1 ("i1"), o1("o1"), i2 ("i2"), o2 ("o2") {
     39    SC_METHOD(eval1);
     40    sensitive << clk.neg();
     41    sensitive << i1;
    4242#ifdef SYSTEMCASS_SPECIFIC
    43                 o1(i1);
     43    o1(i1);
    4444#endif
    45                 SC_METHOD(eval2);
    46                 sensitive << clk.neg();
    47                 sensitive << i2;
     45    SC_METHOD(eval2);
     46    sensitive << clk.neg();
     47    sensitive << i2;
    4848#ifdef SYSTEMCASS_SPECIFIC
    49                 o2(i2);
     49    o2(i2);
    5050#endif
    51         };
     51  };
    5252};
    5353
    5454struct C : sc_module {
    55         sc_in_clk                       clk;
    56         sc_in<bool>                     i1;
    57         sc_in<bool>                     i2;
    58         sc_out<bool>                    o1;
     55  sc_in_clk                       clk;
     56  sc_in<bool>                     i1;
     57  sc_in<bool>                     i2;
     58  sc_out<bool>                    o1;
    5959
    60         void eval1 () {
     60  void eval1 () {
    6161    o1 = i1 ^ i2;
    62         }
     62  }
    6363
    64         SC_CTOR (C) : clk ("clk"), i1 ("i1"), o1("o1"), i2 ("i2") {
    65                 SC_METHOD(eval1);
    66                 sensitive << clk.neg();
    67                 sensitive << i1 << i2;
     64  SC_CTOR (C) : clk ("clk"), i1 ("i1"), o1("o1"), i2 ("i2") {
     65    SC_METHOD(eval1);
     66    sensitive << clk.neg();
     67    sensitive << i1 << i2;
    6868#ifdef SYSTEMCASS_SPECIFIC
    69                 o1(i1);
    70                 o1(i2);
     69    o1(i1);
     70    o1(i2);
    7171#endif
    72         };
     72  };
    7373};
    7474
    7575struct D : sc_module {
    76         sc_in_clk                       clk;
    77         sc_out<bool>                    o1;
     76  sc_in_clk                       clk;
     77  sc_out<bool>                    o1;
    7878
    79         void eval () {
     79  void eval () {
    8080    o1 = (rand()%2) == 0;
    81         }
     81  }
    8282
    83         SC_CTOR (D) : clk ("clk"), o1("o1") {
    84                 SC_METHOD(eval);
    85                 sensitive << clk.neg();
     83  SC_CTOR (D) : clk ("clk"), o1("o1") {
     84    SC_METHOD(eval);
     85    sensitive << clk.neg();
    8686#ifdef SYSTEMCASS_SPECIFIC
    87 //              s1();
     87//    s1();
    8888#endif
    89         };
     89  };
    9090};
    9191
    9292int sc_main (int argc, char *argv[])
    9393{
    94         sc_clock                     signal_clk("my_clock",1, 0.5);
    95         sc_signal<bool>              s1("s1"),s2("s2"),s3("s3"),s4("s4"),s5("s5");
     94  sc_clock                     signal_clk("my_clock",1, 0.5);
     95  sc_signal<bool>              s1("s1"),s2("s2"),s3("s3"),s4("s4"),s5("s5");
    9696
    97         A      a("a");
    98         B      b("b");
    99         C      c("c");
    100         D      d("d");
    101        
    102         a.clk         (signal_clk);
    103         b.clk         (signal_clk);
    104         c.clk         (signal_clk);
    105         d.clk         (signal_clk);
    106        
    107         a.o1          (s1);
    108         b.i1          (s1);
    109                
    110         d.o1          (s2);
    111         c.i2          (s2);
     97  A      a("a");
     98  B      b("b");
     99  C      c("c");
     100  D      d("d");
     101 
     102  a.clk         (signal_clk);
     103  b.clk         (signal_clk);
     104  c.clk         (signal_clk);
     105  d.clk         (signal_clk);
     106 
     107  a.o1          (s1);
     108  b.i1          (s1);
     109   
     110  d.o1          (s2);
     111  c.i2          (s2);
    112112
    113         b.o1          (s3);
    114         c.i1          (s3);
    115        
    116         c.o1          (s4);
    117         b.i2          (s4);
    118        
    119         b.o2          (s5);
    120        
    121         // Init & run
    122         sc_initialize ();
     113  b.o1          (s3);
     114  c.i1          (s3);
     115 
     116  c.o1          (s4);
     117  b.i2          (s4);
     118 
     119  b.o2          (s5);
     120 
     121  // Init & run
     122  sc_initialize ();
    123123
    124124  if (argc == 1)
     
    128128  }
    129129
    130         chrono_t chrono;
    131         chrono.start ();
     130  chrono_t chrono;
     131  chrono.start ();
    132132
    133133  sc_start (atoi(argv[1]));
    134134
    135         chrono.stop ();
    136         unsigned int t = chrono;
    137         cout << "Time elapsed (sec) : " << t << endl;
    138         cout << "Cycles done        : " << sc_simulation_time () << endl;
    139         cout << "Performance        : " << sc_simulation_time () / t << endl;
    140         printf("\nPress <RETURN> to exit simulation.");
    141         char buf_ret[2];
    142         cin.getline(buf_ret,1);
    143         return EXIT_SUCCESS;
     135  chrono.stop ();
     136  unsigned int t = chrono;
     137  cout << "Time elapsed (sec) : " << t << endl;
     138  cout << "Cycles done        : " << sc_simulation_time () << endl;
     139  cout << "Performance        : " << sc_simulation_time () / t << endl;
     140  printf("\nPress <RETURN> to exit simulation.");
     141  char buf_ret[2];
     142  cin.getline(buf_ret,1);
     143  return EXIT_SUCCESS;
    144144}
  • sources/test_regression/28102005/system.cpp

    r23 r35  
    1 #include "systemc.h"
     1#include <systemc.h>
    22#include <iostream>
    33#include <cstring>
  • sources/test_regression/Makefile

    r18 r35  
    3030# 05042006  : check number of writings into each out port
    3131#             check reading from an sc_out port
     32#             (test check_multiwriting2port option)
    3233# 02052006  : check sc_uint, sc_int, sc_signal<X> when X is double, char,
    3334#             signed int, unsigned int and so on. (little/big endianness test)
     
    3839# 07122006  : check if we can declare an undefined external function as
    3940#             a sc_method.
    40 #             check a virtual method as a sc_method => segmentation fault
     41#             check a virtual method as a sc_method
    4142#             (Unable to check if sc_method is a virtual one)
    4243# 20122006  : check Petrot's scheduling (CASS, quasi static)
     
    4647# 23032007  : check multiple execution on the same computer
    4748# 15042009  : check sc_uint operators (==, =, <<=, +=)
     49#             in some cases, such as a compairison, the developper has to use
     50#             sc_signal<T>::read() method to explicitly read a sc_signal.
    4851
    4952## Uncomment the following variable if you want to compile and run the
Note: See TracChangeset for help on using the changeset viewer.