summaryrefslogtreecommitdiff
path: root/src/mem/port.hh
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2012-04-25 10:41:23 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2012-04-25 10:41:23 -0400
commit4c92708b48d51bfb6592ff48925f5a7a0157da5b (patch)
tree2535fb1529ef60f64a3f26f943af5d8d681b22d8 /src/mem/port.hh
parent79750fc575db0966ff9d0530975377c35f630eca (diff)
downloadgem5-4c92708b48d51bfb6592ff48925f5a7a0157da5b.tar.xz
MEM: Add the PortId type and a corresponding id field to Port
This patch introduces the PortId type, moves the definition of INVALID_PORT_ID to the Port class, and also gives every port an id to reflect the fact that each element in a vector port has an identifier/index. Previously the bus and Ruby testers (and potentially other users of the vector ports) added the id field in their port subclasses, and now this functionality is always present as it is moved to the base class.
Diffstat (limited to 'src/mem/port.hh')
-rw-r--r--src/mem/port.hh26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/mem/port.hh b/src/mem/port.hh
index 61c92d8e4..e1f643e8e 100644
--- a/src/mem/port.hh
+++ b/src/mem/port.hh
@@ -79,6 +79,14 @@ class MemObject;
class Port
{
+ public:
+
+ /** A type name for the port identifier. */
+ typedef int PortId;
+
+ /** A symbolic name for the absence of a port id. */
+ static const PortId INVALID_PORT_ID = -1;
+
private:
/** Descriptive name (for DPRINTF output) */
@@ -86,6 +94,12 @@ class Port
protected:
+ /**
+ * A numeric identifier to distinguish ports in a vector, and set
+ * to INVALID_PORT_ID in case this port is not part of a vector.
+ */
+ const PortId id;
+
/** A pointer to the peer port. */
Port* peer;
@@ -97,8 +111,9 @@ class Port
*
* @param _name Port name including the owners name
* @param _owner The MemObject that is the structural owner of this port
+ * @param _id A port identifier for vector ports
*/
- Port(const std::string& _name, MemObject& _owner);
+ Port(const std::string& _name, MemObject& _owner, PortId _id);
/**
* Virtual destructor due to inheritance.
@@ -110,6 +125,9 @@ class Port
/** Return port name (for DPRINTF). */
const std::string name() const { return portName; }
+ /** Get the port id. */
+ PortId getId() const { return id; }
+
protected:
/** These functions are protected because they should only be
@@ -190,7 +208,8 @@ class MasterPort : public Port
public:
- MasterPort(const std::string& name, MemObject* owner);
+ MasterPort(const std::string& name, MemObject* owner,
+ PortId id = INVALID_PORT_ID);
virtual ~MasterPort();
void bind(SlavePort& slave_port);
@@ -286,7 +305,8 @@ class SlavePort : public Port
public:
- SlavePort(const std::string& name, MemObject* owner);
+ SlavePort(const std::string& name, MemObject* owner,
+ PortId id = INVALID_PORT_ID);
virtual ~SlavePort();
void bind(MasterPort& master_port);