29 #ifndef __CACHE_PREFETCH_ASSOCIATIVE_SET_IMPL_HH__
30 #define __CACHE_PREFETCH_ASSOCIATIVE_SET_IMPL_HH__
41 Entry const &init_value)
42 : associativity(assoc), numEntries(num_entries), indexingPolicy(idx_policy),
43 replacementPolicy(rpl_policy), entries(numEntries, init_value)
46 "AssociativeSet<> must be a power of 2");
48 "must be a power of 2");
49 for (
unsigned int entry_idx = 0; entry_idx < numEntries; entry_idx += 1) {
50 Entry* entry = &entries[entry_idx];
51 indexingPolicy->setEntry(entry, entry_idx);
52 entry->replacementData = replacementPolicy->instantiateEntry();
60 Addr tag = indexingPolicy->extractTag(
addr);
62 indexingPolicy->getPossibleEntries(
addr);
64 for (
const auto& location : selected_entries) {
66 if ((entry->getTag() == tag) && entry->isValid() &&
67 entry->isSecure() == is_secure) {
78 replacementPolicy->touch(entry->replacementData);
87 indexingPolicy->getPossibleEntries(
addr);
88 Entry* victim =
static_cast<Entry*
>(replacementPolicy->getVictim(
101 indexingPolicy->getPossibleEntries(
addr);
104 unsigned int idx = 0;
105 for (
auto &entry : selected_entries) {
106 entries[idx++] =
static_cast<Entry *
>(entry);
111 template<
class Entry>
115 entry->insert(indexingPolicy->extractTag(
addr), is_secure);
116 replacementPolicy->reset(entry->replacementData);
119 template<
class Entry>
124 replacementPolicy->invalidate(entry->replacementData);
129 #endif//__CACHE_PREFETCH_ASSOCIATIVE_SET_IMPL_HH__