port(name() + ".port", *this), latency(p->latency),
latency_var(p->latency_var), bandwidth(p->bandwidth), isBusy(false),
retryReq(false), retryResp(false),
- releaseEvent(this), dequeueEvent(this), drainManager(NULL)
+ releaseEvent(this), dequeueEvent(this)
{
}
// to keep things simple (and in order), we put the packet at
// the end even if the latency suggests it should be sent
// before the packet(s) before it
- packetQueue.push_back(DeferredPacket(pkt, curTick() + getLatency()));
+ packetQueue.emplace_back(pkt, curTick() + getLatency());
if (!retryResp && !dequeueEvent.scheduled())
schedule(dequeueEvent, packetQueue.back().tick);
} else {
isBusy = false;
if (retryReq) {
retryReq = false;
- port.sendRetry();
+ port.sendRetryReq();
}
}
// already have an event scheduled, so use re-schedule
reschedule(dequeueEvent,
std::max(packetQueue.front().tick, curTick()), true);
- } else if (drainManager) {
- DPRINTF(Drain, "Drainng of SimpleMemory complete\n");
- drainManager->signalDrainDone();
- drainManager = NULL;
+ } else if (drainState() == DrainState::Draining) {
+ DPRINTF(Drain, "Draining of SimpleMemory complete\n");
+ signalDrainDone();
}
}
}
}
void
-SimpleMemory::recvRetry()
+SimpleMemory::recvRespRetry()
{
assert(retryResp);
}
}
-unsigned int
-SimpleMemory::drain(DrainManager *dm)
+DrainState
+SimpleMemory::drain()
{
- int count = 0;
-
- // also track our internal queue
if (!packetQueue.empty()) {
- count += 1;
- drainManager = dm;
DPRINTF(Drain, "SimpleMemory Queue has requests, waiting to drain\n");
- }
-
- if (count)
- setDrainState(Drainable::Draining);
- else
- setDrainState(Drainable::Drained);
- return count;
+ return DrainState::Draining;
+ } else {
+ return DrainState::Drained;
+ }
}
SimpleMemory::MemoryPort::MemoryPort(const std::string& _name,
}
void
-SimpleMemory::MemoryPort::recvRetry()
+SimpleMemory::MemoryPort::recvRespRetry()
{
- memory.recvRetry();
+ memory.recvRespRetry();
}
SimpleMemory*