diff options
author | Gabe Black <gabeblack@google.com> | 2018-10-01 02:33:55 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-10-16 00:43:35 +0000 |
commit | b2e1f81f51e630ef4399f24024c82404601f8340 (patch) | |
tree | 8a6be7cafcbc3b36e10daa1c433aed390a48eed7 /src/systemc/core | |
parent | a7f1fe77d64e46e5f9a348b8ae02b3cce3042b98 (diff) | |
download | gem5-b2e1f81f51e630ef4399f24024c82404601f8340.tar.xz |
systemc: Add missing sc_interface::register_port, and add calls to it.
This function is standard and supposed to be on sc_interface, but it
was somehow left out. This change adds it, and makes sure it's called
by the port binding code. The default implementation does nothing, as
it's supposed to according to the spec.
Also note that only the ports farthest from the interfaces are suppose
to call register_port. As the port bindings are completed, we keep
track of whether a port has been bound to another port. If it has, the
source port is farther from the interfaces than the target port (since
it has to go "through" the target port to get to them, and so the
target port should not call register_port.
Change-Id: Ia98f9ff364385fd1699d88a1d99787d205816a08
Reviewed-on: https://gem5-review.googlesource.com/c/13199
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/kernel.cc | 2 | ||||
-rw-r--r-- | src/systemc/core/port.cc | 10 | ||||
-rw-r--r-- | src/systemc/core/port.hh | 9 | ||||
-rw-r--r-- | src/systemc/core/sc_interface.cc | 2 |
4 files changed, 22 insertions, 1 deletions
diff --git a/src/systemc/core/kernel.cc b/src/systemc/core/kernel.cc index ff8e24e6a..5804f9683 100644 --- a/src/systemc/core/kernel.cc +++ b/src/systemc/core/kernel.cc @@ -93,6 +93,8 @@ Kernel::regStats() try { for (auto p: allPorts) p->finalize(); + for (auto p: allPorts) + p->regPort(); status(::sc_core::SC_END_OF_ELABORATION); for (auto p: allPorts) diff --git a/src/systemc/core/port.cc b/src/systemc/core/port.cc index 8ee0549a4..db025bbfe 100644 --- a/src/systemc/core/port.cc +++ b/src/systemc/core/port.cc @@ -120,6 +120,16 @@ Port::finalize() sensitivities.clear(); } +void +Port::regPort() +{ + if (!regPortNeeded) + return; + + for (int i = 0; i < size(); i++) + getInterface(i)->register_port(*portBase, portBase->_ifTypeName()); +} + std::list<Port *> allPorts; } // namespace sc_gem5 diff --git a/src/systemc/core/port.hh b/src/systemc/core/port.hh index bf3b73a84..8c09ad0d3 100644 --- a/src/systemc/core/port.hh +++ b/src/systemc/core/port.hh @@ -31,6 +31,7 @@ #define __SYSTEMC_CORE_PORT_HH__ #include <list> +#include <typeinfo> #include <vector> #include "base/cprintf.hh" @@ -57,6 +58,8 @@ class Port int _maxSize; int _size; + bool regPortNeeded; + void finalizePort(StaticSensitivityPort *port); void finalizeFinder(StaticSensitivityFinder *finder); void finalizeReset(ResetSensitivityPort *reset); @@ -80,6 +83,8 @@ class Port void addInterfaces(::sc_core::sc_port_base *pb) { + // Only the ports farthest from the interfaces call register_port. + pb->_gem5Port->regPortNeeded = false; for (int i = 0; i < pb->size(); i++) addInterface(pb->_gem5Interface(i)); } @@ -136,7 +141,8 @@ class Port ::sc_core::sc_port_base *sc_port_base() { return portBase; } Port(::sc_core::sc_port_base *port_base, int max) : - portBase(port_base), finalized(false), _maxSize(max), _size(0) + portBase(port_base), finalized(false), _maxSize(max), _size(0), + regPortNeeded(true) { allPorts.push_front(this); } @@ -161,6 +167,7 @@ class Port void sensitive(ResetSensitivityPort *reset); void finalize(); + void regPort(); int size() { return _size; } int maxSize() { return _maxSize; } diff --git a/src/systemc/core/sc_interface.cc b/src/systemc/core/sc_interface.cc index a23612683..4b3865e13 100644 --- a/src/systemc/core/sc_interface.cc +++ b/src/systemc/core/sc_interface.cc @@ -35,6 +35,8 @@ namespace sc_core { +void sc_interface::register_port(sc_port_base &, const char *) {} + const sc_event & sc_interface::default_event() const { |