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>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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() {};
|
||||
|
||||
|
||||
@@ -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> &) {}
|
||||
|
||||
Reference in New Issue
Block a user