diff options
Diffstat (limited to 'src/systemc')
-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 | ||||
-rw-r--r-- | src/systemc/ext/core/sc_interface.hh | 1 | ||||
-rw-r--r-- | src/systemc/ext/core/sc_port.hh | 4 |
6 files changed, 27 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 { diff --git a/src/systemc/ext/core/sc_interface.hh b/src/systemc/ext/core/sc_interface.hh index 3c6a27dea..3b5abdf09 100644 --- a/src/systemc/ext/core/sc_interface.hh +++ b/src/systemc/ext/core/sc_interface.hh @@ -39,6 +39,7 @@ class sc_event; 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 3586fec73..904d35b8e 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 @@ class sc_port_base : public sc_object virtual void _gem5AddInterface(sc_interface *i) = 0; ::sc_gem5::Port *_gem5Port; + virtual const char *_ifTypeName() const = 0; }; template <class IF> @@ -210,6 +212,8 @@ class sc_port_b : public sc_port_base _interfaces.push_back(interface); } + const char *_ifTypeName() const { return typeid(IF).name(); } + // Disabled sc_port_b() {} sc_port_b(const sc_port_b<IF> &) {} |