mem-cache: Create an address aware TempCacheBlk
[gem5.git] / src / mem / qport.hh
index dd5caa084d07fb6343a09e566d8c6347aa665bda..b15bdfec2c678391f5136e18c6b5a2d0f636e1a1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012,2015 ARM Limited
  * All rights reserved.
  *
  * The license below extends only to copyright in the software and shall
@@ -61,12 +61,10 @@ class QueuedSlavePort : public SlavePort
 
   protected:
 
-    /** Packet queue used to store outgoing requests and responses. */
-    SlavePacketQueue &queue;
+    /** Packet queue used to store outgoing responses. */
+    RespPacketQueue &respQueue;
 
-     /** This function is notification that the device should attempt to send a
-      * packet again. */
-    virtual void recvRetry() { queue.retry(); }
+    void recvRespRetry() { respQueue.retry(); }
 
   public:
 
@@ -78,8 +76,8 @@ class QueuedSlavePort : public SlavePort
      * QueuePort constructor.
      */
     QueuedSlavePort(const std::string& name, MemObject* owner,
-                    SlavePacketQueue &queue) :
-        SlavePort(name, owner), queue(queue)
+                    RespPacketQueue &resp_queue, PortID id = InvalidPortID) :
+        SlavePort(name, owner, id), respQueue(resp_queue)
     { }
 
     virtual ~QueuedSlavePort() { }
@@ -90,40 +88,52 @@ class QueuedSlavePort : public SlavePort
      * @param pkt Packet to send
      * @param when Absolute time (in ticks) to send packet
      */
-    void schedTimingResp(PacketPtr pkt, Tick when)
-    { queue.schedSendTiming(pkt, when); }
+    void schedTimingResp(PacketPtr pkt, Tick when, bool force_order = false)
+    { respQueue.schedSendTiming(pkt, when, force_order); }
 
     /** Check the list of buffered packets against the supplied
      * functional request. */
-    bool checkFunctional(PacketPtr pkt) { return queue.checkFunctional(pkt); }
-
-    unsigned int drain(DrainManager *dm) { return queue.drain(dm); }
+    bool checkFunctional(PacketPtr pkt)
+    { return respQueue.checkFunctional(pkt); }
 };
 
+/**
+ * The QueuedMasterPort combines two queues, a request queue and a
+ * snoop response queue, that both share the same port. The flow
+ * control for requests and snoop responses are completely
+ * independent, and so each queue manages its own flow control
+ * (retries).
+ */
 class QueuedMasterPort : public MasterPort
 {
 
   protected:
 
-    /** Packet queue used to store outgoing requests and responses. */
-    MasterPacketQueue &queue;
+    /** Packet queue used to store outgoing requests. */
+    ReqPacketQueue &reqQueue;
+
+    /** Packet queue used to store outgoing snoop responses. */
+    SnoopRespPacketQueue &snoopRespQueue;
 
-     /** This function is notification that the device should attempt to send a
-      * packet again. */
-    virtual void recvRetry() { queue.retry(); }
+    void recvReqRetry() { reqQueue.retry(); }
+
+    void recvRetrySnoopResp() { snoopRespQueue.retry(); }
 
   public:
 
     /**
      * Create a QueuedPort with a given name, owner, and a supplied
-     * implementation of a packet queue. The external definition of
-     * the queue enables e.g. the cache to implement a specific queue
+     * implementation of two packet queues. The external definition of
+     * the queues enables e.g. the cache to implement a specific queue
      * behaviuor in a subclass, and provide the latter to the
      * QueuePort constructor.
      */
     QueuedMasterPort(const std::string& name, MemObject* owner,
-                     MasterPacketQueue &queue) :
-        MasterPort(name, owner), queue(queue)
+                     ReqPacketQueue &req_queue,
+                     SnoopRespPacketQueue &snoop_resp_queue,
+                     PortID id = InvalidPortID) :
+        MasterPort(name, owner, id), reqQueue(req_queue),
+        snoopRespQueue(snoop_resp_queue)
     { }
 
     virtual ~QueuedMasterPort() { }
@@ -135,7 +145,7 @@ class QueuedMasterPort : public MasterPort
      * @param when Absolute time (in ticks) to send packet
      */
     void schedTimingReq(PacketPtr pkt, Tick when)
-    { queue.schedSendTiming(pkt, when); }
+    { reqQueue.schedSendTiming(pkt, when); }
 
     /**
      * Schedule the sending of a timing snoop response.
@@ -143,14 +153,17 @@ class QueuedMasterPort : public MasterPort
      * @param pkt Packet to send
      * @param when Absolute time (in ticks) to send packet
      */
-    void schedTimingSnoopResp(PacketPtr pkt, Tick when)
-    { queue.schedSendTiming(pkt, when, true); }
+    void schedTimingSnoopResp(PacketPtr pkt, Tick when, bool force_order =
+                              false)
+    { snoopRespQueue.schedSendTiming(pkt, when, force_order); }
 
     /** Check the list of buffered packets against the supplied
      * functional request. */
-    bool checkFunctional(PacketPtr pkt) { return queue.checkFunctional(pkt); }
-
-    unsigned int drain(DrainManager *dm) { return queue.drain(dm); }
+    bool checkFunctional(PacketPtr pkt)
+    {
+        return reqQueue.checkFunctional(pkt) ||
+            snoopRespQueue.checkFunctional(pkt);
+    }
 };
 
 #endif // __MEM_QPORT_HH__