diff options
Diffstat (limited to 'src/sim')
-rw-r--r-- | src/sim/port.cc | 2 | ||||
-rw-r--r-- | src/sim/port.hh | 24 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/sim/port.cc b/src/sim/port.cc index b3139a630..fa7df18cf 100644 --- a/src/sim/port.cc +++ b/src/sim/port.cc @@ -50,6 +50,6 @@ #include "sim/port.hh" Port::Port(const std::string& _name, PortID _id) : - portName(_name), id(_id), _connected(false) + portName(_name), id(_id), _peer(nullptr), _connected(false) {} Port::~Port() {} diff --git a/src/sim/port.hh b/src/sim/port.hh index e1811643f..ee4b548a5 100644 --- a/src/sim/port.hh +++ b/src/sim/port.hh @@ -72,6 +72,13 @@ class Port * to InvalidPortID in case this port is not part of a vector. */ const PortID id; + + /** + * A pointer to this port's peer. + */ + Port *_peer; + + /** * Whether this port is currently connected to a peer port. */ @@ -92,6 +99,9 @@ class Port public: + /** Return a reference to this port's peer. */ + Port &getPeer() { return *_peer; } + /** Return port name (for DPRINTF). */ const std::string name() const { return portName; } @@ -99,10 +109,20 @@ class Port PortID getId() const { return id; } /** Attach to a peer port. */ - virtual void bind(Port &peer) = 0; + virtual void + bind(Port &peer) + { + _peer = &peer; + _connected = true; + } /** Dettach from a peer port. */ - virtual void unbind() = 0; + virtual void + unbind() + { + _peer = nullptr; + _connected = false; + } /** Is this port currently connected to a peer? */ bool isConnected() const { return _connected; } |