mem-cache: Create an address aware TempCacheBlk
[gem5.git] / src / mem / comm_monitor.hh
index 69122cc6042f19b6055aad3a41240bd0fb9edb94..d27594d232f0f158dde263c0b2a0566892ebbf1d 100644 (file)
@@ -1,6 +1,8 @@
 /*
- * Copyright (c) 2012-2013 ARM Limited
- * All rights reserved
+ * Copyright (c) 2012-2013, 2015 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
  * not be construed as granting a license to any other intellectual
  *
  * Authors: Thomas Grass
  *          Andreas Hansson
+ *          Rahul Thakur
+ *          Pierre-Yves Peneau
  */
 
 #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 "proto/protoio.hh"
-#include "sim/system.hh"
+#include "sim/probe/mem.hh"
 
 /**
  * The communication monitor is a MemObject which can monitor statistics of
@@ -62,7 +64,7 @@
 class CommMonitor : public MemObject
 {
 
-  public:
+  public: // Construction & SimObject interfaces
 
     /** Parameters of communication monitor */
     typedef CommMonitorParams Params;
@@ -76,25 +78,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:
 
@@ -172,9 +166,14 @@ class CommMonitor : public MemObject
             return mon.isSnooping();
         }
 
-        void recvRetry()
+        void recvReqRetry()
         {
-            mon.recvRetryMaster();
+            mon.recvReqRetry();
+        }
+
+        void recvRetrySnoopResp()
+        {
+            mon.recvRetrySnoopResp();
         }
 
       private:
@@ -228,9 +227,9 @@ class CommMonitor : public MemObject
             return mon.getAddrRanges();
         }
 
-        void recvRetry()
+        void recvRespRetry()
         {
-            mon.recvRetrySlave();
+            mon.recvRespRetry();
         }
 
       private:
@@ -258,23 +257,23 @@ class CommMonitor : public MemObject
 
     bool recvTimingSnoopResp(PacketPtr pkt);
 
+    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 */
@@ -362,6 +361,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.
@@ -390,38 +395,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;
+    EventFunctionWrapper 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;
 
-    /** 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;
 
-    /** The system in which the monitor lives */
-    System *system;
+    /** @} */
 };
 
 #endif //__MEM_COMM_MONITOR_HH__