diff options
Diffstat (limited to 'src/systemc')
-rw-r--r-- | src/systemc/core/SConscript | 1 | ||||
-rw-r--r-- | src/systemc/core/event.cc | 145 | ||||
-rw-r--r-- | src/systemc/core/event.hh | 109 | ||||
-rw-r--r-- | src/systemc/core/object.cc | 33 | ||||
-rw-r--r-- | src/systemc/core/object.hh | 20 | ||||
-rw-r--r-- | src/systemc/core/sc_event.cc | 348 | ||||
-rw-r--r-- | src/systemc/ext/core/sc_event.hh | 62 |
7 files changed, 562 insertions, 156 deletions
diff --git a/src/systemc/core/SConscript b/src/systemc/core/SConscript index 8fd5f7af9..8996a7de5 100644 --- a/src/systemc/core/SConscript +++ b/src/systemc/core/SConscript @@ -31,6 +31,7 @@ if env['USE_SYSTEMC']: SimObject('SystemC.py') Source('channel.cc') + Source('event.cc') Source('kernel.cc') Source('module.cc') Source('object.cc') diff --git a/src/systemc/core/event.cc b/src/systemc/core/event.cc new file mode 100644 index 000000000..63fcabe4f --- /dev/null +++ b/src/systemc/core/event.cc @@ -0,0 +1,145 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#include "systemc/core/event.hh" + +#include <cstring> +#include <utility> + +#include "systemc/core/module.hh" +#include "systemc/core/scheduler.hh" + +namespace sc_gem5 +{ + +Event::Event(sc_core::sc_event *_sc_event) : Event(_sc_event, "") {} + +Event::Event(sc_core::sc_event *_sc_event, const char *_basename) : + _sc_event(_sc_event), _basename(_basename) +{ + Module *p = currentModule(); + + if (p) + parent = p->obj()->sc_obj(); + else if (scheduler.current()) + parent = scheduler.current(); + + if (parent) { + Object *obj = Object::getFromScObject(parent); + parentIt = obj->addChildEvent(_sc_event); + } else { + parentIt = topLevelEvents.emplace(topLevelEvents.end(), _sc_event); + } + + if (parent) + _name = std::string(parent->name()) + "." + _basename; + else + _name = _basename; + + allEvents.emplace(allEvents.end(), _sc_event); + + // Determine if we're in the hierarchy (created once initialization starts + // means no). +} + +Event::~Event() +{ + if (parent) { + Object *obj = Object::getFromScObject(parent); + obj->delChildEvent(parentIt); + } else { + std::swap(*parentIt, topLevelEvents.back()); + topLevelEvents.pop_back(); + } + + EventsIt it = findEvent(_name); + std::swap(*it, allEvents.back()); + allEvents.pop_back(); +} + +const std::string & +Event::name() const +{ + return _name; +} + +const std::string & +Event::basename() const +{ + return _basename; +} + +bool +Event::inHierarchy() const +{ + return _name.length() != 0; +} + +sc_core::sc_object * +Event::getParentObject() const +{ + return parent; +} + +void +Event::notify() +{ +} + +void +Event::notify(const sc_core::sc_time &t) +{ +} + +void +Event::cancel() +{ +} + +bool +Event::triggered() const +{ + return false; +} + +Events topLevelEvents; +Events allEvents; + +EventsIt +findEvent(const std::string &name) +{ + EventsIt it; + for (it = allEvents.begin(); it != allEvents.end(); it++) + if (!strcmp((*it)->name(), name.c_str())) + break; + + return it; +} + +} // namespace sc_gem5 diff --git a/src/systemc/core/event.hh b/src/systemc/core/event.hh new file mode 100644 index 000000000..bf9afd40f --- /dev/null +++ b/src/systemc/core/event.hh @@ -0,0 +1,109 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_CORE_EVENT_HH__ +#define __SYSTEMC_CORE_EVENT_HH__ + +#include <string> +#include <vector> + +#include "systemc/core/list.hh" +#include "systemc/core/object.hh" +#include "systemc/ext/core/sc_prim.hh" +#include "systemc/ext/core/sc_time.hh" + +namespace sc_core +{ + +class sc_event; + +} // namespace sc_core + +namespace sc_gem5 +{ + +typedef std::vector<sc_core::sc_event *> Events; + +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() { return _sc_event; } + + const std::string &name() const; + const std::string &basename() const; + bool inHierarchy() const; + sc_core::sc_object *getParentObject() const; + + void notify(); + void notify(const sc_core::sc_time &t); + void + notify(double d, sc_core::sc_time_unit &u) + { + notify(sc_core::sc_time(d, u)); + } + void cancel(); + + bool triggered() const; + + static Event * + getFromScEvent(sc_core::sc_event *e) + { + return e->_gem5_event; + } + + static const Event * + getFromScEvent(const sc_core::sc_event *e) + { + return e->_gem5_event; + } + + private: + sc_core::sc_event *_sc_event; + + std::string _basename; + std::string _name; + bool _inHierarchy; + + sc_core::sc_object *parent; + EventsIt parentIt; +}; + +extern Events topLevelEvents; +extern Events allEvents; + +EventsIt findEvent(const std::string &name); + +} // namespace sc_gem5 + +#endif //__SYSTEMC_CORE_EVENT_HH__ diff --git a/src/systemc/core/object.cc b/src/systemc/core/object.cc index 2bc6804e2..68c52eb06 100644 --- a/src/systemc/core/object.cc +++ b/src/systemc/core/object.cc @@ -67,10 +67,10 @@ popObject(Objects *objects, const std::string &name) } // anonymous namespace -Object::Object(sc_core::sc_object *sc_obj) : Object(sc_obj, "object") {} +Object::Object(sc_core::sc_object *_sc_obj) : Object(_sc_obj, "object") {} -Object::Object(sc_core::sc_object *sc_obj, const char *obj_name) : - sc_obj(sc_obj), _basename(obj_name), parent(nullptr) +Object::Object(sc_core::sc_object *_sc_obj, const char *obj_name) : + _sc_obj(_sc_obj), _basename(obj_name), parent(nullptr) { if (_basename == "") _basename = "object"; @@ -86,17 +86,17 @@ Object::Object(sc_core::sc_object *sc_obj, const char *obj_name) : if (p) { // We're "within" a parent module, ie we're being created while its // constructor is running. - parent = p->obj()->sc_obj; - addObject(&parent->_gem5_object->children, sc_obj); + parent = p->obj()->_sc_obj; + addObject(&parent->_gem5_object->children, _sc_obj); } else if (scheduler.current()) { // Our parent is the currently running process. parent = scheduler.current(); } else { // We're a top level object. - addObject(&topLevelObjects, sc_obj); + addObject(&topLevelObjects, _sc_obj); } - addObject(&allObjects, sc_obj); + addObject(&allObjects, _sc_obj); _name = _basename; sc_core::sc_object *sc_p = parent; @@ -106,8 +106,8 @@ Object::Object(sc_core::sc_object *sc_obj, const char *obj_name) : } } -Object::Object(sc_core::sc_object *sc_obj, const Object &arg) : - Object(sc_obj, arg._basename.c_str()) +Object::Object(sc_core::sc_object *_sc_obj, const Object &arg) : + Object(_sc_obj, arg._basename.c_str()) {} Object & @@ -149,7 +149,7 @@ void Object::dump(std::ostream &out) const { out << "name = " << name() << "\n"; - out << "kind = " << sc_obj->kind() << "\n"; + out << "kind = " << _sc_obj->kind() << "\n"; } const std::vector<sc_core::sc_object *> & @@ -218,6 +218,19 @@ Object::simcontext() const return nullptr; } +EventsIt +Object::addChildEvent(sc_core::sc_event *e) +{ + return events.emplace(events.end(), e); +} + +void +Object::delChildEvent(EventsIt it) +{ + std::swap(*it, events.back()); + events.pop_back(); +} + Objects topLevelObjects; Objects allObjects; diff --git a/src/systemc/core/object.hh b/src/systemc/core/object.hh index 93c5e8f7c..1317986bc 100644 --- a/src/systemc/core/object.hh +++ b/src/systemc/core/object.hh @@ -44,13 +44,14 @@ class Object; typedef std::vector<sc_core::sc_object *> Objects; typedef std::vector<sc_core::sc_event *> Events; typedef Objects::iterator ObjectsIt; +typedef Events::iterator EventsIt; class Object { public: - Object(sc_core::sc_object *sc_obj); - Object(sc_core::sc_object *sc_obj, const char *); - Object(sc_core::sc_object *sc_obj, const Object &); + Object(sc_core::sc_object *_sc_obj); + Object(sc_core::sc_object *_sc_obj, const char *); + Object(sc_core::sc_object *_sc_obj, const Object &); Object &operator = (const Object &); virtual ~Object(); @@ -78,8 +79,19 @@ class Object sc_core::sc_simcontext *simcontext() const; + static Object * + getFromScObject(sc_core::sc_object *sc_obj) + { + return sc_obj->_gem5_object; + } + + sc_core::sc_object *sc_obj() { return _sc_obj; } + + EventsIt addChildEvent(sc_core::sc_event *e); + void delChildEvent(EventsIt it); + private: - sc_core::sc_object *sc_obj; + sc_core::sc_object *_sc_obj; std::string _basename; std::string _name; diff --git a/src/systemc/core/sc_event.cc b/src/systemc/core/sc_event.cc index 80d10271a..09c820329 100644 --- a/src/systemc/core/sc_event.cc +++ b/src/systemc/core/sc_event.cc @@ -28,314 +28,378 @@ */ #include "base/logging.hh" +#include "systemc/core/event.hh" #include "systemc/ext/core/sc_event.hh" namespace sc_core { + +/* + * sc_event_finder + */ + void sc_event_finder::warn_unimpl(const char *func) const { warn("%s not implemented.\n", __PRETTY_FUNCTION__); } -sc_event_and_list::sc_event_and_list() -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} -sc_event_and_list::sc_event_and_list(const sc_event_and_list &) -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} +/* + * sc_event_and_list + */ + +sc_event_and_list::sc_event_and_list() : autoDelete(false), busy(0) {} + +sc_event_and_list::sc_event_and_list(const sc_event_and_list &eal) : + events(eal.events), autoDelete(false), busy(0) +{} -sc_event_and_list::sc_event_and_list(const sc_event &) +sc_event_and_list::sc_event_and_list(const sc_event &e) : sc_event_and_list() { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + insert(e); } +sc_event_and_list::sc_event_and_list(bool auto_delete) : + autoDelete(auto_delete), busy(0) +{} + +sc_event_and_list::~sc_event_and_list() {} + sc_event_and_list & -sc_event_and_list::operator = (const sc_event_and_list &) +sc_event_and_list::operator = (const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + events = eal.events; return *this; } int sc_event_and_list::size() const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return 0; + return events.size(); } void -sc_event_and_list::swap(sc_event_and_list &) +sc_event_and_list::swap(sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + events.swap(eal.events); } sc_event_and_list & -sc_event_and_list::operator &= (const sc_event &) +sc_event_and_list::operator &= (const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + insert(e); return *this; } sc_event_and_list & -sc_event_and_list::operator &= (const sc_event_and_list &) +sc_event_and_list::operator &= (const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + insert(eal); return *this; } sc_event_and_expr -sc_event_and_list::operator & (const sc_event &) const +sc_event_and_list::operator & (const sc_event &e) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return sc_event_and_expr(); + sc_event_and_expr expr; + expr.insert(*this); + expr.insert(e); + return expr; } sc_event_and_expr -sc_event_and_list::operator & (const sc_event_and_list &) +sc_event_and_list::operator & (const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return sc_event_and_expr(); + sc_event_and_expr expr; + expr.insert(*this); + expr.insert(eal); + return expr; } -sc_event_or_list::sc_event_or_list() +void +sc_event_and_list::insert(sc_event const &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + events.insert(&e); } -sc_event_or_list::sc_event_or_list(const sc_event_or_list &) +void +sc_event_and_list::insert(sc_event_and_list const &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + events.insert(eal.events.begin(), eal.events.end()); } -sc_event_or_list::sc_event_or_list(const sc_event &) + +/* + * sc_event_or_list + */ + +sc_event_or_list::sc_event_or_list() : autoDelete(false), busy(0) {} + +sc_event_or_list::sc_event_or_list(const sc_event_or_list &eol) : + events(eol.events), autoDelete(false), busy(0) +{} + +sc_event_or_list::sc_event_or_list(const sc_event &e) : sc_event_or_list() { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + insert(e); } -sc_event_or_list& -sc_event_or_list::operator = (const sc_event_or_list &) +sc_event_or_list::sc_event_or_list(bool auto_delete) : + autoDelete(auto_delete), busy(0) +{} + +sc_event_or_list & +sc_event_or_list::operator = (const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + events = eol.events; return *this; } -sc_event_or_list::~sc_event_or_list() -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} +sc_event_or_list::~sc_event_or_list() {} int sc_event_or_list::size() const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return 0; + return events.size(); } void -sc_event_or_list::swap(sc_event_or_list &) +sc_event_or_list::swap(sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + events.swap(eol.events); } sc_event_or_list & -sc_event_or_list::operator |= (const sc_event &) +sc_event_or_list::operator |= (const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + insert(e); return *this; } sc_event_or_list & -sc_event_or_list::operator |= (const sc_event_or_list &) +sc_event_or_list::operator |= (const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + insert(eol); return *this; } sc_event_or_expr -sc_event_or_list::operator | (const sc_event &) const +sc_event_or_list::operator | (const sc_event &e) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return sc_event_or_expr(); + sc_event_or_expr expr; + expr.insert(*this); + expr.insert(e); + return expr; } sc_event_or_expr -sc_event_or_list::operator | (const sc_event_or_list &) const +sc_event_or_list::operator | (const sc_event_or_list &eol) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return sc_event_or_expr(); + sc_event_or_expr expr; + expr.insert(*this); + expr.insert(eol); + return expr; } -sc_event_and_expr::operator const sc_event_and_list &() const +void +sc_event_or_list::insert(sc_event const &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return *(const sc_event_and_list *)nullptr; + events.insert(&e); } -sc_event_and_expr -operator & (sc_event_and_expr expr, sc_event const &) +void +sc_event_or_list::insert(sc_event_or_list const &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return expr; + events.insert(eol.events.begin(), eol.events.end()); } -sc_event_and_expr -operator & (sc_event_and_expr expr, sc_event_and_list const &) -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return expr; -} -sc_event_or_expr::operator const sc_event_or_list &() const -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return *(const sc_event_or_list *)nullptr; -} +/* + * sc_event_and_expr + */ -sc_event_or_expr -operator | (sc_event_or_expr expr, sc_event const &) +// Move semantics +sc_event_and_expr::sc_event_and_expr(sc_event_and_expr const &e) : + list(e.list) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return expr; + e.list = nullptr; } -sc_event_or_expr -operator | (sc_event_or_expr expr, sc_event_or_list const &) +sc_event_and_expr::operator const sc_event_and_list &() const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return expr; + sc_event_and_list *temp = list; + list = nullptr; + return *temp; } -sc_event::sc_event() +void +sc_event_and_expr::insert(sc_event const &e) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + assert(list); + list->insert(e); } -sc_event::sc_event(const char *) +void +sc_event_and_expr::insert(sc_event_and_list const &eal) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + assert(list); + list->insert(eal); } -sc_event::~sc_event() -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} +sc_event_and_expr::~sc_event_and_expr() { delete list; } -const char * -sc_event::name() const -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return ""; -} +sc_event_and_expr::sc_event_and_expr() : list(new sc_event_and_list(true)) {} -const char * -sc_event::basename() const +sc_event_and_expr +operator & (sc_event_and_expr expr, sc_event const &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return ""; + expr.insert(e); + return expr; } -bool -sc_event::in_hierarchy() const +sc_event_and_expr +operator & (sc_event_and_expr expr, sc_event_and_list const &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return false; + expr.insert(eal); + return expr; } -sc_object * -sc_event::get_parent_object() const + +/* + * sc_event_or_expr + */ + +// Move semantics +sc_event_or_expr::sc_event_or_expr(sc_event_or_expr const &e) : + list(e.list) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return (sc_object *)nullptr; + e.list = nullptr; } -void -sc_event::notify() +sc_event_or_expr::operator const sc_event_or_list &() const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + sc_event_or_list *temp = list; + list = NULL; + return *temp; } void -sc_event::notify(const sc_time &) +sc_event_or_expr::insert(sc_event const &e) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + assert(list); + list->insert(e); } void -sc_event::notify(double, sc_time_unit) +sc_event_or_expr::insert(sc_event_or_list const &eol) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + assert(list); + list->insert(eol); } -void -sc_event::cancel() +sc_event_or_expr::~sc_event_or_expr() { delete list; } + +sc_event_or_expr::sc_event_or_expr() : list(new sc_event_or_list(true)) {} + +sc_event_or_expr +operator | (sc_event_or_expr expr, sc_event const &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + expr.insert(e); + return expr; } -bool -sc_event::triggered() const +sc_event_or_expr +operator | (sc_event_or_expr expr, sc_event_or_list const &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return false; + expr.insert(eol); + return expr; } -void -sc_event::notify_delayed() + +/* + * sc_event + */ + +sc_event::sc_event() : _gem5_event(new ::sc_gem5::Event(this)) {} + +sc_event::sc_event(const char *_name) : + _gem5_event(new ::sc_gem5::Event(this, _name)) +{} + +sc_event::~sc_event() { delete _gem5_event; } + +const char *sc_event::name() const { return _gem5_event->name().c_str(); } +const char * +sc_event::basename() const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + return _gem5_event->basename().c_str(); } +bool sc_event::in_hierarchy() const { return _gem5_event->inHierarchy(); } -void -sc_event::notify_delayed(const sc_time &) +sc_object * +sc_event::get_parent_object() const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + return _gem5_event->getParentObject(); } +void sc_event::notify() { _gem5_event->notify(); } +void sc_event::notify(const sc_time &t) { _gem5_event->notify(t); } +void sc_event::notify(double d, sc_time_unit u) { _gem5_event->notify(d, u); } +void sc_event::cancel() { _gem5_event->cancel(); } +bool sc_event::triggered() const { return _gem5_event->triggered(); } +void sc_event::notify_delayed() { _gem5_event->notify(SC_ZERO_TIME); } +void sc_event::notify_delayed(const sc_time &t) { _gem5_event->notify(t); } + sc_event_and_expr -sc_event::operator & (const sc_event &) const +sc_event::operator & (const sc_event &e) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return sc_event_and_expr(); + sc_event_and_expr expr; + expr.insert(*this); + expr.insert(e); + return expr; } sc_event_and_expr -sc_event::operator & (const sc_event_and_list &) const +sc_event::operator & (const sc_event_and_list &eal) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return sc_event_and_expr(); + sc_event_and_expr expr; + expr.insert(*this); + expr.insert(eal); + return expr; } sc_event_or_expr -sc_event::operator | (const sc_event &) const +sc_event::operator | (const sc_event &e) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return sc_event_or_expr(); + sc_event_or_expr expr; + expr.insert(*this); + expr.insert(e); + return expr; } sc_event_or_expr -sc_event::operator | (const sc_event_or_list &) const +sc_event::operator | (const sc_event_or_list &eol) const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return sc_event_or_expr(); + sc_event_or_expr expr; + expr.insert(*this); + expr.insert(eol); + return expr; } const std::vector<sc_event *> & sc_get_top_level_events() { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return *(const std::vector<sc_event *> *)nullptr; + return ::sc_gem5::topLevelEvents; } sc_event * -sc_find_event(const char *) +sc_find_event(const char *name) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return (sc_event *)nullptr; + std::string str(name); + ::sc_gem5::EventsIt it = ::sc_gem5::findEvent(str); + return it == ::sc_gem5::allEvents.end() ? nullptr : *it; } } // namespace sc_core diff --git a/src/systemc/ext/core/sc_event.hh b/src/systemc/ext/core/sc_event.hh index 0b901ff1e..d037a84bf 100644 --- a/src/systemc/ext/core/sc_event.hh +++ b/src/systemc/ext/core/sc_event.hh @@ -30,10 +30,18 @@ #ifndef __SYSTEMC_EXT_CORE_SC_EVENT_HH__ #define __SYSTEMC_EXT_CORE_SC_EVENT_HH__ +#include <set> #include <vector> #include "sc_time.hh" +namespace sc_gem5 +{ + +class Event; + +} + namespace sc_core { @@ -79,6 +87,7 @@ class sc_event_and_list sc_event_and_list(const sc_event_and_list &); sc_event_and_list(const sc_event &); sc_event_and_list &operator = (const sc_event_and_list &); + ~sc_event_and_list(); int size() const; void swap(sc_event_and_list &); @@ -88,6 +97,18 @@ class sc_event_and_list sc_event_and_expr operator & (const sc_event &) const; sc_event_and_expr operator & (const sc_event_and_list &); + + private: + friend class sc_event_and_expr; + + explicit sc_event_and_list(bool auto_delete); + + void insert(sc_event const &e); + void insert(sc_event_and_list const &eal); + + std::set<const sc_event *> events; + bool autoDelete; + mutable unsigned busy; }; class sc_event_or_list @@ -107,12 +128,37 @@ class sc_event_or_list sc_event_or_expr operator | (const sc_event &) const; sc_event_or_expr operator | (const sc_event_or_list &) const; + + private: + friend class sc_event_or_expr; + + explicit sc_event_or_list(bool auto_delete); + + void insert(sc_event const &e); + void insert(sc_event_or_list const &eol); + + std::set<const sc_event *> events; + bool autoDelete; + mutable unsigned busy; }; class sc_event_and_expr { public: + sc_event_and_expr(sc_event_and_expr const &e); operator const sc_event_and_list &() const; + + void insert(sc_event const &e) const; + void insert(sc_event_and_list const &eal) const; + + ~sc_event_and_expr(); + + private: + friend class sc_event_and_list; + friend class sc_event; + + sc_event_and_expr(); + mutable sc_event_and_list *list; }; sc_event_and_expr operator & (sc_event_and_expr, sc_event const &); @@ -121,7 +167,20 @@ sc_event_and_expr operator & (sc_event_and_expr, sc_event_and_list const &); class sc_event_or_expr { public: + sc_event_or_expr(sc_event_or_expr const &e); operator const sc_event_or_list &() const; + + void insert(sc_event const &e) const; + void insert(sc_event_or_list const &eol) const; + + ~sc_event_or_expr(); + + private: + friend class sc_event_or_list; + friend class sc_event; + + sc_event_or_expr(); + mutable sc_event_or_list *list; }; sc_event_or_expr operator | (sc_event_or_expr, sc_event const &); @@ -161,6 +220,9 @@ class sc_event // Disabled sc_event(const sc_event &) {} sc_event &operator = (const sc_event &) { return *this; } + + friend class ::sc_gem5::Event; + ::sc_gem5::Event *_gem5_event; }; const std::vector<sc_event *> &sc_get_top_level_events(); |