-# Copyright (c) 2012 ARM Limited
+# Copyright (c) 2012-2013 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
cxx_header = "mem/bridge.hh"
slave = SlavePort('Slave port')
master = MasterPort('Master port')
- req_size = Param.Int(16, "The number of requests to buffer")
- resp_size = Param.Int(16, "The number of responses to buffer")
+ req_size = Param.Unsigned(16, "The number of requests to buffer")
+ resp_size = Param.Unsigned(16, "The number of responses to buffer")
delay = Param.Latency('0ns', "The latency of this bridge")
ranges = VectorParam.AddrRange([AllMemory],
"Address ranges to pass through the bridge")
/*
- * Copyright (c) 2011-2012 ARM Limited
+ * Copyright (c) 2011-2013 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
}
bool
-Bridge::BridgeSlavePort::respQueueFull()
+Bridge::BridgeSlavePort::respQueueFull() const
{
return outstandingResponses == respQueueLimit;
}
bool
-Bridge::BridgeMasterPort::reqQueueFull()
+Bridge::BridgeMasterPort::reqQueueFull() const
{
return transmitList.size() == reqQueueLimit;
}
DPRINTF(Bridge, "recvTimingReq: %s addr 0x%x\n",
pkt->cmdString(), pkt->getAddr());
- // ensure we do not have something waiting to retry
- if(retryReq)
- return false;
+ // we should not see a timing request if we are already in a retry
+ assert(!retryReq);
DPRINTF(Bridge, "Response queue size: %d outresp: %d\n",
transmitList.size(), outstandingResponses);
+ // if the request queue is full then there is no hope
if (masterPort.reqQueueFull()) {
DPRINTF(Bridge, "Request queue full\n");
retryReq = true;
- } else if (pkt->needsResponse()) {
- if (respQueueFull()) {
- DPRINTF(Bridge, "Response queue full\n");
- retryReq = true;
- } else {
- DPRINTF(Bridge, "Reserving space for response\n");
- assert(outstandingResponses != respQueueLimit);
- ++outstandingResponses;
- retryReq = false;
+ } else {
+ // look at the response queue if we expect to see a response
+ bool expects_response = pkt->needsResponse() &&
+ !pkt->memInhibitAsserted();
+ if (expects_response) {
+ if (respQueueFull()) {
+ DPRINTF(Bridge, "Response queue full\n");
+ retryReq = true;
+ } else {
+ // ok to send the request with space for the response
+ DPRINTF(Bridge, "Reserving space for response\n");
+ assert(outstandingResponses != respQueueLimit);
+ ++outstandingResponses;
+
+ // no need to set retryReq to false as this is already the
+ // case
+ }
+ }
+ if (!retryReq) {
// @todo: We need to pay for this and not just zero it out
pkt->busFirstWordDelay = pkt->busLastWordDelay = 0;
// If there are more packets to send, schedule event to try again.
if (!transmitList.empty()) {
- req = transmitList.front();
+ DeferredPacket next_req = transmitList.front();
DPRINTF(Bridge, "Scheduling next send\n");
- bridge.schedule(sendEvent, std::max(req.tick,
+ bridge.schedule(sendEvent, std::max(next_req.tick,
bridge.clockEdge()));
}
// If there are more packets to send, schedule event to try again.
if (!transmitList.empty()) {
- resp = transmitList.front();
+ DeferredPacket next_resp = transmitList.front();
DPRINTF(Bridge, "Scheduling next send\n");
- bridge.schedule(sendEvent, std::max(resp.tick,
+ bridge.schedule(sendEvent, std::max(next_resp.tick,
bridge.clockEdge()));
}
void
Bridge::BridgeMasterPort::recvRetry()
{
- Tick nextReady = transmitList.front().tick;
- if (nextReady <= curTick())
- trySendTiming();
- else
- bridge.schedule(sendEvent, nextReady);
+ trySendTiming();
}
void
Bridge::BridgeSlavePort::recvRetry()
{
- Tick nextReady = transmitList.front().tick;
- if (nextReady <= curTick())
- trySendTiming();
- else
- bridge.schedule(sendEvent, nextReady);
+ trySendTiming();
}
Tick
void
Bridge::BridgeSlavePort::recvFunctional(PacketPtr pkt)
{
- std::list<DeferredPacket>::iterator i;
-
pkt->pushLabel(name());
// check the response queue
- for (i = transmitList.begin(); i != transmitList.end(); ++i) {
+ for (auto i = transmitList.begin(); i != transmitList.end(); ++i) {
if (pkt->checkFunctional((*i).pkt)) {
pkt->makeResponse();
return;
Bridge::BridgeMasterPort::checkFunctional(PacketPtr pkt)
{
bool found = false;
- std::list<DeferredPacket>::iterator i = transmitList.begin();
+ auto i = transmitList.begin();
while(i != transmitList.end() && !found) {
if (pkt->checkFunctional((*i).pkt)) {
/*
- * Copyright (c) 2011-2012 ARM Limited
+ * Copyright (c) 2011-2013 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
#ifndef __MEM_BRIDGE_HH__
#define __MEM_BRIDGE_HH__
-#include <list>
+#include <deque>
#include "base/types.hh"
#include "mem/mem_object.hh"
public:
- PortID origSrc;
+ const PortID origSrc;
RequestState(PortID orig_src) : origSrc(orig_src)
{ }
public:
- Tick tick;
- PacketPtr pkt;
+ const Tick tick;
+ const PacketPtr pkt;
DeferredPacket(PacketPtr _pkt, Tick _tick) : tick(_tick), pkt(_pkt)
{ }
BridgeMasterPort& masterPort;
/** Minimum request delay though this bridge. */
- Cycles delay;
+ const Cycles delay;
/** Address ranges to pass through the bridge */
- AddrRangeList ranges;
+ const AddrRangeList ranges;
/**
* Response packet queue. Response packets are held in this
* queue for a specified delay to model the processing delay
- * of the bridge.
+ * of the bridge. We use a deque as we need to iterate over
+ * the items for functional accesses.
*/
- std::list<DeferredPacket> transmitList;
+ std::deque<DeferredPacket> transmitList;
/** Counter to track the outstanding responses. */
unsigned int outstandingResponses;
*
* @return true if the reserved space has reached the set limit
*/
- bool respQueueFull();
+ bool respQueueFull() const;
/**
* Handle send event, scheduled when the packet at the head of
BridgeSlavePort& slavePort;
/** Minimum delay though this bridge. */
- Cycles delay;
+ const Cycles delay;
/**
* Request packet queue. Request packets are held in this
* queue for a specified delay to model the processing delay
- * of the bridge.
+ * of the bridge. We use a deque as we need to iterate over
+ * the items for functional accesses.
*/
- std::list<DeferredPacket> transmitList;
+ std::deque<DeferredPacket> transmitList;
/** Max queue size for request packets */
- unsigned int reqQueueLimit;
+ const unsigned int reqQueueLimit;
/**
* Handle send event, scheduled when the packet at the head of
*
* @return true if the occupied space has reached the set limit
*/
- bool reqQueueFull();
+ bool reqQueueFull() const;
/**
* Queue a request packet to be sent out later and also schedule