diff --git a/src/mem/cache/tags/indexing_policies/base.hh b/src/mem/cache/tags/indexing_policies/base.hh index 32465df5dc..7bd3496b2c 100644 --- a/src/mem/cache/tags/indexing_policies/base.hh +++ b/src/mem/cache/tags/indexing_policies/base.hh @@ -109,14 +109,16 @@ class IndexingPolicyTemplate : public SimObject /** * Construct and initialize this policy. */ - IndexingPolicyTemplate(const Params &p) + IndexingPolicyTemplate(const Params &p, + uint32_t num_entries, + int set_shift) : SimObject(p), assoc(p.assoc), - numSets(p.size / (p.entry_size * assoc)), - setShift(floorLog2(p.entry_size)), setMask(numSets - 1), sets(numSets), + numSets(num_entries / assoc), + setShift(set_shift), setMask(numSets - 1), sets(numSets), tagShift(setShift + floorLog2(numSets)) { - fatal_if(!isPowerOf2(numSets), "# of sets must be non-zero and a power " \ - "of 2"); + fatal_if(!isPowerOf2(numSets), + "# of sets must be non-zero and a power of 2"); fatal_if(assoc <= 0, "associativity must be greater than zero"); // Make space for the entries diff --git a/src/mem/cache/tags/indexing_policies/set_associative.cc b/src/mem/cache/tags/indexing_policies/set_associative.cc index 36011f10ef..fd250a0ac1 100644 --- a/src/mem/cache/tags/indexing_policies/set_associative.cc +++ b/src/mem/cache/tags/indexing_policies/set_associative.cc @@ -52,7 +52,7 @@ namespace gem5 { SetAssociative::SetAssociative(const Params &p) - : BaseIndexingPolicy(p) + : BaseIndexingPolicy(p, p.size / p.entry_size, floorLog2(p.entry_size)) { } diff --git a/src/mem/cache/tags/indexing_policies/skewed_associative.cc b/src/mem/cache/tags/indexing_policies/skewed_associative.cc index 76e7acabca..bef191adf0 100644 --- a/src/mem/cache/tags/indexing_policies/skewed_associative.cc +++ b/src/mem/cache/tags/indexing_policies/skewed_associative.cc @@ -42,7 +42,8 @@ namespace gem5 { SkewedAssociative::SkewedAssociative(const Params &p) - : BaseIndexingPolicy(p), msbShift(floorLog2(numSets) - 1) + : BaseIndexingPolicy(p, p.size / p.entry_size, floorLog2(p.entry_size)), + msbShift(floorLog2(numSets) - 1) { if (assoc > NUM_SKEWING_FUNCTIONS) { warn_once("Associativity higher than number of skewing functions. " \ diff --git a/src/mem/cache/tags/tagged_entry.hh b/src/mem/cache/tags/tagged_entry.hh index 1a1d773371..41a780f279 100644 --- a/src/mem/cache/tags/tagged_entry.hh +++ b/src/mem/cache/tags/tagged_entry.hh @@ -85,7 +85,7 @@ class TaggedSetAssociative : public TaggedIndexingPolicy public: PARAMS(TaggedSetAssociative); TaggedSetAssociative(const Params &p) - : TaggedIndexingPolicy(p) + : TaggedIndexingPolicy(p, p.size / p.entry_size, floorLog2(p.entry_size)) {} std::vector