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 | |
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')
-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 | ||||
-rw-r--r-- | src/systemc/ext/channel/sc_event_queue.hh | 2 | ||||
-rw-r--r-- | src/systemc/ext/channel/sc_fifo.hh | 4 | ||||
-rw-r--r-- | src/systemc/ext/channel/sc_mutex.hh | 2 | ||||
-rw-r--r-- | src/systemc/ext/channel/sc_semaphore.hh | 2 | ||||
-rw-r--r-- | src/systemc/ext/channel/sc_signal.hh | 6 | ||||
-rw-r--r-- | src/systemc/ext/core/sc_event.hh | 19 | ||||
-rw-r--r-- | src/systemc/ext/core/sc_join.hh | 2 |
16 files changed, 94 insertions, 44 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(); diff --git a/src/systemc/ext/channel/sc_event_queue.hh b/src/systemc/ext/channel/sc_event_queue.hh index 05ff46ecb..d9b041da9 100644 --- a/src/systemc/ext/channel/sc_event_queue.hh +++ b/src/systemc/ext/channel/sc_event_queue.hh @@ -72,7 +72,7 @@ class sc_event_queue : public sc_event_queue_if, public sc_module private: void _trigger(); - sc_event _defaultEvent; + sc_gem5::InternalScEvent _defaultEvent; std::priority_queue< sc_time, std::vector<sc_time>, std::greater<sc_time> > _times; }; diff --git a/src/systemc/ext/channel/sc_fifo.hh b/src/systemc/ext/channel/sc_fifo.hh index 02a0ddb98..a1c454a8f 100644 --- a/src/systemc/ext/channel/sc_fifo.hh +++ b/src/systemc/ext/channel/sc_fifo.hh @@ -211,8 +211,8 @@ class sc_fifo : public sc_fifo_in_if<T>, {} 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; diff --git a/src/systemc/ext/channel/sc_mutex.hh b/src/systemc/ext/channel/sc_mutex.hh index 12205da9b..0b85ca68f 100644 --- a/src/systemc/ext/channel/sc_mutex.hh +++ b/src/systemc/ext/channel/sc_mutex.hh @@ -56,7 +56,7 @@ class sc_mutex : public sc_mutex_if, public sc_object sc_mutex &operator = (const sc_mutex &) { return *this; } sc_process_handle holder; - sc_event unlockEvent; + sc_gem5::InternalScEvent unlockEvent; }; } // namespace sc_core diff --git a/src/systemc/ext/channel/sc_semaphore.hh b/src/systemc/ext/channel/sc_semaphore.hh index 31af9c708..3669f771e 100644 --- a/src/systemc/ext/channel/sc_semaphore.hh +++ b/src/systemc/ext/channel/sc_semaphore.hh @@ -59,7 +59,7 @@ class sc_semaphore : public sc_semaphore_if, public sc_object sc_semaphore &operator = (const sc_semaphore &) { return *this; } int _value; - sc_event posted; + sc_gem5::InternalScEvent posted; }; } // namespace sc_core diff --git a/src/systemc/ext/channel/sc_signal.hh b/src/systemc/ext/channel/sc_signal.hh index 3b2765db5..522638dde 100644 --- a/src/systemc/ext/channel/sc_signal.hh +++ b/src/systemc/ext/channel/sc_signal.hh @@ -71,7 +71,7 @@ class ScSignalBase : public sc_core::sc_prim_channel 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; }; @@ -91,8 +91,8 @@ class ScSignalBaseBinary : public ScSignalBase 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; diff --git a/src/systemc/ext/core/sc_event.hh b/src/systemc/ext/core/sc_event.hh index 90c1911ca..90fd41f2a 100644 --- a/src/systemc/ext/core/sc_event.hh +++ b/src/systemc/ext/core/sc_event.hh @@ -45,6 +45,7 @@ namespace sc_gem5 class Event; class DynamicSensitivityEventAndList; class DynamicSensitivityEventOrList; +class InternalScEvent; } @@ -196,6 +197,10 @@ class sc_event 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 &) {} @@ -235,7 +240,7 @@ class sc_event_finder_t : public sc_event_finder 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) { @@ -258,4 +263,16 @@ sc_event *sc_find_event(const char *); } // 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__ diff --git a/src/systemc/ext/core/sc_join.hh b/src/systemc/ext/core/sc_join.hh index 49e54ceee..3b227d311 100644 --- a/src/systemc/ext/core/sc_join.hh +++ b/src/systemc/ext/core/sc_join.hh @@ -52,7 +52,7 @@ class sc_join void wait_clocked(); private: - sc_event joinEvent; + sc_gem5::InternalScEvent joinEvent; int remaining; }; |