mem-cache: Add match functions to QueueEntry
[gem5.git] / src / mem / comm_monitor.cc
index b8fe15ff03694d95018e2d50b88c84d2ad5cb931..f27027dfd18168db1614abcf83bf5a57137060f3 100644 (file)
@@ -1,6 +1,7 @@
 /*
- * Copyright (c) 2012-2013, 2015 ARM Limited
+ * Copyright (c) 2012-2013, 2015, 2018 ARM Limited
  * Copyright (c) 2016 Google Inc.
+ * Copyright (c) 2017, Centre National de la Recherche Scientifique
  * All rights reserved.
  *
  * The license below extends only to copyright in the software and shall
@@ -38,6 +39,7 @@
  * Authors: Thomas Grass
  *          Andreas Hansson
  *          Rahul Thakur
+ *          Pierre-Yves Peneau
  */
 
 #include "mem/comm_monitor.hh"
@@ -50,7 +52,7 @@ CommMonitor::CommMonitor(Params* params)
     : MemObject(params),
       masterPort(name() + "-master", *this),
       slavePort(name() + "-slave", *this),
-      samplePeriodicEvent(this),
+      samplePeriodicEvent([this]{ samplePeriodic(); }, name()),
       samplePeriodTicks(params->sample_period),
       samplePeriod(params->sample_period / SimClock::Float::s),
       stats(params)
@@ -81,23 +83,15 @@ CommMonitor::regProbePoints()
     ppPktResp.reset(new ProbePoints::Packet(getProbeManager(), "PktResponse"));
 }
 
-BaseMasterPort&
-CommMonitor::getMasterPort(const std::string& if_name, PortID idx)
+Port &
+CommMonitor::getPort(const std::string &if_name, PortID idx)
 {
     if (if_name == "master") {
         return masterPort;
-    } else {
-        return MemObject::getMasterPort(if_name, idx);
-    }
-}
-
-BaseSlavePort&
-CommMonitor::getSlavePort(const std::string& if_name, PortID idx)
-{
-    if (if_name == "slave") {
+    } else if (if_name == "slave") {
         return slavePort;
     } else {
-        return MemObject::getSlavePort(if_name, idx);
+        return MemObject::getPort(if_name, idx);
     }
 }
 
@@ -248,8 +242,6 @@ CommMonitor::recvTimingReq(PacketPtr pkt)
     // or even deleted when sendTiming() is called.
     const ProbePoints::PacketInfo pkt_info(pkt);
 
-    const bool is_read = pkt->isRead();
-    const bool is_write = pkt->isWrite();
     const bool expects_response(pkt->needsResponse() &&
                                 !pkt->cacheResponding());
 
@@ -274,8 +266,8 @@ CommMonitor::recvTimingReq(PacketPtr pkt)
     }
 
     if (successful) {
-        DPRINTF(CommMonitor, "Forwarded %s request\n",
-                (is_read ? "read" : (is_write ? "write" : "non read/write")));
+        DPRINTF(CommMonitor, "Forwarded %s request\n", pkt->isRead() ? "read" :
+                pkt->isWrite() ? "write" : "non read/write");
         stats.updateReqStats(pkt_info, false, expects_response);
     }
     return successful;
@@ -291,8 +283,6 @@ CommMonitor::recvTimingResp(PacketPtr pkt)
     // or even deleted when sendTiming() is called.
     const ProbePoints::PacketInfo pkt_info(pkt);
 
-    bool is_read = pkt->isRead();
-    bool is_write = pkt->isWrite();
     Tick latency = 0;
     CommMonitorSenderState* received_state =
         dynamic_cast<CommMonitorSenderState*>(pkt->senderState);
@@ -325,8 +315,8 @@ CommMonitor::recvTimingResp(PacketPtr pkt)
 
     if (successful) {
         ppPktResp->notify(pkt_info);
-        DPRINTF(CommMonitor, "Received %s response\n",
-                (is_read ? "Read" : (is_write ? "Write" : "non read/write")));
+        DPRINTF(CommMonitor, "Received %s response\n", pkt->isRead() ? "read" :
+                pkt->isWrite() ?  "write" : "non read/write");
         stats.updateRespStats(pkt_info, latency, false);
     }
     return successful;
@@ -376,6 +366,12 @@ CommMonitor::recvRespRetry()
     masterPort.sendRetryResp();
 }
 
+bool
+CommMonitor::tryTiming(PacketPtr pkt)
+{
+    return masterPort.tryTiming(pkt);
+}
+
 void
 CommMonitor::recvRangeChange()
 {
@@ -494,7 +490,7 @@ CommMonitor::regStats()
     stats.writeTransHist
         .init(params()->transaction_bins)
         .name(name() + ".writeTransHist")
-        .desc("Histogram of read transactions per sample period")
+        .desc("Histogram of write transactions per sample period")
         .flags(stats.disableTransactionHists ? nozero : pdf);
 
     stats.readAddrDist