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