Changeset 52 for sources/src/sc_module.cc
- Timestamp:
- Jan 22, 2013, 4:23:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/sc_module.cc
r35 r52 49 49 #include "entity.h" 50 50 #include <cassert> 51 51 52 #ifdef HAVE_CONFIG_H 52 53 #include "config.h" … … 62 63 63 64 namespace sc_core { 65 64 66 instances_set_t instances_set; 65 67 instances_list_t temp_list; 66 68 method_process_list_t method_process_list; 67 68 69 module_name_stack_t module_name_stack; 69 70 70 modules_stack_t modules_stack; 71 72 method_process_t *method; 73 74 void 75 declare_method_process (const char * name, 76 SC_ENTRY_FUNC func, 77 sc_module& module) 78 { 79 method = create_method_process (name, func, module); 71 method_process_t * method; 72 73 void declare_method_process(const char * name, SC_ENTRY_FUNC func, sc_module & module) { 74 method = create_method_process(name, func, module); 80 75 method_process_list.push_back(method); 81 76 } 82 77 83 78 84 ostream& 85 operator << (ostream &o, 86 instances_set_t &l) 87 { 79 ostream & operator << (ostream &o, instances_set_t &l) { 88 80 instances_set_t::iterator i; 89 for (i = l.begin (); i != l.end(); ++i) {90 o << (*i)->name 91 } ;81 for (i = l.begin(); i != l.end(); ++i) { 82 o << (*i)->name() << " "; 83 } 92 84 return o << endl; 93 85 } 94 86 87 95 88 template <typename T> 96 static 97 std::ostream& 98 operator << (std::ostream &o, 99 const list<T> &l) 100 { 89 static std::ostream& operator << (std::ostream & o, const list<T> &l) { 101 90 typename list<T>::const_iterator i; 102 for (i = l.begin (); i != l.end(); ++i) {91 for (i = l.begin(); i != l.end(); ++i) { 103 92 o << (*i) << " "; 104 } ;93 } 105 94 return o << endl; 106 95 } 107 96 97 108 98 template <typename T> 109 static 110 std::ostream& 111 operator << (std::ostream &o, 112 const list<T*> &l) 113 { 114 typename list<T*>::const_iterator i; 115 for (i = l.begin (); i != l.end (); ++i) { 99 static std::ostream& operator << (std::ostream &o, const list<T *> &l) { 100 typename list<T *>::const_iterator i; 101 for (i = l.begin(); i != l.end(); ++i) { 116 102 o << (**i) << " "; 117 } ;103 } 118 104 return o << endl; 119 105 } 120 106 121 bool 122 is_clock (const sc_interface &inter) 123 { 124 equi_t &e = get_equi(inter);125 equi_t::iterator i; 126 for (i = e.begin (); i != e.end (); ++i) {127 if (i->kind () == sc_clock::kind_string) 128 return true; 129 130 107 108 bool is_clock (const sc_interface & inter) { 109 equi_t & e = get_equi(inter); 110 equi_t::iterator i; 111 for (i = e.begin(); i != e.end(); ++i) { 112 if (i->kind() == sc_clock::kind_string) { 113 return true; 114 } 115 } 116 return false; 131 117 } 132 118 … … 136 122 // 137 123 // ---------------------------------------------------------------------------- 138 method_process_t::method_process_t(const char* nm, SC_ENTRY_FUNC fn, sc_module& mod) 139 { 124 method_process_t::method_process_t(const char * nm, SC_ENTRY_FUNC fn, sc_module & mod) { 140 125 name = nm; 141 126 func = fn; … … 144 129 } 145 130 146 static 147 bool 148 is_register (const sc_interface &inter) 149 { 150 equi_t &e = get_equi (inter); 151 if (e.size () != 1) 152 return false; 153 sc_object &obj = *(e.begin ()->object); 154 if (obj.kind () != sc_signal_base::kind_string) 155 return false; 156 return true; 157 } 158 159 bool method_process_t::is_combinational(void) 160 { 161 if (sensitivity_list.empty ()) 162 return false; 163 sensitivity_list_t::iterator i; 164 for (i = sensitivity_list.begin (); i != sensitivity_list.end (); ++i) { 131 132 static bool is_register (const sc_interface & inter) { 133 equi_t & e = get_equi(inter); 134 if (e.size() != 1) { 135 return false; 136 } 137 138 sc_object & obj = *(e.begin()->object); 139 if (obj.kind() != sc_signal_base::kind_string) { 140 return false; 141 } 142 return true; 143 } 144 145 146 bool method_process_t::is_combinational(void) { 147 if (sensitivity_list.empty()) { 148 return false; 149 } 150 sensitivity_list_t::iterator i; 151 for (i = sensitivity_list.begin(); i != sensitivity_list.end(); ++i) { 165 152 #if defined(CONFIG_DEBUG) && 0 166 if (i->get_interface() == NULL) 167 { 168 cerr << "'" << i << "' is unbound.\n"; 169 exit (121); 170 } 153 if (i->get_interface() == NULL) { 154 cerr << "'" << i << "' is unbound.\n"; 155 exit(121); 156 } 171 157 #endif 172 if ((i->get_flag() == sc_event::VAL) 173 && (!is_register (i->get_interface()))) 174 return true; 175 } 176 return false; 177 } 178 179 bool method_process_t::is_transition(void) 180 { 181 if (sensitivity_list.empty ()) 182 return false; 183 sensitivity_list_t::iterator i; 184 for (i = sensitivity_list.begin (); i != sensitivity_list.end (); ++i) { 185 if (i->get_flag () != sc_event::POS) 186 return false; 187 // check if the port is a clock 188 if (is_clock (i->get_interface ()) == false) 189 return false; 190 } 191 return true; 192 } 193 194 bool method_process_t::is_genmoore(void) 195 { 196 // sensitivity list of moore functions includes : 197 // - register (signal unconnected) 198 // - negative edge of port which is bound to a clock signal 199 if (sensitivity_list.empty ()) 200 return false; 201 sensitivity_list_t::iterator i; 202 for (i = sensitivity_list.begin (); i != sensitivity_list.end (); ++i) { 203 if ((i->get_flag () == sc_event::VAL) 204 && (is_register(i->get_interface ()))) 205 continue; 206 if ((i->get_flag () == sc_event::NEG) 207 && (is_clock (i->get_interface ()) == true)) 208 continue; 209 return false; 210 } 211 return true; 212 } 213 214 std::ostream& operator << (std::ostream &o, const method_process_t &m) 215 { 216 return o << *(m.module) 217 << "->" 218 << m.name 219 << "() when " 220 << m.sensitivity_list; 221 } 158 if ((i->get_flag() == sc_event::VAL) && (!is_register(i->get_interface()))) { 159 return true; 160 } 161 } 162 return false; 163 } 164 165 166 bool method_process_t::is_transition(void) { 167 if (sensitivity_list.empty()) { 168 return false; 169 } 170 sensitivity_list_t::iterator i; 171 for (i = sensitivity_list.begin(); i != sensitivity_list.end(); ++i) { 172 if (i->get_flag() != sc_event::POS) { 173 return false; 174 } 175 // check if the port is a clock 176 if (is_clock(i->get_interface()) == false) { 177 return false; 178 } 179 } 180 return true; 181 } 182 183 184 bool method_process_t::is_genmoore(void) { 185 // sensitivity list of moore functions includes : 186 // - register (signal unconnected) 187 // - negative edge of port which is bound to a clock signal 188 if (sensitivity_list.empty()) { 189 return false; 190 } 191 sensitivity_list_t::iterator i; 192 for (i = sensitivity_list.begin(); i != sensitivity_list.end(); ++i) { 193 if ((i->get_flag() == sc_event::VAL) && (is_register(i->get_interface()))) { 194 continue; 195 } 196 if ((i->get_flag() == sc_event::NEG) && (is_clock(i->get_interface()) == true)) { 197 continue; 198 } 199 return false; 200 } 201 return true; 202 } 203 204 205 std::ostream & operator << (std::ostream & o, const method_process_t & m) { 206 return o << *(m.module) 207 << "->" 208 << m.name 209 << "() when " 210 << m.sensitivity_list; 211 } 212 222 213 223 214 // ---------------------------------------------------------------------------- … … 227 218 228 219 229 sc_module::sc_module(void) 230 : sc_object (NULL), 231 sensitive (this) 220 sc_module::sc_module(void) : 221 sc_object(NULL), 222 sensitive(this) { 223 init(); 224 } 225 226 sc_module::sc_module(const char * nm) : 227 sc_object(NULL), 228 sensitive(this) { 229 assert(nm != NULL); 230 init(); 231 } 232 233 234 sc_module::sc_module(const sc_module_name & nm) : 235 sc_object(NULL), 236 sensitive(this) { 237 init(); 238 } 239 240 241 void sc_module::init() { 242 instances_set.insert(this); 243 temp_list.push_back(this); 244 modules_stack.top() = this; 245 set_save_handler(*this, NULL); 246 } 247 248 void sc_module::dont_initialize() { 249 sc_core::valid_method_process(); 250 } 251 252 253 void declare_save_handler(const char * name, save_fct_t1 func, sc_module & module) { 254 sc_core::set_save_handler(module, func); 255 } 256 257 typedef std::list<sc_port_base*> port_list_t; 258 259 // Build a port list owned by the module mod 260 static void get_port_list(const sc_module & mod, port_list_t & pl) { 261 port2module_t::iterator i; 262 for (i = port2module.begin(); i != port2module.end(); ++i) { 263 if (i->second == &mod) { 264 pl.push_back((sc_port_base *) (i->first)); 265 } 266 } 267 } 268 269 270 #define BIND(sig) bind(*this, p, port_list, sig) 271 272 static void bind(sc_module & mod, 273 port_list_t::iterator & port_it, 274 port_list_t & port_list, 275 sc_bind_proxy & sig) { 276 if (&sig == &SC_BIND_PROXY_NIL) { 277 return; 278 } 279 if (port_it == port_list.end()) { 280 cerr << "error : binding port in "; 281 cerr << mod.name(); 282 cerr << " module.\n"; 283 exit(7); 284 } 285 bind(**(port_it++), sig); 286 } 287 288 289 void sc_module::operator () ( /* const */ sc_bind_proxy & p001, 290 /* const */ sc_bind_proxy & p002, 291 /* const */ sc_bind_proxy & p003, 292 /* const */ sc_bind_proxy & p004, 293 /* const */ sc_bind_proxy & p005, 294 /* const */ sc_bind_proxy & p006, 295 /* const */ sc_bind_proxy & p007, 296 /* const */ sc_bind_proxy & p008, 297 /* const */ sc_bind_proxy & p009, 298 /* const */ sc_bind_proxy & p010, 299 /* const */ sc_bind_proxy & p011, 300 /* const */ sc_bind_proxy & p012, 301 /* const */ sc_bind_proxy & p013, 302 /* const */ sc_bind_proxy & p014, 303 /* const */ sc_bind_proxy & p015, 304 /* const */ sc_bind_proxy & p016, 305 /* const */ sc_bind_proxy & p017, 306 /* const */ sc_bind_proxy & p018, 307 /* const */ sc_bind_proxy & p019, 308 /* const */ sc_bind_proxy & p020, 309 /* const */ sc_bind_proxy & p021, 310 /* const */ sc_bind_proxy & p022, 311 /* const */ sc_bind_proxy & p023, 312 /* const */ sc_bind_proxy & p024, 313 /* const */ sc_bind_proxy & p025, 314 /* const */ sc_bind_proxy & p026, 315 /* const */ sc_bind_proxy & p027, 316 /* const */ sc_bind_proxy & p028, 317 /* const */ sc_bind_proxy & p029, 318 /* const */ sc_bind_proxy & p030, 319 /* const */ sc_bind_proxy & p031, 320 /* const */ sc_bind_proxy & p032, 321 /* const */ sc_bind_proxy & p033, 322 /* const */ sc_bind_proxy & p034, 323 /* const */ sc_bind_proxy & p035, 324 /* const */ sc_bind_proxy & p036, 325 /* const */ sc_bind_proxy & p037, 326 /* const */ sc_bind_proxy & p038, 327 /* const */ sc_bind_proxy & p039, 328 /* const */ sc_bind_proxy & p040, 329 /* const */ sc_bind_proxy & p041, 330 /* const */ sc_bind_proxy & p042, 331 /* const */ sc_bind_proxy & p043, 332 /* const */ sc_bind_proxy & p044, 333 /* const */ sc_bind_proxy & p045, 334 /* const */ sc_bind_proxy & p046, 335 /* const */ sc_bind_proxy & p047, 336 /* const */ sc_bind_proxy & p048, 337 /* const */ sc_bind_proxy & p049, 338 /* const */ sc_bind_proxy & p050, 339 /* const */ sc_bind_proxy & p051, 340 /* const */ sc_bind_proxy & p052, 341 /* const */ sc_bind_proxy & p053, 342 /* const */ sc_bind_proxy & p054, 343 /* const */ sc_bind_proxy & p055, 344 /* const */ sc_bind_proxy & p056, 345 /* const */ sc_bind_proxy & p057, 346 /* const */ sc_bind_proxy & p058, 347 /* const */ sc_bind_proxy & p059, 348 /* const */ sc_bind_proxy & p060, 349 /* const */ sc_bind_proxy & p061, 350 /* const */ sc_bind_proxy & p062, 351 /* const */ sc_bind_proxy & p063, 352 /* const */ sc_bind_proxy & p064) 232 353 { 233 #if 0 234 cerr << "sc_module constructor with no parameter\n"; 235 #endif 236 init (); 237 } 238 239 sc_module::sc_module(const char* nm) 240 : sc_object (NULL), 241 sensitive (this) 242 { 243 assert(nm != NULL); 244 #if 0 245 cerr << "sc_module constructor with const char * parameter\n"; 246 #endif 247 init (); 248 } 249 250 251 sc_module::sc_module(const sc_module_name &nm) 252 : sc_object (NULL), 253 sensitive (this) 254 { 255 #if 0 256 cerr << "sc_module constructor by copy\n"; 257 #endif 258 init (); 259 } 260 261 void 262 sc_module::init () 263 { 264 instances_set.insert (this); 265 temp_list.push_back (this); 266 modules_stack.top () = this; 267 set_save_handler (*this, NULL); 268 #if 0 269 cout << "sc_module <- " << this->name () << endl; 270 #endif 271 } 272 273 void 274 sc_module::dont_initialize () 275 { 276 sc_core::valid_method_process (); 277 } 278 279 280 void 281 declare_save_handler (const char * name, 282 save_fct_t1 func, 283 sc_module& module) 284 { 285 sc_core::set_save_handler (module, func); 286 } 287 288 typedef std::list<sc_port_base*> port_list_t; 289 290 // Build a port list owned by the module mod 291 static void 292 get_port_list (const sc_module &mod, port_list_t &pl) 293 { 294 port2module_t::iterator i; 295 for (i = port2module.begin (); i != port2module.end (); ++i) { 296 if (i->second == &mod) { 297 pl.push_back ((sc_port_base*)(i->first)); 298 } 299 } 300 } 301 302 303 #define BIND(sig) bind(*this, p, port_list, sig) 304 305 static void 306 bind (sc_module &mod, 307 port_list_t::iterator &port_it, 308 port_list_t &port_list, 309 sc_bind_proxy &sig) 310 { 311 if (&sig == &SC_BIND_PROXY_NIL) { 312 return; 313 }; 314 if (port_it == port_list.end ()) { 315 cerr << "error : binding port in "; 316 cerr << mod.name (); 317 cerr << " module.\n"; 318 exit (7); 319 }; 320 bind (**(port_it++), sig); 321 } 322 323 void 324 sc_module::operator () ( /* const */ sc_bind_proxy& p001, 325 /* const */ sc_bind_proxy& p002, 326 /* const */ sc_bind_proxy& p003, 327 /* const */ sc_bind_proxy& p004, 328 /* const */ sc_bind_proxy& p005, 329 /* const */ sc_bind_proxy& p006, 330 /* const */ sc_bind_proxy& p007, 331 /* const */ sc_bind_proxy& p008, 332 /* const */ sc_bind_proxy& p009, 333 /* const */ sc_bind_proxy& p010, 334 /* const */ sc_bind_proxy& p011, 335 /* const */ sc_bind_proxy& p012, 336 /* const */ sc_bind_proxy& p013, 337 /* const */ sc_bind_proxy& p014, 338 /* const */ sc_bind_proxy& p015, 339 /* const */ sc_bind_proxy& p016, 340 /* const */ sc_bind_proxy& p017, 341 /* const */ sc_bind_proxy& p018, 342 /* const */ sc_bind_proxy& p019, 343 /* const */ sc_bind_proxy& p020, 344 /* const */ sc_bind_proxy& p021, 345 /* const */ sc_bind_proxy& p022, 346 /* const */ sc_bind_proxy& p023, 347 /* const */ sc_bind_proxy& p024, 348 /* const */ sc_bind_proxy& p025, 349 /* const */ sc_bind_proxy& p026, 350 /* const */ sc_bind_proxy& p027, 351 /* const */ sc_bind_proxy& p028, 352 /* const */ sc_bind_proxy& p029, 353 /* const */ sc_bind_proxy& p030, 354 /* const */ sc_bind_proxy& p031, 355 /* const */ sc_bind_proxy& p032, 356 /* const */ sc_bind_proxy& p033, 357 /* const */ sc_bind_proxy& p034, 358 /* const */ sc_bind_proxy& p035, 359 /* const */ sc_bind_proxy& p036, 360 /* const */ sc_bind_proxy& p037, 361 /* const */ sc_bind_proxy& p038, 362 /* const */ sc_bind_proxy& p039, 363 /* const */ sc_bind_proxy& p040, 364 /* const */ sc_bind_proxy& p041, 365 /* const */ sc_bind_proxy& p042, 366 /* const */ sc_bind_proxy& p043, 367 /* const */ sc_bind_proxy& p044, 368 /* const */ sc_bind_proxy& p045, 369 /* const */ sc_bind_proxy& p046, 370 /* const */ sc_bind_proxy& p047, 371 /* const */ sc_bind_proxy& p048, 372 /* const */ sc_bind_proxy& p049, 373 /* const */ sc_bind_proxy& p050, 374 /* const */ sc_bind_proxy& p051, 375 /* const */ sc_bind_proxy& p052, 376 /* const */ sc_bind_proxy& p053, 377 /* const */ sc_bind_proxy& p054, 378 /* const */ sc_bind_proxy& p055, 379 /* const */ sc_bind_proxy& p056, 380 /* const */ sc_bind_proxy& p057, 381 /* const */ sc_bind_proxy& p058, 382 /* const */ sc_bind_proxy& p059, 383 /* const */ sc_bind_proxy& p060, 384 /* const */ sc_bind_proxy& p061, 385 /* const */ sc_bind_proxy& p062, 386 /* const */ sc_bind_proxy& p063, 387 /* const */ sc_bind_proxy& p064 ) 388 { 389 port_list_t port_list; 390 get_port_list (*this,port_list); 391 cerr << "port list : " << port_list << endl; 392 port_list_t::iterator p = port_list.begin (); 393 BIND( p001 ); 394 BIND( p002 ); 395 BIND( p003 ); 396 BIND( p004 ); 397 BIND( p005 ); 398 BIND( p006 ); 399 BIND( p007 ); 400 BIND( p008 ); 401 BIND( p009 ); 402 BIND( p010 ); 403 BIND( p011 ); 404 BIND( p012 ); 405 BIND( p013 ); 406 BIND( p014 ); 407 BIND( p015 ); 408 BIND( p016 ); 409 BIND( p017 ); 410 BIND( p018 ); 411 BIND( p019 ); 412 BIND( p020 ); 413 BIND( p021 ); 414 BIND( p022 ); 415 BIND( p023 ); 416 BIND( p024 ); 417 BIND( p025 ); 418 BIND( p026 ); 419 BIND( p027 ); 420 BIND( p028 ); 421 BIND( p029 ); 422 BIND( p030 ); 423 BIND( p031 ); 424 BIND( p032 ); 425 BIND( p033 ); 426 BIND( p034 ); 427 BIND( p035 ); 428 BIND( p036 ); 429 BIND( p037 ); 430 BIND( p038 ); 431 BIND( p039 ); 432 BIND( p040 ); 433 BIND( p041 ); 434 BIND( p042 ); 435 BIND( p043 ); 436 BIND( p044 ); 437 BIND( p045 ); 438 BIND( p046 ); 439 BIND( p047 ); 440 BIND( p048 ); 441 BIND( p049 ); 442 BIND( p050 ); 443 BIND( p051 ); 444 BIND( p052 ); 445 BIND( p053 ); 446 BIND( p054 ); 447 BIND( p055 ); 448 BIND( p056 ); 449 BIND( p057 ); 450 BIND( p058 ); 451 BIND( p059 ); 452 BIND( p060 ); 453 BIND( p061 ); 454 BIND( p062 ); 455 BIND( p063 ); 456 BIND( p064 ); 457 } 458 459 ostream& operator << (ostream &o, const sc_module &m) 460 { 461 return o << m.name (); 462 } 354 port_list_t port_list; 355 get_port_list(*this, port_list); 356 cerr << "port list : " << port_list << endl; 357 port_list_t::iterator p = port_list.begin(); 358 BIND(p001); 359 BIND(p002); 360 BIND(p003); 361 BIND(p004); 362 BIND(p005); 363 BIND(p006); 364 BIND(p007); 365 BIND(p008); 366 BIND(p009); 367 BIND(p010); 368 BIND(p011); 369 BIND(p012); 370 BIND(p013); 371 BIND(p014); 372 BIND(p015); 373 BIND(p016); 374 BIND(p017); 375 BIND(p018); 376 BIND(p019); 377 BIND(p020); 378 BIND(p021); 379 BIND(p022); 380 BIND(p023); 381 BIND(p024); 382 BIND(p025); 383 BIND(p026); 384 BIND(p027); 385 BIND(p028); 386 BIND(p029); 387 BIND(p030); 388 BIND(p031); 389 BIND(p032); 390 BIND(p033); 391 BIND(p034); 392 BIND(p035); 393 BIND(p036); 394 BIND(p037); 395 BIND(p038); 396 BIND(p039); 397 BIND(p040); 398 BIND(p041); 399 BIND(p042); 400 BIND(p043); 401 BIND(p044); 402 BIND(p045); 403 BIND(p046); 404 BIND(p047); 405 BIND(p048); 406 BIND(p049); 407 BIND(p050); 408 BIND(p051); 409 BIND(p052); 410 BIND(p053); 411 BIND(p054); 412 BIND(p055); 413 BIND(p056); 414 BIND(p057); 415 BIND(p058); 416 BIND(p059); 417 BIND(p060); 418 BIND(p061); 419 BIND(p062); 420 BIND(p063); 421 BIND(p064); 422 } 423 424 425 ostream & operator << (ostream & o, const sc_module & m) { 426 return o << m.name(); 427 } 428 463 429 464 430 // ---------------------------------------------------------------------------- … … 467 433 // ---------------------------------------------------------------------------- 468 434 469 sc_module_name::sc_module_name( const char* name_ ) 470 : m_pushed(true) 471 { 472 #if 0 473 cerr << "sc_module_name constructor with const char * parameter\n"; 435 sc_module_name::sc_module_name(const char * name_) : m_pushed(true) { 436 m_name = name_; 437 init(); 438 } 439 440 441 sc_module_name::sc_module_name(const sc_module_name & module) : m_pushed(false) { 442 m_name = module.m_name; 443 } 444 445 446 void sc_module_name::init() { 447 sc_core::module_name_stack.push_back(m_name); 448 modules_stack.push(NULL); 449 } 450 451 452 sc_module_name::~sc_module_name() { 453 if (m_pushed == false) { 454 return; 455 } 456 assert(sc_core::module_name_stack.empty() == false); 457 sc_core::module_name_stack.pop_back(); 458 modules_stack.pop(); 459 assert(temp_list.empty() == false); 460 sc_module * last1 = temp_list.back(); 461 temp_list.pop_back(); 462 sc_module * last2 = (temp_list.empty()) ? NULL : temp_list.back(); 463 set_parent(*last1, last2); 464 } 465 466 467 std::ostream & operator << (std::ostream & o, const sc_core::sc_module_name & n) { 468 return o << (const char *) n; 469 } 470 471 /////////////////////////////////////////: 472 473 static void check_method_process(const method_process_t & m) { 474 if (m.dont_initialize == false) { 475 assert(m.module != NULL); 476 #ifdef CONFIG_DEBUG 477 std::cerr << "Warning : SystemCASS doesn't perform SC_METHOD(S) initializations.\n" 478 << "Please turn off automatic initialization for '" << m.name 479 << "' method of '" << m.module->name() << "' module" 480 " by calling 'dont_initialize()' function.\n" 481 "Example :\n" 482 " SC_METHOD(transition);\n" 483 " sensitive << clk;\n" 484 " dont_initialize();\n"; 474 485 #endif 475 m_name = name_; 476 init (); 477 } 478 479 sc_module_name::sc_module_name( const sc_module_name &module ) 480 : m_pushed(false) 481 { 482 #if 0 483 cerr << "sc_module_name constructor by copy\n"; 484 #endif 485 m_name = module.m_name; 486 //init (); 487 } 488 489 void 490 sc_module_name::init () 491 { 492 sc_core::module_name_stack.push_back (m_name); 493 modules_stack.push (NULL); 494 #if 0 495 cout << "module_name <- " << m_name << endl; 496 #endif 497 } 498 499 sc_module_name::~sc_module_name () 500 { 501 if (m_pushed == false) 502 return; 503 assert(sc_core::module_name_stack.empty () == false); 504 sc_core::module_name_stack.pop_back (); 505 modules_stack.pop (); 506 #if 0 507 cout << "~sc_module_name <- " << m_name << endl; 508 #endif 509 assert(temp_list.empty () == false); 510 sc_module *last1 = temp_list.back(); 511 temp_list.pop_back(); 512 sc_module *last2 = (temp_list.empty())?NULL:temp_list.back(); 513 set_parent (*last1, last2); 514 } 515 516 std::ostream& 517 operator << (std::ostream& o, 518 const sc_core::sc_module_name &n) 519 { 520 return o << (const char*)n; 521 } 522 523 /////////////////////////////////////////: 524 525 static 526 void 527 check_method_process (const method_process_t &m) 528 { 529 if (m.dont_initialize == false) 530 { 531 assert(m.module != NULL); 532 #ifdef CONFIG_DEBUG 533 std::cerr << "Warning : SystemCASS doesn't perform SC_METHOD(S) initializations.\n" 534 << "Please turn off automatic initialization for '" << m.name 535 << "' method of '" << m.module->name () << "' module" 536 " by calling 'dont_initialize()' function.\n" 537 "Example :\n" 538 " SC_METHOD(transition);\n" 539 " sensitive << clk;\n" 540 " dont_initialize ();\n"; 541 #endif 542 #if 0 543 exit (250405); 544 #endif 545 } 546 } 547 548 void 549 check_all_method_process () 550 { 551 method_process_list_t::const_iterator i; 552 for (i = sc_core::method_process_list.begin(); 553 i != sc_core::method_process_list.end (); 554 ++i) 555 { 556 check_method_process (**i); 557 } 558 } 559 560 void 561 valid_method_process () 562 { 563 method_process_t *m = sc_core::method_process_list.back(); 564 m->dont_initialize = true; 565 } 566 567 method_process_t* 568 create_method_process (const char * name, 569 SC_ENTRY_FUNC func, 570 sc_module& module) 571 { 572 return new method_process_t (name, func, module); 573 } 486 } 487 } 488 489 490 void check_all_method_process() { 491 method_process_list_t::const_iterator i; 492 for (i = sc_core::method_process_list.begin(); i != sc_core::method_process_list.end(); ++i) { 493 check_method_process(**i); 494 } 495 } 496 497 498 void valid_method_process() { 499 method_process_t * m = sc_core::method_process_list.back(); 500 m->dont_initialize = true; 501 } 502 503 504 method_process_t * create_method_process(const char * name, SC_ENTRY_FUNC func, sc_module & module) { 505 return new method_process_t(name, func, module); 506 } 507 574 508 575 509 } // end of sc_core namespace 576 510 511 /* 512 # Local Variables: 513 # tab-width: 4; 514 # c-basic-offset: 4; 515 # c-file-offsets:((innamespace . 0)(inline-open . 0)); 516 # indent-tabs-mode: nil; 517 # End: 518 # 519 # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 520 */ 521
Note: See TracChangeset
for help on using the changeset viewer.