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>
This commit is contained in:
parent
ce2a0076c9
commit
83cabc6264
5 changed files with 16 additions and 26 deletions
5
src/mem/cache/tags/base.cc
vendored
5
src/mem/cache/tags/base.cc
vendored
|
@ -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 :
|
||||
|
|
14
src/mem/cache/tags/base.hh
vendored
14
src/mem/cache/tags/base.hh
vendored
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
1
src/mem/cache/tags/base_set_assoc.cc
vendored
1
src/mem/cache/tags/base_set_assoc.cc
vendored
|
@ -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);
|
||||
|
|
12
src/mem/cache/tags/base_set_assoc.hh
vendored
12
src/mem/cache/tags/base_set_assoc.hh
vendored
|
@ -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.
|
||||
|
|
10
src/mem/cache/tags/fa_lru.hh
vendored
10
src/mem/cache/tags/fa_lru.hh
vendored
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue