diff options
author | Gabe Black <gabeblack@google.com> | 2018-10-06 00:10:20 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-10-16 01:00:42 +0000 |
commit | 05f2a5f4f67c6d6b71497a0b6c75faf728f963f6 (patch) | |
tree | 9901e11e6fcefc25d8f4b4e09957e3ee12b69a76 /src/systemc/core | |
parent | e9b366922b6b2dcb9e36bfa87eb58aefc3e138fb (diff) | |
download | gem5-05f2a5f4f67c6d6b71497a0b6c75faf728f963f6.tar.xz |
systemc: Distinguish internal events from normal sc_events.
The internal events aren't supposed to show up in the namespace or as
children of objects.
Change-Id: Id04b9bfe2e1f8f216390dd989797558eaf33d715
Reviewed-on: https://gem5-review.googlesource.com/c/13309
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core')
-rw-r--r-- | src/systemc/core/event.cc | 57 | ||||
-rw-r--r-- | src/systemc/core/event.hh | 5 | ||||
-rw-r--r-- | src/systemc/core/module.cc | 2 | ||||
-rw-r--r-- | src/systemc/core/module.hh | 2 | ||||
-rw-r--r-- | src/systemc/core/process.hh | 4 | ||||
-rw-r--r-- | src/systemc/core/sc_event.cc | 21 | ||||
-rw-r--r-- | src/systemc/core/sc_interface.cc | 2 | ||||
-rw-r--r-- | src/systemc/core/sc_module.cc | 4 | ||||
-rw-r--r-- | src/systemc/core/sc_process_handle.cc | 4 |
9 files changed, 67 insertions, 34 deletions
diff --git a/src/systemc/core/event.cc b/src/systemc/core/event.cc index 2e356bdb6..de5bc8c32 100644 --- a/src/systemc/core/event.cc +++ b/src/systemc/core/event.cc @@ -43,38 +43,47 @@ 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 @@ -86,7 +95,7 @@ Event::~Event() 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()); @@ -117,7 +126,7 @@ Event::basename() const bool Event::inHierarchy() const { - return _name.length() != 0; + return _inHierarchy; } sc_core::sc_object * diff --git a/src/systemc/core/event.hh b/src/systemc/core/event.hh index 75687729f..127e22ae3 100644 --- a/src/systemc/core/event.hh +++ b/src/systemc/core/event.hh @@ -60,8 +60,9 @@ class Sensitivity; 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(); diff --git a/src/systemc/core/module.cc b/src/systemc/core/module.cc index 8cbde8f70..ec6c7761a 100644 --- a/src/systemc/core/module.cc +++ b/src/systemc/core/module.cc @@ -47,6 +47,8 @@ Module *_new_module; } // anonymous namespace +UniqueNameGen globalNameGen; + Module::Module(const char *name) : _name(name), _sc_mod(nullptr), _obj(nullptr), _ended(false), _deprecatedConstructor(false), bindingIndex(0) diff --git a/src/systemc/core/module.hh b/src/systemc/core/module.hh index 8d6df81e6..b65fdf3bf 100644 --- a/src/systemc/core/module.hh +++ b/src/systemc/core/module.hh @@ -68,6 +68,8 @@ class UniqueNameGen } }; +extern UniqueNameGen globalNameGen; + class Module { private: diff --git a/src/systemc/core/process.hh b/src/systemc/core/process.hh index a0657f4be..17961c77f 100644 --- a/src/systemc/core/process.hh +++ b/src/systemc/core/process.hh @@ -156,8 +156,8 @@ class Process : public ::sc_core::sc_process_b, public ListNode clearDynamic(); } - ::sc_core::sc_event _resetEvent; - ::sc_core::sc_event _terminatedEvent; + InternalScEvent _resetEvent; + InternalScEvent _terminatedEvent; ProcessFuncWrapper *func; sc_core::sc_curr_proc_kind _procKind; diff --git a/src/systemc/core/sc_event.cc b/src/systemc/core/sc_event.cc index b2dc0e525..0eeae038f 100644 --- a/src/systemc/core/sc_event.cc +++ b/src/systemc/core/sc_event.cc @@ -389,6 +389,19 @@ sc_event::operator | (const sc_event_or_list &eol) const 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() { @@ -404,3 +417,11 @@ sc_find_event(const char *name) } } // namespace sc_core + +namespace sc_gem5 +{ + +InternalScEvent::InternalScEvent() : sc_event(true) {} +InternalScEvent::InternalScEvent(const char *_name) : sc_event(true, _name) {} + +} // namespace sc_gem5 diff --git a/src/systemc/core/sc_interface.cc b/src/systemc/core/sc_interface.cc index 4b3865e13..93aff6712 100644 --- a/src/systemc/core/sc_interface.cc +++ b/src/systemc/core/sc_interface.cc @@ -41,7 +41,7 @@ const sc_event & 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; } diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc index 0b58f3232..77f0f83f3 100644 --- a/src/systemc/core/sc_module.cc +++ b/src/systemc/core/sc_module.cc @@ -97,8 +97,6 @@ newCThreadProcess(const char *name, ProcessFuncWrapper *func) return p; } -UniqueNameGen nameGen; - } // namespace sc_gem5 namespace sc_core @@ -836,7 +834,7 @@ sc_gen_unique_name(const char *seed) if (p) return p->uniqueName(seed); - return ::sc_gem5::nameGen.gen(seed); + return ::sc_gem5::globalNameGen.gen(seed); } bool diff --git a/src/systemc/core/sc_process_handle.cc b/src/systemc/core/sc_process_handle.cc index 8bf939801..fff406161 100644 --- a/src/systemc/core/sc_process_handle.cc +++ b/src/systemc/core/sc_process_handle.cc @@ -199,7 +199,7 @@ sc_process_handle::terminated_event() const 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(); @@ -289,7 +289,7 @@ sc_process_handle::reset_event() const 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(); |