Changeset 59 for sources/src/sc_signal.h
- Timestamp:
- Feb 6, 2017, 11:35:42 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/sc_signal.h
r52 r59 18 18 #include <iostream> 19 19 #include <cstdlib> 20 #include <typeinfo> // for typeid 20 21 21 22 #include "sc_fwd.h" … … 53 54 base_type * pointer; 54 55 base_type value; 55 //pending_write_t(base_type * const pointer_, const base_type value_) {56 // pointer = pointer_;57 // value = value_;58 //}59 56 60 57 friend std::ostream & operator << (std::ostream & o, const pending_write_t & p) { … … 76 73 77 74 template < typename T > 78 inline void post_write(base_type * const pointer_, const T value_) /*INLINE*/;79 80 template < typename T > 81 inline void post_multiwrite(base_type * const pointer_, const T value_) {75 inline void post_write(base_type * const pointer_, const T & value_) /*INLINE*/; 76 77 template < typename T > 78 inline void post_multiwrite(base_type * const pointer_, const T & value_) { 82 79 size_t size = (sizeof(T) - 1) / sizeof(base_type); 83 80 size_t i = 0; 84 const base_type * pvalue = (const base_type *) (void *) (& 81 const base_type * pvalue = (const base_type *) (void *) (&value_); 85 82 do { 86 83 post_write(pointer_ + i, pvalue[i]); … … 89 86 90 87 template < typename T > 91 inline void post_write(base_type * const pointer_, const T value_) {88 inline void post_write(base_type * const pointer_, const T & value_) { 92 89 if (sizeof(T) > sizeof(base_type)) { 93 post_multiwrite(pointer_, value_);90 post_multiwrite(pointer_, value_); 94 91 } 95 92 else { … … 166 163 167 164 private: 165 168 166 T val; 167 169 168 typedef T data_type; 170 169 typedef sc_signal < T > this_type; … … 182 181 // constructors, destructor 183 182 sc_signal() { 183 if (typeid(data_type) == typeid(double) || typeid(data_type) == typeid(float)) { 184 std::cerr << "Error: SystemCASS does not support sc_signal<T> with T of type " << typeid(data_type).name() << std::endl; 185 exit(1); 186 } 184 187 init(); 185 188 } … … 215 218 } 216 219 217 const data_type & get_new_value() const; 220 const data_type & get_new_value() const { 221 // Warning: untested and doesn't support variable size 222 unsigned int i = 0; 223 for (i = 0; i < pending_write_vector_capacity; i++) { 224 if (pending_write_vector[i].pointer == get_pointer()) { 225 return pending_write_vector[i].value; 226 } 227 } 228 return val; 229 } 218 230 219 231 // void trace (sc_trace_file * tf) const; … … 235 247 set_kind(kind_string); 236 248 sc_interface::init(sizeof(data_type)); 237 val = 0; /* The simulator initializes the signal/register to 0. */249 val = (T) 0; /* The simulator initializes the signal/register to 0. */ 238 250 /* However, hardware initialization still has to be done. */ 239 251 /* This kind of initialization is for trace diffing. */ … … 245 257 /*virtual*/ inline const T & sc_signal< T >::read() const { 246 258 #ifdef DUMP_READ 247 std::cerr << "read " << READ_SIGNAL(const T, get_pointer()) << " on signal " << name() << "\n"; 248 #endif 249 return READ_SIGNAL(const T, get_pointer()); 259 std::cerr << "read " << READ_SIGNAL(const data_type, get_pointer()) << " on signal " << name() << "\n"; 260 #endif 261 // QM 262 return READ_SIGNAL(T, get_pointer()); 250 263 } 251 264 … … 266 279 std::cerr << "write (posted) " << value_ << " on sc_signal (writing into register) '" << name() << "'\n"; 267 280 #endif 281 268 282 post_write(/*(tab_t*)&val*/ get_pointer(), value_); 269 283 }
Note: See TracChangeset
for help on using the changeset viewer.