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 | |
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')
-rw-r--r-- | src/mem/cache/tags/base.cc | 5 | ||||
-rw-r--r-- | src/mem/cache/tags/base.hh | 14 | ||||
-rw-r--r-- | src/mem/cache/tags/base_set_assoc.cc | 1 | ||||
-rw-r--r-- | src/mem/cache/tags/base_set_assoc.hh | 12 | ||||
-rw-r--r-- | src/mem/cache/tags/fa_lru.hh | 10 |
5 files changed, 16 insertions, 26 deletions
diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc index cf970c7dd..7796cd3e5 100644 --- a/src/mem/cache/tags/base.cc +++ b/src/mem/cache/tags/base.cc @@ -1,5 +1,5 @@ /* - * 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 @@ -55,7 +55,8 @@ 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 : 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); } /** diff --git a/src/mem/cache/tags/base_set_assoc.cc b/src/mem/cache/tags/base_set_assoc.cc index a96825975..ea74c97df 100644 --- a/src/mem/cache/tags/base_set_assoc.cc +++ b/src/mem/cache/tags/base_set_assoc.cc @@ -70,7 +70,6 @@ BaseSetAssoc::BaseSetAssoc(const Params *p) fatal("associativity must be greater than zero"); } - blkMask = blkSize - 1; setShift = floorLog2(blkSize); setMask = numSets - 1; tagShift = setShift + floorLog2(numSets); diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh index 8e3aab741..4049b8486 100644 --- a/src/mem/cache/tags/base_set_assoc.hh +++ b/src/mem/cache/tags/base_set_assoc.hh @@ -106,8 +106,6 @@ class BaseSetAssoc : public BaseTags 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: @@ -322,16 +320,6 @@ public: } /** - * 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. * @param set The set of the block. diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh index 26de1ede2..a266fb516 100644 --- a/src/mem/cache/tags/fa_lru.hh +++ b/src/mem/cache/tags/fa_lru.hh @@ -221,16 +221,6 @@ public: 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. * @param addr The address to get the tag from. |