Changes in sources/src/sc_signal.h [17:27]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/sc_signal.h
r17 r27 15 15 16 16 // Define registers writing method 17 #include<iostream> 18 #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_time.h" // SC_ZERO_TIME 24 #include"sc_object.h" 25 #include"sc_interface.h" 26 #include"internal_ext.h" 17 #include <iostream> 18 #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_time.h" // SC_ZERO_TIME 24 #include "sc_object.h" 25 #include "sc_interface.h" 26 #include "internal_ext.h" 27 28 #ifdef CONFIG_CHECK_FSM_RULES 27 29 #include "fsm_rules.h" 30 #endif 28 31 29 32 namespace sc_core { … … 42 45 ///////////////////// DEPRECATED 43 46 // C ANSI-only since it is needed to link with extern "C" 44 // this declaration is not in casc.h since the C HECK_FSM_RULES macro47 // this declaration is not in casc.h since the CONFIG_CHECK_FSM_RULES macro 45 48 // is not defined. 46 49 … … 79 82 size_t size = (sizeof (T)-1) / sizeof (base_type); 80 83 size_t i = 0; 81 const base_type *pvalue = (const base_type*)( &value_);84 const base_type *pvalue = (const base_type*)(void*)(&value_); 82 85 do { 83 86 #if 0 … … 91 94 const T value_) 92 95 { 93 96 if (sizeof (T) > sizeof (base_type)) { 94 97 #if 0 95 cout << "sizeof (T) = " << sizeof (T) << " (base_type = " << sizeof96 (base_type) << "\n";97 #endif 98 99 100 #if defined( DEBUG)101 102 103 104 105 106 107 108 #endif // DEBUG109 pending_write_vector[pending_write_vector_nb].pointer = pointer_;98 std::cout << "sizeof (T) = " << sizeof (T) 99 << " (base_type = " << sizeof (base_type) << "\n"; 100 #endif 101 post_multiwrite (pointer_,value_); 102 } else { 103 #if defined(CONFIG_DEBUG) 104 if (pending_write_vector_nb >= pending_write_vector_capacity) { 105 //if (pending_write_vector_nb >= pending_write_vector_capacity * sizeof(pending_write)) { 106 std::cerr << "Error : The array for posted writing on register is too small.\n"; 107 std::cerr << "Up to 1 writing per register is allowed during a cycle.\n"; 108 std::cerr << "Please check the hardware description.\n"; 109 exit (-1); 110 } 111 #endif // CONFIG_DEBUG 112 pending_write_vector[pending_write_vector_nb].pointer = pointer_; 110 113 // 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 !114 pending_write_vector[pending_write_vector_nb++].value = value_; // => bug avec blues ! 112 115 113 116 // -> fix to use user-defined struct in sc_signal/sc_in/sc_out/sc_inout … … 121 124 return; 122 125 #endif 123 126 }; 124 127 } 125 128 126 129 inline bool is_posted_write () 127 130 { 128 131 return pending_write_vector_nb > 0; 129 132 } 130 133 … … 139 142 class sc_signal_base : public sc_object, public sc_interface 140 143 { 141 142 144 ////// 145 // Internal 143 146 friend class sc_clock; 144 147 friend class sc_port_base; 145 148 void init (); 146 149 ////// 147 150 148 151 … … 158 161 sc_signal_base(const char* name_); 159 162 sc_signal_base(const char* name_, void*); 160 163 ~sc_signal_base(); 161 164 }; 162 165 … … 165 168 { 166 169 private: 167 168 typedef T data_type;170 T val; 171 typedef T data_type; 169 172 typedef sc_signal < T > this_type; 170 /////////// 171 // Internal 172 public: void init (); 173 /////////// 174 // virtual void update (); 173 174 /////////// 175 // Internal 176 public: void init (); 177 /////////// 178 179 // virtual void update (); 175 180 void check_writer (); 176 181 public: 177 182 // constructors, destructor 178 183 sc_signal () 179 184 { init (); } 180 185 explicit sc_signal (const char *name_): sc_signal_base(name_) 181 186 { init (); } 182 187 /*virtual */~ sc_signal () 183 188 {} … … 227 232 sc_signal<T>::init() 228 233 { 229 set_pointer ((tab_t*)&val);234 set_pointer ((tab_t*)(void*)&val); 230 235 set_kind (kind_string); 231 236 sc_interface::init (sizeof (data_type)); 232 237 val = 0; /* The simulator initializes the signal/register to 0. */ 233 238 /* However, hardware initialization still has to be done. */ … … 245 250 << " on signal " << name () << "\n"; 246 251 #endif 247 #ifdef C HECK_FSM_RULES252 #ifdef CONFIG_CHECK_FSM_RULES 248 253 // we can read value from sc_signal type (used like a register) at any time 249 254 #endif … … 257 262 sc_signal<T>::write( const data_type& value_ ) 258 263 { 259 #ifdef C HECK_FSM_RULES264 #ifdef CONFIG_CHECK_FSM_RULES 260 265 if ((casc_fsm_step != TRANSITION) 261 266 && ( casc_fsm_step != STIMULI)) { … … 266 271 } 267 272 #endif 268 #ifdef DEBUG273 #ifdef CONFIG_DEBUG 269 274 if (get_pointer() == NULL) 270 275 { … … 273 278 } 274 279 #endif 275 #ifdef C HECK_MULTIWRITING2REGISTER280 #ifdef CONFIG_CHECK_MULTIWRITING2REGISTER 276 281 pending_writing2register_record_and_check (get_pointer ()); 277 282 #endif
Note: See TracChangeset
for help on using the changeset viewer.