summaryrefslogtreecommitdiff
path: root/src/mem/bus.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2013-02-19 05:56:06 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2013-02-19 05:56:06 -0500
commit7cd49b24d2523eaf21179946e291c46c6acf5bfc (patch)
tree91c066608dfb6e4ca52dd25e91a61719848d64a7 /src/mem/bus.cc
parent5c7ebee434a0328802c01b38c19845c50ae75cab (diff)
downloadgem5-7cd49b24d2523eaf21179946e291c46c6acf5bfc.tar.xz
sim: Make clock private and access using clockPeriod()
This patch makes the clock member private to the ClockedObject and forces all children to access it using clockPeriod(). This makes it impossible to inadvertently change the clock, and also makes it easier to transition to a situation where the clock is derived from e.g. a clock domain, or through a multiplier.
Diffstat (limited to 'src/mem/bus.cc')
-rw-r--r--src/mem/bus.cc37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/mem/bus.cc b/src/mem/bus.cc
index a880eca8f..4d9cdbe88 100644
--- a/src/mem/bus.cc
+++ b/src/mem/bus.cc
@@ -1,5 +1,5 @@
/*
- * 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
@@ -132,37 +132,33 @@ BaseBus::getSlavePort(const std::string &if_name, PortID idx)
Tick
BaseBus::calcPacketTiming(PacketPtr pkt)
{
- // determine the current time rounded to the closest following
+ // determine the header time rounded to the closest following
// clock edge
- Tick now = nextCycle();
-
- Tick headerTime = now + headerCycles * clock;
+ Tick headerTime = clockEdge(headerCycles);
// The packet will be sent. Figure out how long it occupies the bus, and
// how much of that time is for the first "word", aka bus width.
- int numCycles = 0;
+ Cycles numCycles(0);
if (pkt->hasData()) {
// If a packet has data, it needs ceil(size/width) cycles to send it
- int dataSize = pkt->getSize();
- numCycles += dataSize/width;
- if (dataSize % width)
- numCycles++;
+ unsigned dataSize = pkt->getSize();
+ numCycles = Cycles(divCeil(dataSize, width));
}
- // The first word will be delivered after the current tick, the delivery
- // of the address if any, and one bus cycle to deliver the data
- pkt->firstWordTime = headerTime + clock;
+ // The first word will be delivered on the cycle after the header.
+ pkt->firstWordTime = headerTime + clockPeriod();
- pkt->finishTime = headerTime + numCycles * clock;
+ // Note that currently finishTime can be smaller than
+ // firstWordTime if the packet has no data
+ pkt->finishTime = headerTime + numCycles * clockPeriod();
return headerTime;
}
template <typename PortClass>
-BaseBus::Layer<PortClass>::Layer(BaseBus& _bus, const std::string& _name,
- Tick _clock) :
+BaseBus::Layer<PortClass>::Layer(BaseBus& _bus, const std::string& _name) :
Drainable(),
- bus(_bus), _name(_name), state(IDLE), clock(_clock), drainManager(NULL),
+ bus(_bus), _name(_name), state(IDLE), drainManager(NULL),
releaseEvent(this)
{
}
@@ -306,11 +302,8 @@ BaseBus::Layer<PortClass>::retryWaiting()
// snoop responses
state = BUSY;
- // determine the current time rounded to the closest following
- // clock edge
- Tick now = bus.nextCycle();
-
- occupyLayer(now + clock);
+ // occupy the bus layer until the next cycle ends
+ occupyLayer(bus.clockEdge(Cycles(1)));
}
}