sc_module.cc (13315:baeb753a3f10) | sc_module.cc (13317:36c574a4036e) |
---|---|
1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 29 unchanged lines hidden (view full) --- 38#include "systemc/core/object.hh" 39#include "systemc/core/port.hh" 40#include "systemc/core/process_types.hh" 41#include "systemc/core/sensitivity.hh" 42#include "systemc/ext/channel/sc_in.hh" 43#include "systemc/ext/channel/sc_inout.hh" 44#include "systemc/ext/channel/sc_out.hh" 45#include "systemc/ext/channel/sc_signal_in_if.hh" | 1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 29 unchanged lines hidden (view full) --- 38#include "systemc/core/object.hh" 39#include "systemc/core/port.hh" 40#include "systemc/core/process_types.hh" 41#include "systemc/core/sensitivity.hh" 42#include "systemc/ext/channel/sc_in.hh" 43#include "systemc/ext/channel/sc_inout.hh" 44#include "systemc/ext/channel/sc_out.hh" 45#include "systemc/ext/channel/sc_signal_in_if.hh" |
46#include "systemc/ext/core/messages.hh" |
|
46#include "systemc/ext/core/sc_module.hh" 47#include "systemc/ext/core/sc_module_name.hh" 48#include "systemc/ext/dt/bit/sc_logic.hh" 49#include "systemc/ext/utils/sc_report_handler.hh" 50 51namespace sc_gem5 52{ 53 54Process * 55newMethodProcess(const char *name, ProcessFuncWrapper *func) 56{ 57 Method *p = new Method(name, func); 58 if (::sc_core::sc_is_running()) { 59 std::string name = p->name(); 60 delete p; | 47#include "systemc/ext/core/sc_module.hh" 48#include "systemc/ext/core/sc_module_name.hh" 49#include "systemc/ext/dt/bit/sc_logic.hh" 50#include "systemc/ext/utils/sc_report_handler.hh" 51 52namespace sc_gem5 53{ 54 55Process * 56newMethodProcess(const char *name, ProcessFuncWrapper *func) 57{ 58 Method *p = new Method(name, func); 59 if (::sc_core::sc_is_running()) { 60 std::string name = p->name(); 61 delete p; |
61 SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while " 62 "simulation running", name.c_str()); | 62 SC_REPORT_ERROR(sc_core::SC_ID_MODULE_METHOD_AFTER_START_, 63 name.c_str()); |
63 return nullptr; 64 } 65 scheduler.reg(p); 66 return p; 67} 68 69Process * 70newThreadProcess(const char *name, ProcessFuncWrapper *func) 71{ 72 Thread *p = new Thread(name, func); 73 if (::sc_core::sc_is_running()) { 74 std::string name = p->name(); 75 delete p; | 64 return nullptr; 65 } 66 scheduler.reg(p); 67 return p; 68} 69 70Process * 71newThreadProcess(const char *name, ProcessFuncWrapper *func) 72{ 73 Thread *p = new Thread(name, func); 74 if (::sc_core::sc_is_running()) { 75 std::string name = p->name(); 76 delete p; |
76 SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while " 77 "simulation running", name.c_str()); | 77 SC_REPORT_ERROR(sc_core::SC_ID_MODULE_THREAD_AFTER_START_, 78 name.c_str()); |
78 return nullptr; 79 } 80 scheduler.reg(p); 81 return p; 82} 83 84Process * 85newCThreadProcess(const char *name, ProcessFuncWrapper *func) 86{ 87 CThread *p = new CThread(name, func); 88 if (::sc_core::sc_is_running()) { 89 std::string name = p->name(); 90 delete p; | 79 return nullptr; 80 } 81 scheduler.reg(p); 82 return p; 83} 84 85Process * 86newCThreadProcess(const char *name, ProcessFuncWrapper *func) 87{ 88 CThread *p = new CThread(name, func); 89 if (::sc_core::sc_is_running()) { 90 std::string name = p->name(); 91 delete p; |
91 SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while " 92 "simulation running", name.c_str()); | 92 SC_REPORT_ERROR(sc_core::SC_ID_MODULE_CTHREAD_AFTER_START_, 93 name.c_str()); |
93 return nullptr; 94 } 95 scheduler.reg(p); 96 p->dontInitialize(true); 97 return p; 98} 99 100} // namespace sc_gem5 --- 146 unchanged lines hidden (view full) --- 247{ 248 return _gem5_module->obj()->get_child_events(); 249} 250 251sc_module::sc_module() : 252 sc_object(sc_gem5::newModuleChecked()->name()), 253 _gem5_module(sc_gem5::currentModule()) 254{ | 94 return nullptr; 95 } 96 scheduler.reg(p); 97 p->dontInitialize(true); 98 return p; 99} 100 101} // namespace sc_gem5 --- 146 unchanged lines hidden (view full) --- 248{ 249 return _gem5_module->obj()->get_child_events(); 250} 251 252sc_module::sc_module() : 253 sc_object(sc_gem5::newModuleChecked()->name()), 254 _gem5_module(sc_gem5::currentModule()) 255{ |
255 if (sc_is_running()) { 256 SC_REPORT_ERROR("(E529) insert module failed", "simulation running"); 257 std::cout << "Running!\n"; 258 } 259 if (::sc_gem5::scheduler.elaborationDone()) { 260 SC_REPORT_ERROR("(E529) insert module failed", "elaboration done"); 261 std::cout << "Elaboration done!\n"; 262 } | 256 if (sc_is_running()) 257 SC_REPORT_ERROR(SC_ID_INSERT_MODULE_, "simulation running"); 258 if (::sc_gem5::scheduler.elaborationDone()) 259 SC_REPORT_ERROR(SC_ID_INSERT_MODULE_, "elaboration done"); |
263} 264 265sc_module::sc_module(const sc_module_name &) : sc_module() {} 266sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) 267{ 268 _gem5_module->deprecatedConstructor(); | 260} 261 262sc_module::sc_module(const sc_module_name &) : sc_module() {} 263sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) 264{ 265 _gem5_module->deprecatedConstructor(); |
269 SC_REPORT_WARNING("(W569) sc_module(const char*), " 270 "sc_module(const std::string&) have been deprecated, use " 271 "sc_module(const sc_module_name&)", _name); | 266 SC_REPORT_WARNING(SC_ID_BAD_SC_MODULE_CONSTRUCTOR_, _name); |
272} 273sc_module::sc_module(const std::string &_name) : 274 sc_module(sc_module_name(_name.c_str())) 275{ 276 _gem5_module->deprecatedConstructor(); | 267} 268sc_module::sc_module(const std::string &_name) : 269 sc_module(sc_module_name(_name.c_str())) 270{ 271 _gem5_module->deprecatedConstructor(); |
277 SC_REPORT_WARNING("(W569) sc_module(const char*), " 278 "sc_module(const std::string&) have been deprecated, use " 279 "sc_module(const sc_module_name&)", _name.c_str()); | 272 SC_REPORT_WARNING(SC_ID_BAD_SC_MODULE_CONSTRUCTOR_, _name.c_str()); |
280} 281 282void 283sc_module::end_module() 284{ 285 _gem5_module->endModule(); 286} 287 --- 46 unchanged lines hidden (view full) --- 334 ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), false, val); 335} 336 337 338void 339sc_module::dont_initialize() 340{ 341 ::sc_gem5::Process *p = ::sc_gem5::Process::newest(); | 273} 274 275void 276sc_module::end_module() 277{ 278 _gem5_module->endModule(); 279} 280 --- 46 unchanged lines hidden (view full) --- 327 ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), false, val); 328} 329 330 331void 332sc_module::dont_initialize() 333{ 334 ::sc_gem5::Process *p = ::sc_gem5::Process::newest(); |
342 if (p->procKind() == SC_CTHREAD_PROC_) { 343 SC_REPORT_WARNING("(W524) dont_initialize() has no effect for " 344 "SC_CTHREADs", ""); 345 } | 335 if (p->procKind() == SC_CTHREAD_PROC_) 336 SC_REPORT_WARNING(SC_ID_DONT_INITIALIZE_, ""); |
346 p->dontInitialize(true); 347} 348 349void 350sc_module::set_stack_size(size_t size) 351{ 352 ::sc_gem5::Process::newest()->setStackSize(size); 353} --- 286 unchanged lines hidden (view full) --- 640 641namespace 642{ 643 644bool 645waitErrorCheck(sc_gem5::Process *p) 646{ 647 if (p->procKind() == SC_METHOD_PROC_) { | 337 p->dontInitialize(true); 338} 339 340void 341sc_module::set_stack_size(size_t size) 342{ 343 ::sc_gem5::Process::newest()->setStackSize(size); 344} --- 286 unchanged lines hidden (view full) --- 631 632namespace 633{ 634 635bool 636waitErrorCheck(sc_gem5::Process *p) 637{ 638 if (p->procKind() == SC_METHOD_PROC_) { |
648 SC_REPORT_ERROR( 649 "(E519) wait() is only allowed in SC_THREADs and SC_CTHREADs", | 639 SC_REPORT_ERROR(SC_ID_WAIT_NOT_ALLOWED_, |
650 "\n in SC_METHODs use next_trigger() instead"); 651 return true; 652 } 653 return false; 654} 655 656} // anonymous namespace 657 --- 8 unchanged lines hidden (view full) --- 666 sc_gem5::scheduler.yield(); 667} 668 669void 670wait(int n) 671{ 672 if (n <= 0) { 673 std::string msg = csprintf("n = %d", n); | 640 "\n in SC_METHODs use next_trigger() instead"); 641 return true; 642 } 643 return false; 644} 645 646} // anonymous namespace 647 --- 8 unchanged lines hidden (view full) --- 656 sc_gem5::scheduler.yield(); 657} 658 659void 660wait(int n) 661{ 662 if (n <= 0) { 663 std::string msg = csprintf("n = %d", n); |
674 SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str()); | 664 SC_REPORT_ERROR(SC_ID_WAIT_N_INVALID_, msg.c_str()); |
675 } 676 sc_gem5::Process *p = sc_gem5::scheduler.current(); 677 p->waitCount(n - 1); 678 wait(); 679} 680 681void 682wait(const sc_event &e) --- 138 unchanged lines hidden (view full) --- 821 while (s.read() == sc_dt::Log_1) 822 wait(); 823} 824 825const char * 826sc_gen_unique_name(const char *seed) 827{ 828 if (!seed || seed[0] == '\0') { | 665 } 666 sc_gem5::Process *p = sc_gem5::scheduler.current(); 667 p->waitCount(n - 1); 668 wait(); 669} 670 671void 672wait(const sc_event &e) --- 138 unchanged lines hidden (view full) --- 811 while (s.read() == sc_dt::Log_1) 812 wait(); 813} 814 815const char * 816sc_gen_unique_name(const char *seed) 817{ 818 if (!seed || seed[0] == '\0') { |
829 SC_REPORT_ERROR( 830 "(E532) cannot generate unique name from null string", ""); | 819 SC_REPORT_ERROR(SC_ID_GEN_UNIQUE_NAME_, ""); |
831 seed = "unnamed"; 832 } 833 834 auto mod = sc_gem5::pickParentModule(); 835 if (mod) 836 return mod->uniqueName(seed); 837 838 sc_gem5::Process *p = sc_gem5::scheduler.current(); --- 34 unchanged lines hidden --- | 820 seed = "unnamed"; 821 } 822 823 auto mod = sc_gem5::pickParentModule(); 824 if (mod) 825 return mod->uniqueName(seed); 826 827 sc_gem5::Process *p = sc_gem5::scheduler.current(); --- 34 unchanged lines hidden --- |