}
Bus::BusFreeEvent::BusFreeEvent(Bus *_bus) : Event(&mainEventQueue), bus(_bus)
-{
- assert(!scheduled());
-}
+{}
void Bus::BusFreeEvent::process()
{
- bus->recvRetry(0);
+ bus->recvRetry(-1);
}
const char * Bus::BusFreeEvent::description()
// If the bus is busy, or other devices are in line ahead of the current
// one, put this device on the retry list.
if (tickNextIdle > curTick ||
- (retryList.size() && pktPort != retryingPort)) {
+ (retryList.size() && (!inRetry || pktPort != retryList.front()))) {
addToRetryList(pktPort);
return false;
}
assert(success);
if (pkt->flags & SATISFIED) {
//Cache-Cache transfer occuring
- if (retryingPort) {
+ if (inRetry) {
retryList.pop_front();
- retryingPort = NULL;
+ inRetry = false;
}
return true;
}
if (port->sendTiming(pkt)) {
// Packet was successfully sent. Return true.
// Also take care of retries
- if (retryingPort) {
+ if (inRetry) {
retryList.pop_front();
- retryingPort = NULL;
+ inRetry = false;
}
return true;
}
{
// If there's anything waiting...
if (retryList.size()) {
- retryingPort = retryList.front();
- retryingPort->sendRetry();
- // If the retryingPort pointer isn't null, sendTiming wasn't called
- if (retryingPort) {
- warn("sendRetry didn't call sendTiming\n");
- retryList.pop_front();
- retryingPort = NULL;
- }
+ //retryingPort = retryList.front();
+ inRetry = true;
+ retryList.front()->sendRetry();
+ // If inRetry is still true, sendTiming wasn't called
+ if (inRetry)
+ panic("Port %s didn't call sendTiming in it's recvRetry\n",\
+ retryList.front()->getPeer()->name());
+ //assert(!inRetry);
}
}
BusFreeEvent busIdle;
- Port * retryingPort;
+ bool inRetry;
/** An array of pointers to the peer port interfaces
connected to this bus.*/
void addToRetryList(Port * port)
{
- if (!retryingPort) {
+ if (!inRetry) {
// The device wasn't retrying a packet, or wasn't at an appropriate
// time.
retryList.push_back(port);
} else {
// The device was retrying a packet. It didn't work, so we'll leave
// it at the head of the retry list.
- retryingPort = NULL;
+ inRetry = false;
- // We shouldn't be receiving a packet from one port when a different
+/* // We shouldn't be receiving a packet from one port when a different
// one is retrying.
- assert(port == retryingPort);
+ assert(port == retryingPort);*/
}
}
Bus(const std::string &n, int bus_id, int _clock, int _width)
: MemObject(n), busId(bus_id), clock(_clock), width(_width),
- tickNextIdle(0), busIdle(this), retryingPort(NULL), defaultPort(NULL)
+ tickNextIdle(0), busIdle(this), inRetry(false), defaultPort(NULL)
{
//Both the width and clock period must be positive
- assert(width);
- assert(clock);
+ if (width <= 0)
+ fatal("Bus width must be positive\n");
+ if (clock <= 0)
+ fatal("Bus clock period must be positive\n");
}
};
assert(port->outTiming >= 0);
if (port->transmitList.size()) {
port->transmitList.push_back(packet);
- }
- else if (port->sendTiming(packet)) {
+ } else if (port->sendTiming(packet)) {
// send successful
if (port->transmitList.size() == 0 && port->drainEvent) {
port->drainEvent->process();