Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/17037 )

Change subject: sim: Add a getPort function to SimObject.
......................................................................

sim: Add a getPort function to SimObject.

This will retrieve a Port object from a given SimObject (which might
not be a MemObject) no matter what flavor of Port it is.

Change-Id: I636b85e9d4929a05a769e165849106bcb5f3e9c1
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17037
Reviewed-by: Andreas Sandberg <andreas.sandb...@arm.com>
Maintainer: Andreas Sandberg <andreas.sandb...@arm.com>
---
M src/python/m5/SimObject.py
M src/sim/sim_object.cc
M src/sim/sim_object.hh
3 files changed, 23 insertions(+), 0 deletions(-)

Approvals:
  Andreas Sandberg: Looks good to me, approved; Looks good to me, approved



diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index b74e93a..0e29980 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -1642,6 +1642,10 @@
     def getValue(self):
         return self.getCCObject()

+    @cxxMethod(return_value_policy="reference")
+    def getPort(self, if_name, idx):
+        pass
+
     # Create C++ port connections corresponding to the connections in
     # _port_refs
     def connectPorts(self):
diff --git a/src/sim/sim_object.cc b/src/sim/sim_object.cc
index ab92ae5..7b794a0 100644
--- a/src/sim/sim_object.cc
+++ b/src/sim/sim_object.cc
@@ -133,6 +133,12 @@
     return probeManager;
 }

+Port &
+SimObject::getPort(const std::string &if_name, PortID idx)
+{
+    fatal("%s does not have any port named %s\n", name(), if_name);
+}
+
 //
 // static function: serialize all SimObjects.
 //
diff --git a/src/sim/sim_object.hh b/src/sim/sim_object.hh
index 42a19bb..5c9bf00 100644
--- a/src/sim/sim_object.hh
+++ b/src/sim/sim_object.hh
@@ -56,6 +56,7 @@
 #include "sim/drain.hh"
 #include "sim/eventq.hh"
 #include "sim/eventq_impl.hh"
+#include "sim/port.hh"
 #include "sim/serialize.hh"

 class EventManager;
@@ -170,6 +171,18 @@
     ProbeManager *getProbeManager();

     /**
+     * Get a port with a given name and index. This is used at binding time
+     * and returns a reference to a protocol-agnostic port.
+     *
+     * @param if_name Port name
+     * @param idx Index in the case of a VectorPort
+     *
+     * @return A reference to the given port
+     */
+    virtual Port &getPort(const std::string &if_name,
+                          PortID idx=InvalidPortID);
+
+    /**
      * startup() is the final initialization call before simulation.
      * All state is initialized (including unserialized state, if any,
      * such as the curTick() value), so this is the appropriate place to

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/17037
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I636b85e9d4929a05a769e165849106bcb5f3e9c1
Gerrit-Change-Number: 17037
Gerrit-PatchSet: 6
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: Weiping Liao <weipingl...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to