mem: Remove unused size field from the CacheBlk class
[gem5.git] / src / mem / comm_monitor.hh
index 4b90306e18da9b8d120a3129dbd8e27d49e047ca..d46f75fe073374369de8409dfc30ece76e5c3b56 100644 (file)
@@ -1,6 +1,7 @@
 /*
- * Copyright (c) 2012 ARM Limited
- * All rights reserved
+ * Copyright (c) 2012-2013, 2015 ARM Limited
+ * Copyright (c) 2016 Google Inc.
+ * All rights reserved.
  *
  * The license below extends only to copyright in the software and shall
  * not be construed as granting a license to any other intellectual
  *
  * Authors: Thomas Grass
  *          Andreas Hansson
+ *          Rahul Thakur
  */
 
 #ifndef __MEM_COMM_MONITOR_HH__
 #define __MEM_COMM_MONITOR_HH__
 
 #include "base/statistics.hh"
-#include "base/time.hh"
 #include "mem/mem_object.hh"
 #include "params/CommMonitor.hh"
+#include "sim/probe/mem.hh"
 
 /**
  * The communication monitor is a MemObject which can monitor statistics of
@@ -60,7 +62,7 @@
 class CommMonitor : public MemObject
 {
 
-  public:
+  public: // Construction & SimObject interfaces
 
     /** Parameters of communication monitor */
     typedef CommMonitorParams Params;
@@ -74,19 +76,17 @@ class CommMonitor : public MemObject
      */
     CommMonitor(Params* params);
 
-    /** Destructor */
-    ~CommMonitor() { }
+    void init() override;
+    void regStats() override;
+    void startup() override;
+    void regProbePoints() override;
 
-    virtual MasterPort& getMasterPort(const std::string& if_name,
-                                      int idx = -1);
+  public: // MemObject interfaces
+    BaseMasterPort& getMasterPort(const std::string& if_name,
+                                  PortID idx = InvalidPortID) override;
 
-    virtual SlavePort& getSlavePort(const std::string& if_name,
-                                    int idx = -1);
-
-    virtual void init();
-
-    /** Register statistics */
-    void regStats();
+    BaseSlavePort& getSlavePort(const std::string& if_name,
+                                PortID idx = InvalidPortID) override;
 
   private:
 
@@ -100,23 +100,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;
 
@@ -169,14 +164,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:
@@ -225,19 +220,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:
@@ -265,27 +255,23 @@ 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
     {
 
-        /** Disable flag for burst length historgrams **/
+        /** Disable flag for burst length histograms **/
         bool disableBurstLengthHists;
 
         /** Histogram of read burst lengths */
@@ -373,6 +359,12 @@ class CommMonitor : public MemObject
         /** Disable flag for address distributions. */
         bool disableAddrDists;
 
+        /** Address mask for sources of read accesses to be captured */
+        const Addr readAddrMask;
+
+        /** Address mask for sources of write accesses to be captured */
+        const Addr writeAddrMask;
+
         /**
          * Histogram of number of read accesses to addresses over
          * time.
@@ -401,32 +393,51 @@ class CommMonitor : public MemObject
             outstandingReadReqs(0), outstandingWriteReqs(0),
             disableTransactionHists(params->disable_transaction_hists),
             readTrans(0), writeTrans(0),
-            disableAddrDists(params->disable_addr_dists)
+            disableAddrDists(params->disable_addr_dists),
+            readAddrMask(params->read_addr_mask),
+            writeAddrMask(params->write_addr_mask)
         { }
 
+        void updateReqStats(const ProbePoints::PacketInfo& pkt, bool is_atomic,
+                            bool expects_response);
+        void updateRespStats(const ProbePoints::PacketInfo& pkt, Tick latency,
+                             bool is_atomic);
     };
 
     /** 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;
 
-    /** Length of simulation time bin*/
-    Tick samplePeriodTicks;
-    Time samplePeriod;
+    /**
+     *@{
+     * @name Configuration
+     */
 
-    /** Address mask for sources of read accesses to be captured */
-    Addr readAddrMask;
+    /** Length of simulation time bin*/
+    const Tick samplePeriodTicks;
+    /** Sample period in seconds */
+    const double samplePeriod;
 
-    /** Address mask for sources of write accesses to be captured */
-    Addr writeAddrMask;
+    /** @} */
 
     /** Instantiate stats */
     MonitorStats stats;
+
+  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__