summaryrefslogtreecommitdiff
path: root/src/sim/port.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-08-16 15:27:35 -0700
committerGabe Black <gabeblack@google.com>2019-08-27 22:17:45 +0000
commit2a566b4fa7fbd805746d598d0ffc096c2710cef9 (patch)
tree12c10fb70e8151a81eafefae2e4a5efdf3c63ef3 /src/sim/port.hh
parent3126e84db773f64e46b1d02a9a27892bf6612d30 (diff)
downloadgem5-2a566b4fa7fbd805746d598d0ffc096c2710cef9.tar.xz
mem, sim, systemc: Reorganize Port and co.s bind, unbind slightly.
The base Port class can keep track of its peer, and also whether it's connected. This is partially delegated away from the port subclasses which still keep track of a cast version of their peer pointer for their own conveneince, so that it can be used by generic code. Even with the Port mechanism's new flexibility, each port still has exactly one peer and is either connected or not based on whether there is a peer currently. Change-Id: Id3228617dd1604d196814254a1aadeac5ade7cde Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20232 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/sim/port.hh')
-rw-r--r--src/sim/port.hh24
1 files changed, 22 insertions, 2 deletions
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; }