From: Nikos Nikoleris Date: Mon, 31 Oct 2016 12:02:24 +0000 (+0000) Subject: mem: Make blkAlign a common function between all tag classes X-Git-Tag: v19.0.0.0~2926 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83cabc6264d7aac752e6f1bf8acc7b7b042afa50;p=gem5.git 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 Reviewed-by: Andreas Hansson --- 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. */ @@ -186,6 +188,16 @@ 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. @@ -193,7 +205,7 @@ class BaseTags : public ClockedObject */ 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: @@ -321,16 +319,6 @@ 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. 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 @@ -220,16 +220,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.