Changeset 22 for sources/src/sc_signal.h


Ignore:
Timestamp:
Apr 16, 2009, 2:46:01 PM (15 years ago)
Author:
buchmann
Message:

Fix:

  • add missing system header include
  • add a namespace path to atoi

And... code cleanup:

  • bunch of various operators that share the same implementation now are using the same #define.
  • indent and tab/space
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/sc_signal.h

    r17 r22  
    9191                        const T          value_)
    9292{
    93         if (sizeof (T) > sizeof (base_type)) {
     93  if (sizeof (T) > sizeof (base_type)) {
    9494#if 0
    95     cout << "sizeof (T) = " << sizeof (T) << " (base_type = " << sizeof
    96 (base_type) << "\n";
    97 #endif
    98                 post_multiwrite (pointer_,value_);
    99         } else {
     95  std::cout << "sizeof (T) = " << sizeof (T)
     96            << " (base_type = " << sizeof (base_type) << "\n";
     97#endif
     98  post_multiwrite (pointer_,value_);
     99  } else {
    100100#if defined(DEBUG)
    101         if (pending_write_vector_nb >= pending_write_vector_capacity) {
    102         //if (pending_write_vector_nb >= pending_write_vector_capacity * sizeof(pending_write)) {
    103                 std::cerr << "Error : The array for posted writing on register is too small.\n";
    104                 std::cerr << "Up to 1 writing per register is allowed during a cycle.\n";
    105                 std::cerr << "Please check the hardware description.\n";
    106                 exit (-1);
    107         }
     101    if (pending_write_vector_nb >= pending_write_vector_capacity) {
     102      //if (pending_write_vector_nb >= pending_write_vector_capacity * sizeof(pending_write)) {
     103      std::cerr << "Error : The array for posted writing on register is too small.\n";
     104      std::cerr << "Up to 1 writing per register is allowed during a cycle.\n";
     105      std::cerr << "Please check the hardware description.\n";
     106      exit (-1);
     107    }
    108108#endif // DEBUG
    109   pending_write_vector[pending_write_vector_nb].pointer = pointer_;
     109    pending_write_vector[pending_write_vector_nb].pointer = pointer_;
    110110//      pending_write_vector[pending_write_vector_nb++].value = *(reinterpret_cast<const base_type*const>(&value_)); => bug !
    111   pending_write_vector[pending_write_vector_nb++].value = value_; // => bug avec blues !
     111    pending_write_vector[pending_write_vector_nb++].value = value_; // => bug avec blues !
    112112
    113113        // -> fix to use user-defined struct in sc_signal/sc_in/sc_out/sc_inout
     
    121121                return;
    122122#endif
    123         };
     123  };
    124124}
    125125
    126126inline bool is_posted_write ()
    127127{
    128                 return pending_write_vector_nb > 0;
     128  return pending_write_vector_nb > 0;
    129129}
    130130
     
    139139class sc_signal_base : public sc_object, public sc_interface
    140140{
    141         //////
    142         // Internal
     141  //////
     142  // Internal
    143143  friend class sc_clock;
    144144  friend class sc_port_base;
    145145  void init ();
    146         //////                           
     146  //////                                 
    147147 
    148148
     
    158158  sc_signal_base(const char* name_);
    159159  sc_signal_base(const char* name_, void*);
    160         ~sc_signal_base();
     160  ~sc_signal_base();
    161161};
    162162
     
    165165{
    166166private:
    167         T val;
    168   typedef T  data_type;
     167  T val;
     168  typedef T                data_type;
    169169  typedef sc_signal < T >  this_type;
    170         ///////////
    171         // Internal
    172         public: void init ();
    173         ///////////
    174 //  virtual void update ();
     170
     171  ///////////
     172  // Internal
     173public: void init ();
     174  ///////////
     175
     176  //  virtual void update ();
    175177  void check_writer ();
    176178public:
    177179  // constructors, destructor
    178180  sc_signal ()
    179         { init (); }
     181  { init (); }
    180182  explicit sc_signal (const char *name_): sc_signal_base(name_)
    181         { init (); }
     183  { init (); }
    182184  /*virtual */~ sc_signal ()
    183185  {}
     
    229231  set_pointer ((tab_t*)&val);
    230232  set_kind    (kind_string);
    231         sc_interface::init (sizeof (data_type));
     233  sc_interface::init (sizeof (data_type));
    232234  val = 0; /* The simulator initializes the signal/register to 0.    */
    233235           /* However, hardware initialization still has to be done. */
Note: See TracChangeset for help on using the changeset viewer.