diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-10-11 06:38:43 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-10-11 06:38:43 -0400 |
commit | 43ca8415e8747145cb1a410d4672d4cd2247c695 (patch) | |
tree | 079d9c95eb41033870017b84205c625e95febf00 /src/mem/bus.cc | |
parent | 5dba9225f7cdbcef342fd64c70f91b5bbea2a1a1 (diff) | |
download | gem5-43ca8415e8747145cb1a410d4672d4cd2247c695.tar.xz |
Mem: Determine bus block size during initialisation
This patch moves the block size computation from findBlockSize to
initialisation time, once all the neighbouring ports are connected.
There is no need to dynamically update the block size, and the caching
of the value effectively avoided that anyhow. This is very similar to
what was already in place, just with a slightly leaner implementation.
Diffstat (limited to 'src/mem/bus.cc')
-rw-r--r-- | src/mem/bus.cc | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/src/mem/bus.cc b/src/mem/bus.cc index 4dfcbad1c..d4157e14d 100644 --- a/src/mem/bus.cc +++ b/src/mem/bus.cc @@ -59,8 +59,7 @@ BaseBus::BaseBus(const BaseBusParams *p) headerCycles(p->header_cycles), width(p->width), defaultPortID(InvalidPortID), useDefaultRange(p->use_default_range), - defaultBlockSize(p->block_size), - cachedBlockSize(0), cachedBlockSizeValid(false) + blockSize(p->block_size) {} BaseBus::~BaseBus() @@ -76,6 +75,34 @@ BaseBus::~BaseBus() } } +void +BaseBus::init() +{ + // determine the maximum peer block size, look at both the + // connected master and slave modules + uint32_t peer_block_size = 0; + + for (MasterPortConstIter m = masterPorts.begin(); m != masterPorts.end(); + ++m) { + peer_block_size = std::max((*m)->peerBlockSize(), peer_block_size); + } + + for (SlavePortConstIter s = slavePorts.begin(); s != slavePorts.end(); + ++s) { + peer_block_size = std::max((*s)->peerBlockSize(), peer_block_size); + } + + // if the peers do not have a block size, use the default value + // set through the bus parameters + if (peer_block_size != 0) + blockSize = peer_block_size; + + // check if the block size is a value known to work + if (blockSize != 16 || blockSize != 32 || blockSize != 64 || + blockSize != 128) + warn_once("Block size is neither 16, 32, 64 or 128 bytes.\n"); +} + MasterPort & BaseBus::getMasterPort(const std::string &if_name, int idx) { @@ -452,34 +479,9 @@ BaseBus::getAddrRanges() const } unsigned -BaseBus::findBlockSize() +BaseBus::deviceBlockSize() const { - if (cachedBlockSizeValid) - return cachedBlockSize; - - unsigned max_bs = 0; - - for (MasterPortConstIter m = masterPorts.begin(); m != masterPorts.end(); - ++m) { - unsigned tmp_bs = (*m)->peerBlockSize(); - if (tmp_bs > max_bs) - max_bs = tmp_bs; - } - - for (SlavePortConstIter s = slavePorts.begin(); s != slavePorts.end(); - ++s) { - unsigned tmp_bs = (*s)->peerBlockSize(); - if (tmp_bs > max_bs) - max_bs = tmp_bs; - } - if (max_bs == 0) - max_bs = defaultBlockSize; - - if (max_bs != 64 && max_bs != 32) - warn_once("Blocksize found to not be 32 or 64... hmm... probably not.\n"); - cachedBlockSize = max_bs; - cachedBlockSizeValid = true; - return max_bs; + return blockSize; } template <typename PortClass> |