Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/13199
Change subject: systemc: Add missing sc_interface::register_port, and add
calls to it.
......................................................................
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
---
M src/systemc/core/kernel.cc
M src/systemc/core/port.cc
M src/systemc/core/port.hh
M src/systemc/core/sc_interface.cc
M src/systemc/ext/core/sc_interface.hh
M src/systemc/ext/core/sc_port.hh
6 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/systemc/core/kernel.cc b/src/systemc/core/kernel.cc
index ff8e24e..5804f96 100644
--- a/src/systemc/core/kernel.cc
+++ b/src/systemc/core/kernel.cc
@@ -93,6 +93,8 @@
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 8ee0549..db025bb 100644
--- a/src/systemc/core/port.cc
+++ b/src/systemc/core/port.cc
@@ -120,6 +120,16 @@
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 bf3b73a..8c09ad0 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 @@
int _maxSize;
int _size;
+ bool regPortNeeded;
+
void finalizePort(StaticSensitivityPort *port);
void finalizeFinder(StaticSensitivityFinder *finder);
void finalizeReset(ResetSensitivityPort *reset);
@@ -80,6 +83,8 @@
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 @@
::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 @@
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 a236126..4b3865e 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
{
diff --git a/src/systemc/ext/core/sc_interface.hh
b/src/systemc/ext/core/sc_interface.hh
index 3c6a27d..3b5abdf 100644
--- a/src/systemc/ext/core/sc_interface.hh
+++ b/src/systemc/ext/core/sc_interface.hh
@@ -39,6 +39,7 @@
class sc_interface
{
public:
+ virtual void register_port(sc_port_base &, const char *);
virtual const sc_event &default_event() const;
virtual ~sc_interface() {};
diff --git a/src/systemc/ext/core/sc_port.hh
b/src/systemc/ext/core/sc_port.hh
index 3586fec..904d35b 100644
--- a/src/systemc/ext/core/sc_port.hh
+++ b/src/systemc/ext/core/sc_port.hh
@@ -30,6 +30,7 @@
#ifndef __SYSTEMC_EXT_CORE_SC_PORT_HH__
#define __SYSTEMC_EXT_CORE_SC_PORT_HH__
+#include <typeinfo>
#include <vector>
#include "../utils/sc_report_handler.hh"
@@ -108,6 +109,7 @@
virtual void _gem5AddInterface(sc_interface *i) = 0;
::sc_gem5::Port *_gem5Port;
+ virtual const char *_ifTypeName() const = 0;
};
template <class IF>
@@ -210,6 +212,8 @@
_interfaces.push_back(interface);
}
+ const char *_ifTypeName() const { return typeid(IF).name(); }
+
// Disabled
sc_port_b() {}
sc_port_b(const sc_port_b<IF> &) {}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/13199
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ia98f9ff364385fd1699d88a1d99787d205816a08
Gerrit-Change-Number: 13199
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev