MESI Coherence Protocol: Add copyright notice
[gem5.git] / src / mem / noncoherent_bus.cc
index e502a78a8b3c097e2eea3bafe12da45b13a73dba..237e8726b8d7dc6288c43b10a76f01dafad9a53d 100644 (file)
 #include "mem/noncoherent_bus.hh"
 
 NoncoherentBus::NoncoherentBus(const NoncoherentBusParams *p)
-    : BaseBus(p), layer(*this, ".layer", p->clock)
+    : BaseBus(p), reqLayer(*this, ".reqLayer", p->clock),
+      respLayer(*this, ".respLayer", p->clock)
 {
     // create the ports based on the size of the master and slave
     // vector ports, and the presence of the default port, the ports
     // are enumerated starting from zero
     for (int i = 0; i < p->port_master_connection_count; ++i) {
-        std::string portName = csprintf("%s-p%d", name(), i);
+        std::string portName = csprintf("%s.master[%d]", name(), i);
         MasterPort* bp = new NoncoherentBusMasterPort(portName, *this, i);
         masterPorts.push_back(bp);
     }
@@ -70,7 +71,7 @@ NoncoherentBus::NoncoherentBus(const NoncoherentBusParams *p)
     // our corresponding master port
     if (p->port_default_connection_count) {
         defaultPortID = masterPorts.size();
-        std::string portName = csprintf("%s-default", name());
+        std::string portName = name() + ".default";
         MasterPort* bp = new NoncoherentBusMasterPort(portName, *this,
                                                       defaultPortID);
         masterPorts.push_back(bp);
@@ -78,7 +79,7 @@ NoncoherentBus::NoncoherentBus(const NoncoherentBusParams *p)
 
     // create the slave ports, once again starting at zero
     for (int i = 0; i < p->port_slave_connection_count; ++i) {
-        std::string portName = csprintf("%s-p%d", name(), i);
+        std::string portName = csprintf("%s.slave[%d]", name(), i);
         SlavePort* bp = new NoncoherentBusSlavePort(portName, *this, i);
         slavePorts.push_back(bp);
     }
@@ -97,7 +98,7 @@ NoncoherentBus::recvTimingReq(PacketPtr pkt, PortID slave_port_id)
 
     // test if the bus should be considered occupied for the current
     // port
-    if (!layer.tryTiming(src_port)) {
+    if (!reqLayer.tryTiming(src_port)) {
         DPRINTF(NoncoherentBus, "recvTimingReq: src %s %s 0x%x BUSY\n",
                 src_port->name(), pkt->cmdString(), pkt->getAddr());
         return false;
@@ -123,12 +124,12 @@ NoncoherentBus::recvTimingReq(PacketPtr pkt, PortID slave_port_id)
         DPRINTF(NoncoherentBus, "recvTimingReq: src %s %s 0x%x RETRY\n",
                 src_port->name(), pkt->cmdString(), pkt->getAddr());
 
-        layer.failedTiming(src_port, headerFinishTime);
+        reqLayer.failedTiming(src_port, headerFinishTime);
 
         return false;
     }
 
-    layer.succeededTiming(packetFinishTime);
+    reqLayer.succeededTiming(packetFinishTime);
 
     return true;
 }
@@ -141,7 +142,7 @@ NoncoherentBus::recvTimingResp(PacketPtr pkt, PortID master_port_id)
 
     // test if the bus should be considered occupied for the current
     // port
-    if (!layer.tryTiming(src_port)) {
+    if (!respLayer.tryTiming(src_port)) {
         DPRINTF(NoncoherentBus, "recvTimingResp: src %s %s 0x%x BUSY\n",
                 src_port->name(), pkt->cmdString(), pkt->getAddr());
         return false;
@@ -161,7 +162,7 @@ NoncoherentBus::recvTimingResp(PacketPtr pkt, PortID master_port_id)
     // deadlock
     assert(success);
 
-    layer.succeededTiming(packetFinishTime);
+    respLayer.succeededTiming(packetFinishTime);
 
     return true;
 }
@@ -169,8 +170,10 @@ NoncoherentBus::recvTimingResp(PacketPtr pkt, PortID master_port_id)
 void
 NoncoherentBus::recvRetry()
 {
-    // only one layer that can deal with it
-    layer.recvRetry();
+    // responses never block on forwarding them, so the retry will
+    // always be coming from a port to which we tried to forward a
+    // request
+    reqLayer.recvRetry();
 }
 
 Tick
@@ -211,8 +214,8 @@ NoncoherentBus::recvFunctional(PacketPtr pkt, PortID slave_port_id)
 unsigned int
 NoncoherentBus::drain(Event *de)
 {
-    // only one layer to worry about at the moment
-    return layer.drain(de);
+    // sum up the individual layers
+    return reqLayer.drain(de) + respLayer.drain(de);
 }
 
 NoncoherentBus*