48 warn_once(
"Associativity higher than number of skewing functions. " \
49 "Expect sub-optimal skewing.\n");
55 "for the skewing functions.");
68 const uint8_t xor_bit = msb ^ lsb;
82 const uint8_t lsb = msb ^ xor_bit;
104 addr1 =
hash(addr1) ^
hash(addr2) ^ addr2;
107 addr1 =
hash(addr1) ^
hash(addr2) ^ addr1;
128 panic(
"A skewing function has not been implemented for this way.");
160 addr1 = addr1 ^
hash(addr2);
168 addr1 = addr1 ^
dehash(addr2);
174 return hash(addr1 ^
hash(addr2) ^ addr2);
176 addr1 = addr1 ^
hash(addr2);
184 addr1 = addr1 ^
dehash(addr2);
190 panic(
"A skewing function has not been implemented for this way.");
215 for (uint32_t way = 0; way <
assoc; ++way) {
A common base class for indexing table locations.
std::vector< std::vector< ReplaceableEntry * > > sets
The cache sets.
const int setShift
The amount to shift the address to get the set.
const uint32_t numSets
The number of sets in the cache.
const unsigned setMask
Mask out all bits that aren't part of the set index.
const int tagShift
The amount to shift the address to get the tag.
const unsigned assoc
The associativity.
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
uint32_t getWay() const
Get way number.
uint32_t getSet() const
Get set number.
Addr regenerateAddr(const Addr tag, const ReplaceableEntry *entry) const override
Regenerate an entry's address from its tag and assigned set and way.
Addr deskew(const Addr addr, const uint32_t way) const
Address deskewing function (inverse of the skew function) of the given way.
uint32_t extractSet(const Addr addr, const uint32_t way) const
Apply a skewing function to calculate address' set given a way.
const int msbShift
The amount to shift a set index to get its MSB.
Addr skew(const Addr addr, const uint32_t way) const
Address skewing function selection.
SkewedAssociativeParams Params
Convenience typedef.
const int NUM_SKEWING_FUNCTIONS
The number of skewing functions implemented.
Addr hash(const Addr addr) const
The hash function itself.
std::vector< ReplaceableEntry * > getPossibleEntries(const Addr addr) const override
Find all possible entries for insertion and replacement of an address.
SkewedAssociative(const Params &p)
Construct and initialize this policy.
Addr dehash(const Addr addr) const
Inverse of the hash function.
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
constexpr T mbits(T val, unsigned first, unsigned last)
Mask off the given bits in place like bits() but without shifting.
constexpr T insertBits(T val, unsigned first, unsigned last, B bit_val)
Returns val with bits first to last set to the LSBs of bit_val.
#define panic(...)
This implements a cprintf based panic() function.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Declaration of a skewed associative indexing policy.