#include "sim/core.hh"
#include "sim/eventq.hh"
#include "systemc/core/kernel.hh"
+#include "systemc/core/process_types.hh"
#include "systemc/core/sched_event.hh"
#include "systemc/core/scheduler.hh"
#include "systemc/ext/channel/sc_clock.hh"
{
_name += (to ? ".up_tick" : ".down_tick");
_procName = _name + ".p";
- p = newMethodProcess(_procName.c_str(), &funcWrapper);
+ p = new Method(_procName.c_str(), &funcWrapper);
+ scheduler.reg(p);
scheduler.dontInitialize(p);
}
*/
#include <memory>
+#include <string>
#include <vector>
#include "base/logging.hh"
#include "systemc/core/process_types.hh"
#include "systemc/ext/core/sc_module.hh"
#include "systemc/ext/core/sc_module_name.hh"
+#include "systemc/ext/utils/sc_report_handler.hh"
namespace sc_gem5
{
Process *
newMethodProcess(const char *name, ProcessFuncWrapper *func)
{
- Process *p = new Method(name, func);
+ Method *p = new Method(name, func);
+ if (::sc_core::sc_is_running()) {
+ std::string name = p->name();
+ delete p;
+ SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while "
+ "simulation running", name.c_str());
+ return nullptr;
+ }
scheduler.reg(p);
return p;
}
Process *
newThreadProcess(const char *name, ProcessFuncWrapper *func)
{
- Process *p = new Thread(name, func);
+ Thread *p = new Thread(name, func);
+ if (::sc_core::sc_is_running()) {
+ std::string name = p->name();
+ delete p;
+ SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while "
+ "simulation running", name.c_str());
+ return nullptr;
+ }
scheduler.reg(p);
return p;
}
Process *
newCThreadProcess(const char *name, ProcessFuncWrapper *func)
{
- Process *p = new CThread(name, func);
+ CThread *p = new CThread(name, func);
+ if (::sc_core::sc_is_running()) {
+ std::string name = p->name();
+ delete p;
+ SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while "
+ "simulation running", name.c_str());
+ return nullptr;
+ }
scheduler.reg(p);
p->dontInitialize();
return p;
#name, new ::sc_gem5::ProcessMemberFuncWrapper< \
SC_CURRENT_USER_MODULE>(this, \
&SC_CURRENT_USER_MODULE::name)); \
- this->sensitive << p; \
+ if (p) \
+ this->sensitive << p; \
}
#define SC_THREAD(name) \
{ \
#name, new ::sc_gem5::ProcessMemberFuncWrapper< \
SC_CURRENT_USER_MODULE>(this, \
&SC_CURRENT_USER_MODULE::name)); \
- this->sensitive << p; \
+ if (p) \
+ this->sensitive << p; \
}
#define SC_CTHREAD(name, clk) \
{ \
#name, new ::sc_gem5::ProcessMemberFuncWrapper< \
SC_CURRENT_USER_MODULE>(this, \
&SC_CURRENT_USER_MODULE::name)); \
- this->sensitive << p; \
- this->sensitive << clk; \
+ if (p) { \
+ this->sensitive << p; \
+ this->sensitive << clk; \
+ } \
}
// Nonstandard