namespace sc_gem5
{
-Event::Event(sc_core::sc_event *_sc_event) : Event(_sc_event, nullptr) {}
+Event::Event(sc_core::sc_event *_sc_event, bool internal) :
+ Event(_sc_event, nullptr, internal)
+{}
-Event::Event(sc_core::sc_event *_sc_event, const char *_basename_cstr) :
+Event::Event(sc_core::sc_event *_sc_event, const char *_basename_cstr,
+ bool internal) :
_sc_event(_sc_event), _basename(_basename_cstr ? _basename_cstr : ""),
- delayedNotify([this]() { this->notify(); }), _triggeredStamp(~0ULL)
+ _inHierarchy(!internal), delayedNotify([this]() { this->notify(); }),
+ _triggeredStamp(~0ULL)
{
if (_basename == "" && ::sc_core::sc_is_running())
_basename = ::sc_core::sc_gen_unique_name("event");
- parent = pickParentObj();
+ parent = internal ? nullptr : pickParentObj();
- std::string original_name = _basename;
- _basename = pickUniqueName(parent, _basename);
-
- if (parent) {
- Object *obj = Object::getFromScObject(parent);
- obj->addChildEvent(_sc_event);
+ if (internal) {
+ _basename = globalNameGen.gen(_basename);
+ _name = _basename;
} else {
- topLevelEvents.emplace(topLevelEvents.end(), _sc_event);
- }
-
- std::string path = parent ? (std::string(parent->name()) + ".") : "";
-
- if (original_name != "" && _basename != original_name) {
- std::string message = path + original_name +
- ". Latter declaration will be renamed to " +
- path + _basename;
- SC_REPORT_WARNING("(W505) object already exists", message.c_str());
+ std::string original_name = _basename;
+ _basename = pickUniqueName(parent, _basename);
+
+ if (parent) {
+ Object *obj = Object::getFromScObject(parent);
+ obj->addChildEvent(_sc_event);
+ } else {
+ topLevelEvents.emplace(topLevelEvents.end(), _sc_event);
+ }
+
+ std::string path = parent ? (std::string(parent->name()) + ".") : "";
+
+ if (original_name != "" && _basename != original_name) {
+ std::string message = path + original_name +
+ ". Latter declaration will be renamed to " +
+ path + _basename;
+ SC_REPORT_WARNING("(W505) object already exists", message.c_str());
+ }
+
+ _name = path + _basename;
}
- _name = path + _basename;
-
allEvents.emplace(allEvents.end(), _sc_event);
// Determine if we're in the hierarchy (created once initialization starts
if (parent) {
Object *obj = Object::getFromScObject(parent);
obj->delChildEvent(_sc_event);
- } else {
+ } else if (inHierarchy()) {
EventsIt it = find(topLevelEvents.begin(), topLevelEvents.end(),
_sc_event);
assert(it != topLevelEvents.end());
bool
Event::inHierarchy() const
{
- return _name.length() != 0;
+ return _inHierarchy;
}
sc_core::sc_object *
class Event
{
public:
- Event(sc_core::sc_event *_sc_event);
- Event(sc_core::sc_event *_sc_event, const char *_basename);
+ Event(sc_core::sc_event *_sc_event, bool internal=false);
+ Event(sc_core::sc_event *_sc_event, const char *_basename,
+ bool internal=false);
~Event();
} // anonymous namespace
+UniqueNameGen globalNameGen;
+
Module::Module(const char *name) :
_name(name), _sc_mod(nullptr), _obj(nullptr), _ended(false),
_deprecatedConstructor(false), bindingIndex(0)
}
};
+extern UniqueNameGen globalNameGen;
+
class Module
{
private:
clearDynamic();
}
- ::sc_core::sc_event _resetEvent;
- ::sc_core::sc_event _terminatedEvent;
+ InternalScEvent _resetEvent;
+ InternalScEvent _terminatedEvent;
ProcessFuncWrapper *func;
sc_core::sc_curr_proc_kind _procKind;
return expr;
}
+sc_event::sc_event(bool) :
+ _gem5_event(new ::sc_gem5::Event(
+ this, sc_core::sc_gen_unique_name(
+ "$$$internal kernel event$$$"), true))
+{}
+
+sc_event::sc_event(bool, const char *_name) :
+ _gem5_event(new ::sc_gem5::Event(
+ this,
+ (std::string("$$$internal kernel event$$$") + _name).c_str(),
+ true))
+{}
+
const std::vector<sc_event *> &
sc_get_top_level_events()
{
}
} // namespace sc_core
+
+namespace sc_gem5
+{
+
+InternalScEvent::InternalScEvent() : sc_event(true) {}
+InternalScEvent::InternalScEvent(const char *_name) : sc_event(true, _name) {}
+
+} // namespace sc_gem5
sc_interface::default_event() const
{
SC_REPORT_WARNING("(W116) channel doesn't have a default event", "");
- static sc_event dummy;
+ static sc_gem5::InternalScEvent dummy;
return dummy;
}
return p;
}
-UniqueNameGen nameGen;
-
} // namespace sc_gem5
namespace sc_core
if (p)
return p->uniqueName(seed);
- return ::sc_gem5::nameGen.gen(seed);
+ return ::sc_gem5::globalNameGen.gen(seed);
}
bool
if (!_gem5_process) {
SC_REPORT_WARNING("(W570) attempt to use an empty "
"process handle ignored", "terminated_event()");
- static sc_event non_event;
+ static sc_gem5::InternalScEvent non_event;
return non_event;
}
return _gem5_process->terminatedEvent();
if (!_gem5_process) {
SC_REPORT_WARNING("(W570) attempt to use an empty "
"process handle ignored", "reset()");
- static sc_event non_event;
+ static sc_gem5::InternalScEvent non_event;
return non_event;
}
return _gem5_process->resetEvent();
private:
void _trigger();
- sc_event _defaultEvent;
+ sc_gem5::InternalScEvent _defaultEvent;
std::priority_queue<
sc_time, std::vector<sc_time>, std::greater<sc_time> > _times;
};
{}
sc_fifo &operator = (const sc_fifo<T> &) { return *this; }
- sc_event _dataReadEvent;
- sc_event _dataWriteEvent;
+ sc_gem5::InternalScEvent _dataReadEvent;
+ sc_gem5::InternalScEvent _dataWriteEvent;
sc_port_base *_reader;
sc_port_base *_writer;
sc_mutex &operator = (const sc_mutex &) { return *this; }
sc_process_handle holder;
- sc_event unlockEvent;
+ sc_gem5::InternalScEvent unlockEvent;
};
} // namespace sc_core
sc_semaphore &operator = (const sc_semaphore &) { return *this; }
int _value;
- sc_event posted;
+ sc_gem5::InternalScEvent posted;
};
} // namespace sc_core
virtual sc_core::sc_writer_policy get_writer_policy() const = 0;
- sc_core::sc_event _valueChangedEvent;
+ InternalScEvent _valueChangedEvent;
uint64_t _changeStamp;
sc_core::sc_port_base *_gem5WriterPort;
};
bool posedge() const;
bool negedge() const;
- sc_core::sc_event _posedgeEvent;
- sc_core::sc_event _negedgeEvent;
+ InternalScEvent _posedgeEvent;
+ InternalScEvent _negedgeEvent;
uint64_t _posStamp;
uint64_t _negStamp;
class Event;
class DynamicSensitivityEventAndList;
class DynamicSensitivityEventOrList;
+class InternalScEvent;
}
sc_event_or_expr operator | (const sc_event &) const;
sc_event_or_expr operator | (const sc_event_or_list &) const;
+ protected:
+ explicit sc_event(bool);
+ explicit sc_event(bool, const char *);
+
private:
// Disabled
sc_event(const sc_event &) {}
const sc_event &
find_event(sc_interface *if_p=NULL) const override
{
- static const sc_event none;
+ static const sc_gem5::InternalScEvent none;
const IF *iface = if_p ? dynamic_cast<const IF *>(if_p) :
dynamic_cast<const IF *>(_port->get_interface());
if (!iface) {
} // namespace sc_core
+namespace sc_gem5
+{
+
+class InternalScEvent : public ::sc_core::sc_event
+{
+ public:
+ InternalScEvent();
+ InternalScEvent(const char *);
+};
+
+} // namespace sc_gem5
+
#endif //__SYSTEMC_EXT_CORE_SC_INTERFACE_HH__
void wait_clocked();
private:
- sc_event joinEvent;
+ sc_gem5::InternalScEvent joinEvent;
int remaining;
};