changeset 1ebd7c856abc in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=1ebd7c856abc
description:
        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:

 src/cpu/testers/directedtest/RubyDirectedTester.cc |   2 +-
 src/cpu/testers/directedtest/RubyDirectedTester.hh |   6 +--
 src/cpu/testers/rubytest/RubyTester.cc             |   2 +-
 src/cpu/testers/rubytest/RubyTester.hh             |   6 +--
 src/mem/bus.cc                                     |  30 ++++++++-------
 src/mem/bus.hh                                     |  43 +++++++--------------
 src/mem/port.cc                                    |  12 +++---
 src/mem/port.hh                                    |  26 +++++++++++-
 8 files changed, 66 insertions(+), 61 deletions(-)

diffs (truncated from 441 to 300 lines):

diff -r d9ca1c98a690 -r 1ebd7c856abc 
src/cpu/testers/directedtest/RubyDirectedTester.cc
--- a/src/cpu/testers/directedtest/RubyDirectedTester.cc        Wed Apr 25 
08:57:18 2012 -0400
+++ b/src/cpu/testers/directedtest/RubyDirectedTester.cc        Wed Apr 25 
10:41:23 2012 -0400
@@ -93,7 +93,7 @@
 bool
 RubyDirectedTester::CpuPort::recvTiming(PacketPtr pkt)
 {
-    tester->hitCallback(idx, pkt->getAddr());
+    tester->hitCallback(id, pkt->getAddr());
     
     //
     // Now that the tester has completed, delete the packet, then return
diff -r d9ca1c98a690 -r 1ebd7c856abc 
src/cpu/testers/directedtest/RubyDirectedTester.hh
--- a/src/cpu/testers/directedtest/RubyDirectedTester.hh        Wed Apr 25 
08:57:18 2012 -0400
+++ b/src/cpu/testers/directedtest/RubyDirectedTester.hh        Wed Apr 25 
10:41:23 2012 -0400
@@ -54,12 +54,10 @@
 
       public:
         CpuPort(const std::string &_name, RubyDirectedTester *_tester,
-                uint32_t _idx)
-            : MasterPort(_name, _tester), tester(_tester), idx(_idx)
+                Port::PortId _id)
+            : MasterPort(_name, _tester, _id), tester(_tester)
         {}
 
-        uint32_t idx;
-
       protected:
         virtual bool recvTiming(PacketPtr pkt);
         virtual void recvRetry()
diff -r d9ca1c98a690 -r 1ebd7c856abc src/cpu/testers/rubytest/RubyTester.cc
--- a/src/cpu/testers/rubytest/RubyTester.cc    Wed Apr 25 08:57:18 2012 -0400
+++ b/src/cpu/testers/rubytest/RubyTester.cc    Wed Apr 25 10:41:23 2012 -0400
@@ -156,7 +156,7 @@
     // pop the sender state from the packet
     pkt->senderState = senderState->saved;
 
-    tester->hitCallback(idx, subblock);
+    tester->hitCallback(id, subblock);
 
     // Now that the tester has completed, delete the senderState
     // (includes sublock) and the packet, then return
diff -r d9ca1c98a690 -r 1ebd7c856abc src/cpu/testers/rubytest/RubyTester.hh
--- a/src/cpu/testers/rubytest/RubyTester.hh    Wed Apr 25 08:57:18 2012 -0400
+++ b/src/cpu/testers/rubytest/RubyTester.hh    Wed Apr 25 10:41:23 2012 -0400
@@ -57,12 +57,10 @@
         // RubyPorts that support both types of requests, separate InstOnly
         // and DataOnly CpuPorts will map to that RubyPort
 
-        CpuPort(const std::string &_name, RubyTester *_tester, int _idx)
-            : MasterPort(_name, _tester), tester(_tester), idx(_idx)
+        CpuPort(const std::string &_name, RubyTester *_tester, PortId _id)
+            : MasterPort(_name, _tester, _id), tester(_tester)
         {}
 
-        int idx;
-
       protected:
         virtual bool recvTiming(PacketPtr pkt);
         virtual void recvRetry()
diff -r d9ca1c98a690 -r 1ebd7c856abc src/mem/bus.cc
--- a/src/mem/bus.cc    Wed Apr 25 08:57:18 2012 -0400
+++ b/src/mem/bus.cc    Wed Apr 25 10:41:23 2012 -0400
@@ -57,7 +57,8 @@
     : MemObject(p), clock(p->clock),
       headerCycles(p->header_cycles), width(p->width), tickNextIdle(0),
       drainEvent(NULL), busIdleEvent(this), inRetry(false),
-      defaultPortId(INVALID_PORT_ID), useDefaultRange(p->use_default_range),
+      defaultPortId(Port::INVALID_PORT_ID),
+      useDefaultRange(p->use_default_range),
       defaultBlockSize(p->block_size),
       cachedBlockSize(0), cachedBlockSizeValid(false)
 {
@@ -304,7 +305,7 @@
         assert(pkt->isExpressSnoop());
 
         // forward to all snoopers
-        forwardTiming(pkt, INVALID_PORT_ID);
+        forwardTiming(pkt, Port::INVALID_PORT_ID);
 
         // a snoop request came from a connected slave device (one of
         // our master ports), and if it is not coming from the slave
@@ -403,7 +404,7 @@
         // (corresponding to our own slave port that is also in
         // snoopPorts) and should not send it back to where it came
         // from
-        if (exclude_slave_port_id == INVALID_PORT_ID ||
+        if (exclude_slave_port_id == Port::INVALID_PORT_ID ||
             p->getId() != exclude_slave_port_id) {
             // cache is not allowed to refuse snoop
             bool success M5_VAR_USED = p->sendTimingSnoop(pkt);
@@ -467,7 +468,7 @@
 }
 
 void
-Bus::recvRetry(int id)
+Bus::recvRetry(Port::PortId id)
 {
     // we got a retry from a peer that we tried to send something to
     // and failed, but we sent it on the account of someone else, and
@@ -493,7 +494,7 @@
     int dest_id;
 
     dest_id = checkPortCache(addr);
-    if (dest_id != INVALID_PORT_ID)
+    if (dest_id != Port::INVALID_PORT_ID)
         return dest_id;
 
     // Check normal port ranges
@@ -513,7 +514,7 @@
                 return defaultPortId;
             }
         }
-    } else if (defaultPortId != INVALID_PORT_ID) {
+    } else if (defaultPortId != Port::INVALID_PORT_ID) {
         DPRINTF(Bus, "Unable to find destination for addr %#llx, "
                 "will use default port\n", addr);
         return defaultPortId;
@@ -570,7 +571,8 @@
     assert(pkt->isRequest());
 
     // forward to all snoopers
-    std::pair<MemCmd, Tick> snoop_result = forwardAtomic(pkt, INVALID_PORT_ID);
+    std::pair<MemCmd, Tick> snoop_result =
+        forwardAtomic(pkt, Port::INVALID_PORT_ID);
     MemCmd snoop_response_cmd = snoop_result.first;
     Tick snoop_response_latency = snoop_result.second;
 
@@ -599,7 +601,7 @@
         // (corresponding to our own slave port that is also in
         // snoopPorts) and should not send it back to where it came
         // from
-        if (exclude_slave_port_id == INVALID_PORT_ID ||
+        if (exclude_slave_port_id == Port::INVALID_PORT_ID ||
             p->getId() != exclude_slave_port_id) {
             Tick latency = p->sendAtomicSnoop(pkt);
             // in contrast to a functional access, we have to keep on
@@ -668,7 +670,7 @@
     assert(pkt->isRequest());
 
     // forward to all snoopers
-    forwardFunctional(pkt, INVALID_PORT_ID);
+    forwardFunctional(pkt, Port::INVALID_PORT_ID);
 }
 
 void
@@ -681,7 +683,7 @@
         // (corresponding to our own slave port that is also in
         // snoopPorts) and should not send it back to where it came
         // from
-        if (exclude_slave_port_id == INVALID_PORT_ID ||
+        if (exclude_slave_port_id == Port::INVALID_PORT_ID ||
             p->getId() != exclude_slave_port_id)
             p->sendFunctionalSnoop(pkt);
 
@@ -694,7 +696,7 @@
 
 /** Function called by the port when the bus is receiving a range change.*/
 void
-Bus::recvRangeChange(int id)
+Bus::recvRangeChange(Port::PortId id)
 {
     AddrRangeList ranges;
     AddrRangeIter iter;
@@ -758,7 +760,7 @@
 }
 
 AddrRangeList
-Bus::getAddrRanges(int id)
+Bus::getAddrRanges(Port::PortId id)
 {
     AddrRangeList ranges;
 
@@ -799,14 +801,14 @@
 }
 
 bool
-Bus::isSnooping(int id) const
+Bus::isSnooping(Port::PortId id) const
 {
     // in essence, answer the question if there are snooping ports
     return !snoopPorts.empty();
 }
 
 unsigned
-Bus::findBlockSize(int id)
+Bus::findBlockSize(Port::PortId id)
 {
     if (cachedBlockSizeValid)
         return cachedBlockSize;
diff -r d9ca1c98a690 -r 1ebd7c856abc src/mem/bus.hh
--- a/src/mem/bus.hh    Wed Apr 25 08:57:18 2012 -0400
+++ b/src/mem/bus.hh    Wed Apr 25 10:41:23 2012 -0400
@@ -77,18 +77,13 @@
         /** A pointer to the bus to which this port belongs. */
         Bus *bus;
 
-        /** A id to keep track of the interface ID of this port. */
-        int id;
-
       public:
 
         /** Constructor for the BusSlavePort.*/
-        BusSlavePort(const std::string &_name, Bus *_bus, int _id)
-            : SlavePort(_name, _bus), bus(_bus), id(_id)
+        BusSlavePort(const std::string &_name, Bus *_bus, Port::PortId _id)
+            : SlavePort(_name, _bus, _id), bus(_bus)
         { }
 
-        int getId() const { return id; }
-
       protected:
 
         /**
@@ -147,18 +142,13 @@
         /** A pointer to the bus to which this port belongs. */
         Bus *bus;
 
-        /** A id to keep track of the interface ID of this port. */
-        int id;
-
       public:
 
         /** Constructor for the BusMasterPort.*/
-        BusMasterPort(const std::string &_name, Bus *_bus, int _id)
-            : MasterPort(_name, _bus), bus(_bus), id(_id)
+        BusMasterPort(const std::string &_name, Bus *_bus, Port::PortId _id)
+            : MasterPort(_name, _bus, _id), bus(_bus)
         { }
 
-        int getId() const { return id; }
-
         /**
          * Determine if this port should be considered a snooper. This
          * is determined by the bus.
@@ -254,7 +244,7 @@
      * @param pkt Packet to forward
      * @param exclude_slave_port_id Id of slave port to exclude
      */
-    void forwardTiming(PacketPtr pkt, int exclude_slave_port_id);
+    void forwardTiming(PacketPtr pkt, Port::PortId exclude_slave_port_id);
 
     /**
      * Determine if the bus is to be considered occupied when being
@@ -296,7 +286,7 @@
      * @return a pair containing the snoop response and snoop latency
      */
     std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt,
-                                          int exclude_slave_port_id);
+                                          Port::PortId exclude_slave_port_id);
 
     /** Function called by the port when the bus is recieving a Functional
         transaction.*/
@@ -314,14 +304,14 @@
      * @param pkt Packet to forward
      * @param exclude_slave_port_id Id of slave port to exclude
      */
-    void forwardFunctional(PacketPtr pkt, int exclude_slave_port_id);
+    void forwardFunctional(PacketPtr pkt, Port::PortId exclude_slave_port_id);
 
     /** Timing function called by port when it is once again able to process
      * requests. */
-    void recvRetry(int id);
+    void recvRetry(Port::PortId id);
 
     /** Function called by the port when the bus is recieving a range change.*/
-    void recvRangeChange(int id);
+    void recvRangeChange(Port::PortId id);
 
     /** Find which port connected to this bus (if any) should be given a packet
      * with this address.
@@ -333,7 +323,7 @@
     // Cache for the findPort function storing recently used ports from portMap
     struct PortCache {
         bool valid;
-        int  id;
+        Port::PortId id;
         Addr start;
         Addr end;
     };
@@ -356,7 +346,7 @@
             return portCache[2].id;
         }
 
-        return INVALID_PORT_ID;
+        return Port::INVALID_PORT_ID;
     }
 
     // Clears the earliest entry of the cache and inserts a new port entry
@@ -391,7 +381,7 @@
      *
      * @return a list of non-overlapping address ranges
      */
-    AddrRangeList getAddrRanges(int id);
+    AddrRangeList getAddrRanges(Port::PortId id);
 
     /**
      * Determine if the bus port is snooping or not.
@@ -400,7 +390,7 @@
      *
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to