summaryrefslogtreecommitdiff
path: root/src/systemc/core/sensitivity.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-09-14 18:33:16 -0700
committerGabe Black <gabeblack@google.com>2018-10-09 21:50:01 +0000
commitd737358ac643ff5bdc3984138cc3ae08c7b57ff7 (patch)
tree885d850e9740065a8a2ef4731024d4ca081606a0 /src/systemc/core/sensitivity.cc
parent7bc110ce5c12f47105e851a1a54c26a83eba6b87 (diff)
downloadgem5-d737358ac643ff5bdc3984138cc3ae08c7b57ff7.tar.xz
systemc: Rework how delayed sensitivities are handled.
Make BindInfo into a more general purpose Port class which mirrors sc_module and Module, sc_object and Object, etc. This tracks multiple bindings internally, and also pending sensitivities. Keep a global list of ports which are added in reverse order to match Accellera, and which is iterated over to finalize binding and for phase callbacks. This is as opposed to doing it one module at a time, and is to better match Accellera's ordering for the regressions. Also the sensitivity classes are now built with factory functions, which gets around problems calling virtual functions from their constructors or forgetting to having to have extra boilerplate each place they're constructed. The port class also now finalizes port or event finder sensitivities when its binding is completed, unless it's already complete in which case it does so immediately. Change-Id: I1b01689715c425b94e0f68cf0271f5c1565d8c61 Reviewed-on: https://gem5-review.googlesource.com/c/12806 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/sensitivity.cc')
-rw-r--r--src/systemc/core/sensitivity.cc154
1 files changed, 98 insertions, 56 deletions
diff --git a/src/systemc/core/sensitivity.cc b/src/systemc/core/sensitivity.cc
index 77aacb56a..740090cd9 100644
--- a/src/systemc/core/sensitivity.cc
+++ b/src/systemc/core/sensitivity.cc
@@ -30,6 +30,7 @@
#include "systemc/core/sensitivity.hh"
#include "systemc/core/event.hh"
+#include "systemc/core/port.hh"
#include "systemc/core/scheduler.hh"
#include "systemc/ext/core/sc_export.hh"
#include "systemc/ext/core/sc_interface.hh"
@@ -38,6 +39,10 @@
namespace sc_gem5
{
+/*
+ * Common sensitivity interface.
+ */
+
void
Sensitivity::satisfy()
{
@@ -53,6 +58,10 @@ Sensitivity::notify(Event *e)
}
+/*
+ * Dynamic vs. static sensitivity.
+ */
+
void
DynamicSensitivity::addToEvent(const ::sc_core::sc_event *e)
{
@@ -77,106 +86,139 @@ StaticSensitivity::delFromEvent(const ::sc_core::sc_event *e)
Event::getFromScEvent(e)->delSensitivity(this);
}
+
+/*
+ * Static sensitivities.
+ */
+
void
-StaticSensitivityInterface::finalize()
+newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
{
- event = &interface->default_event();
- SensitivityEvent::finalize();
+ auto s = new StaticSensitivityEvent(p, e);
+ s->addToEvent(s->event);
+ p->addStatic(s);
}
void
-StaticSensitivityPort::finalize()
+newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
{
- for (int i = 0; i < port->size(); i++) {
- const ::sc_core::sc_event *event =
- &port->_gem5Interface(i)->default_event();
- events.insert(event);
- addToEvent(event);
- }
+ auto s = new StaticSensitivityInterface(p, i);
+ s->addToEvent(s->event);
+ p->addStatic(s);
}
void
-StaticSensitivityExport::finalize()
+newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
{
- event = &exp->get_interface()->default_event();
- SensitivityEvent::finalize();
+ auto s = new StaticSensitivityPort(p);
+ Port *port = Port::fromPort(pb);
+ port->sensitive(s);
+ p->addStatic(s);
}
void
-StaticSensitivityFinder::finalize()
+newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
{
- const ::sc_core::sc_port_base *port = finder->port();
- int size = port->size();
- for (int i = 0; i < size; i++) {
- ::sc_core::sc_interface *interface = port->_gem5Interface(i);
- const ::sc_core::sc_event *event = &finder->find_event(interface);
- events.insert(event);
- addToEvent(event);
- }
+ auto s = new StaticSensitivityExport(p, exp);
+ s->addToEvent(s->event);
+ p->addStatic(s);
}
-bool
-DynamicSensitivityEventOrList::notifyWork(Event *e)
+void
+newStaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
{
- events.erase(e->sc_event());
+ auto s = new StaticSensitivityFinder(p, f);
+ Port *port = Port::fromPort(f->port());
+ port->sensitive(s);
+ p->addStatic(s);
+}
- // All the other events need this deleted from their lists since this
- // sensitivity has been satisfied without them triggering.
- for (auto le: events)
- delFromEvent(le);
- satisfy();
- return true;
-}
+StaticSensitivityInterface::StaticSensitivityInterface(
+ Process *p, const sc_core::sc_interface *i) :
+ Sensitivity(p), StaticSensitivity(p),
+ SensitivityEvent(p, &i->default_event())
+{}
-DynamicSensitivityEventOrList::DynamicSensitivityEventOrList(
- Process *p, const sc_core::sc_event_or_list *eol) :
- Sensitivity(p), DynamicSensitivity(p), events(eol->events)
+StaticSensitivityExport::StaticSensitivityExport(
+ Process *p, const sc_core::sc_export_base *exp) :
+ Sensitivity(p), StaticSensitivity(p),
+ SensitivityEvent(p, &exp->get_interface()->default_event())
{}
+const ::sc_core::sc_event &
+StaticSensitivityFinder::find(::sc_core::sc_interface *i)
+{
+ return finder->find_event(i);
+}
+
+
+/*
+ * Dynamic sensitivities.
+ */
+
void
-DynamicSensitivityEventOrList::finalize()
+newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
{
- for (auto e: events)
- addToEvent(e);
+ auto s = new DynamicSensitivityEvent(p, e);
+ s->addToEvent(s->event);
+ p->setDynamic(s);
}
void
-DynamicSensitivityEventOrList::clear()
+newDynamicSensitivityEventOrList(
+ Process *p, const sc_core::sc_event_or_list *eol)
+{
+ auto s = new DynamicSensitivityEventOrList(p, eol);
+ for (auto event: s->events)
+ s->addToEvent(event);
+ p->setDynamic(s);
+}
+
+void newDynamicSensitivityEventAndList(
+ Process *p, const sc_core::sc_event_and_list *eal)
{
- for (auto e: events)
- delFromEvent(e);
+ auto s = new DynamicSensitivityEventAndList(p, eal);
+ for (auto event: s->events)
+ s->addToEvent(event);
+ p->setDynamic(s);
}
+
+DynamicSensitivityEventOrList::DynamicSensitivityEventOrList(
+ Process *p, const sc_core::sc_event_or_list *eol) :
+ Sensitivity(p), DynamicSensitivity(p), SensitivityEvents(p, eol->events)
+{}
+
bool
-DynamicSensitivityEventAndList::notifyWork(Event *e)
+DynamicSensitivityEventOrList::notifyWork(Event *e)
{
events.erase(e->sc_event());
- // This sensitivity is satisfied if all events have triggered.
- if (events.empty())
- satisfy();
+ // All the other events need this deleted from their lists since this
+ // sensitivity has been satisfied without them triggering.
+ for (auto le: events)
+ delFromEvent(le);
+ satisfy();
return true;
}
DynamicSensitivityEventAndList::DynamicSensitivityEventAndList(
Process *p, const sc_core::sc_event_and_list *eal) :
- Sensitivity(p), DynamicSensitivity(p), events(eal->events)
+ Sensitivity(p), DynamicSensitivity(p), SensitivityEvents(p, eal->events)
{}
-void
-DynamicSensitivityEventAndList::finalize()
+bool
+DynamicSensitivityEventAndList::notifyWork(Event *e)
{
- for (auto e: events)
- addToEvent(e);
-}
+ events.erase(e->sc_event());
-void
-DynamicSensitivityEventAndList::clear()
-{
- for (auto e: events)
- delFromEvent(e);
+ // This sensitivity is satisfied if all events have triggered.
+ if (events.empty())
+ satisfy();
+
+ return true;
}
} // namespace sc_gem5