Changeset 35 for sources/src


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/src
Files:
10 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
Note: See TracChangeset for help on using the changeset viewer.