diff options
author | Nikos Nikoleris <nikos.nikoleris@arm.com> | 2016-10-31 12:02:24 +0000 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2017-03-03 14:09:42 +0000 |
commit | 83cabc6264d7aac752e6f1bf8acc7b7b042afa50 (patch) | |
tree | d0029d968f67521f61e4d3b0ae61d359e372b30e /src/mem/cache/tags/base.hh | |
parent | ce2a0076c962a902f34442010f4373f7347a0156 (diff) | |
download | gem5-83cabc6264d7aac752e6f1bf8acc7b7b042afa50.tar.xz |
mem: Make blkAlign a common function between all tag classes
blkAlign was defined as a separate function in the base associative
and fully-associative tags classes although both functions implemented
identical functionality. This patch moves the blkAlign in the base
tags class.
Change-Id: I3d415d0e62bddeec7ce0d559667e40a8c5fdc2d4
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Andreas Hansson <andreas.hansson@arm.com>
Diffstat (limited to 'src/mem/cache/tags/base.hh')
-rw-r--r-- | src/mem/cache/tags/base.hh | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh index dd5426172..4caf6de4e 100644 --- a/src/mem/cache/tags/base.hh +++ b/src/mem/cache/tags/base.hh @@ -67,6 +67,8 @@ class BaseTags : public ClockedObject 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. */ @@ -187,13 +189,23 @@ class BaseTags : public ClockedObject 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. * @return the block offset. */ int extractBlkOffset(Addr addr) const { - return (addr & (Addr)(blkSize-1)); + return (addr & blkMask); } /** |