/*
- * Copyright (c) 2013 ARM Limited
+ * Copyright (c) 2013,2016 ARM Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
using namespace std;
BaseTags::BaseTags(const Params *p)
- : ClockedObject(p), blkSize(p->block_size), size(p->size),
+ : ClockedObject(p), blkSize(p->block_size), blkMask(blkSize - 1),
+ size(p->size),
lookupLatency(p->tag_latency),
accessLatency(p->sequential_access ?
p->tag_latency + p->data_latency :
protected:
/** The block size of the cache. */
const unsigned blkSize;
+ /** Mask out all bits that aren't part of the block offset. */
+ const Addr blkMask;
/** The size of the cache. */
const unsigned size;
/** The tag lookup latency of the cache. */
*/
virtual CacheBlk * findBlock(Addr addr, bool is_secure) const = 0;
+ /**
+ * Align an address to the block size.
+ * @param addr the address to align.
+ * @return The block address.
+ */
+ Addr blkAlign(Addr addr) const
+ {
+ return addr & ~blkMask;
+ }
+
/**
* Calculate the block offset of an address.
* @param addr the address to get the offset of.
*/
int extractBlkOffset(Addr addr) const
{
- return (addr & (Addr)(blkSize-1));
+ return (addr & blkMask);
}
/**
fatal("associativity must be greater than zero");
}
- blkMask = blkSize - 1;
setShift = floorLog2(blkSize);
setMask = numSets - 1;
tagShift = setShift + floorLog2(numSets);
int tagShift;
/** Mask out all bits that aren't part of the set index. */
unsigned setMask;
- /** Mask out all bits that aren't part of the block offset. */
- unsigned blkMask;
public:
return ((addr >> setShift) & setMask);
}
- /**
- * Align an address to the block size.
- * @param addr the address to align.
- * @return The block address.
- */
- Addr blkAlign(Addr addr) const
- {
- return (addr & ~(Addr)blkMask);
- }
-
/**
* Regenerate the block address from the tag.
* @param tag The tag of the block.
*/
CacheBlk* findBlockBySetAndWay(int set, int way) const override;
- /**
- * Align an address to the block size.
- * @param addr the address to align.
- * @return The aligned address.
- */
- Addr blkAlign(Addr addr) const
- {
- return (addr & ~(Addr)(blkSize-1));
- }
-
/**
* Generate the tag from the addres. For fully associative this is just the
* block address.