mem: Include WriteLineReq in cache demand stats
[gem5.git] / src / mem / comm_monitor.hh
index 271ae5fff2060af702eade3c13beac173654da0a..5ccce80370f218f1a8bfab4a7be67ed3d573f7bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012-2013, 2015 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
 #define __MEM_COMM_MONITOR_HH__
 
 #include "base/statistics.hh"
-#include "base/time.hh"
 #include "mem/mem_object.hh"
 #include "params/CommMonitor.hh"
-#include "proto/protoio.hh"
+#include "sim/probe/mem.hh"
 
 /**
  * The communication monitor is a MemObject which can monitor statistics of
@@ -61,7 +60,7 @@
 class CommMonitor : public MemObject
 {
 
-  public:
+  public: // Construction & SimObject interfaces
 
     /** Parameters of communication monitor */
     typedef CommMonitorParams Params;
@@ -75,25 +74,17 @@ class CommMonitor : public MemObject
      */
     CommMonitor(Params* params);
 
-    /** Destructor */
-    ~CommMonitor() {}
+    void init() override;
+    void regStats() override;
+    void startup() override;
+    void regProbePoints() override;
 
-    /**
-     * Callback to flush and close all open output streams on exit. If
-     * we were calling the destructor it could be done there.
-     */
-    void closeStreams();
-
-    virtual BaseMasterPort& getMasterPort(const std::string& if_name,
-                                          PortID idx = InvalidPortID);
+  public: // MemObject interfaces
+    BaseMasterPort& getMasterPort(const std::string& if_name,
+                                  PortID idx = InvalidPortID) override;
 
-    virtual BaseSlavePort& getSlavePort(const std::string& if_name,
-                                        PortID idx = InvalidPortID);
-
-    virtual void init();
-
-    /** Register statistics */
-    void regStats();
+    BaseSlavePort& getSlavePort(const std::string& if_name,
+                                PortID idx = InvalidPortID) override;
 
   private:
 
@@ -107,23 +98,18 @@ class CommMonitor : public MemObject
       public:
 
         /**
-         * Construct a new sender state and remember the original one
-         * so that we can implement a stack.
+         * Construct a new sender state and store the time so we can
+         * calculate round-trip latency.
          *
-         * @param _origSenderState Sender state to remember
          * @param _transmitTime Time of packet transmission
          */
-        CommMonitorSenderState(SenderState* _origSenderState,
-                               Tick _transmitTime)
-            : origSenderState(_origSenderState), transmitTime(_transmitTime)
+        CommMonitorSenderState(Tick _transmitTime)
+            : transmitTime(_transmitTime)
         { }
 
         /** Destructor */
         ~CommMonitorSenderState() { }
 
-        /** Pointer to old sender state of packet */
-        SenderState* origSenderState;
-
         /** Tick when request is transmitted */
         Tick transmitTime;
 
@@ -176,14 +162,14 @@ class CommMonitor : public MemObject
             return mon.isSnooping();
         }
 
-        unsigned deviceBlockSize() const
+        void recvReqRetry()
         {
-            return mon.deviceBlockSizeMaster();
+            mon.recvReqRetry();
         }
 
-        void recvRetry()
+        void recvRetrySnoopResp()
         {
-            mon.recvRetryMaster();
+            mon.recvRetrySnoopResp();
         }
 
       private:
@@ -232,19 +218,14 @@ class CommMonitor : public MemObject
             return mon.recvTimingSnoopResp(pkt);
         }
 
-        unsigned deviceBlockSize() const
-        {
-            return mon.deviceBlockSizeSlave();
-        }
-
         AddrRangeList getAddrRanges() const
         {
             return mon.getAddrRanges();
         }
 
-        void recvRetry()
+        void recvRespRetry()
         {
-            mon.recvRetrySlave();
+            mon.recvRespRetry();
         }
 
       private:
@@ -272,22 +253,18 @@ class CommMonitor : public MemObject
 
     bool recvTimingSnoopResp(PacketPtr pkt);
 
-    unsigned deviceBlockSizeMaster();
-
-    unsigned deviceBlockSizeSlave();
+    void recvRetrySnoopResp();
 
     AddrRangeList getAddrRanges() const;
 
     bool isSnooping() const;
 
-    void recvRetryMaster();
+    void recvReqRetry();
 
-    void recvRetrySlave();
+    void recvRespRetry();
 
     void recvRangeChange();
 
-    void periodicTraceDump();
-
     /** Stats declarations, all in a struct for convenience. */
     struct MonitorStats
     {
@@ -416,27 +393,43 @@ class CommMonitor : public MemObject
     /** This function is called periodically at the end of each time bin */
     void samplePeriodic();
 
-    /** Schedule the first periodic event */
-    void startup();
-
     /** Periodic event called at the end of each simulation time bin */
     EventWrapper<CommMonitor, &CommMonitor::samplePeriodic> samplePeriodicEvent;
 
+    /**
+     *@{
+     * @name Configuration
+     */
+
     /** Length of simulation time bin*/
-    Tick samplePeriodTicks;
-    Time samplePeriod;
+    const Tick samplePeriodTicks;
+    /** Sample period in seconds */
+    const double samplePeriod;
 
     /** Address mask for sources of read accesses to be captured */
-    Addr readAddrMask;
+    const Addr readAddrMask;
 
     /** Address mask for sources of write accesses to be captured */
-    Addr writeAddrMask;
+    const Addr writeAddrMask;
+
+    /** @} */
 
     /** Instantiate stats */
     MonitorStats stats;
 
-    /** Output stream for a potential trace. */
-    ProtoOutputStream* traceStream;
+  protected: // Probe points
+    /**
+     * @{
+     * @name Memory system probe points
+     */
+
+    /** Successfully forwarded request packet */
+    ProbePoints::PacketUPtr ppPktReq;
+
+    /** Successfully forwarded response packet */
+    ProbePoints::PacketUPtr ppPktResp;
+
+    /** @} */
 };
 
 #endif //__MEM_COMM_MONITOR_HH__