1/* 2 * Copyright (c) 2012-2014,2017 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 36 unchanged lines hidden (view full) --- 45 * Declaration of a base set associative tag store. 46 */ 47 48#ifndef __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__ 49#define __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__ 50 51#include <cassert> 52#include <cstring> |
53#include <vector> 54 |
55#include "debug/CacheRepl.hh" |
56#include "mem/cache/base.hh" 57#include "mem/cache/blk.hh" |
58#include "mem/cache/replacement_policies/base.hh" |
59#include "mem/cache/tags/base.hh" 60#include "mem/cache/tags/cacheset.hh" 61#include "mem/packet.hh" 62#include "params/BaseSetAssoc.hh" 63 64/** 65 * A BaseSetAssoc cache tag store. 66 * @sa \ref gem5MemorySystem "gem5 Memory System" --- 34 unchanged lines hidden (view full) --- 101 int tagShift; 102 /** Mask out all bits that aren't part of the set index. */ 103 unsigned setMask; 104 105 /** Replacement policy */ 106 BaseReplacementPolicy *replacementPolicy; 107 108 public: |
109 /** Convenience typedef. */ 110 typedef BaseSetAssocParams Params; 111 112 /** 113 * Construct and initialize this tag store. 114 */ 115 BaseSetAssoc(const Params *p); 116 117 /** 118 * Destructor 119 */ 120 virtual ~BaseSetAssoc() {}; 121 122 /** |
123 * This function updates the tags when a block is invalidated but does 124 * not invalidate the block itself. It also updates the replacement data. 125 * 126 * @param blk The block to invalidate. 127 */ 128 void invalidate(CacheBlk *blk) override; 129 130 /** |
131 * Find the cache block given set and way 132 * @param set The set of the block. 133 * @param way The way of the block. 134 * @return The cache block. 135 */ 136 CacheBlk *findBlockBySetAndWay(int set, int way) const override; 137 138 /** --- 29 unchanged lines hidden (view full) --- 168 // apply the accessLatency on top of block->whenReady. 169 if (blk->whenReady > curTick() && 170 cache->ticksToCycles(blk->whenReady - curTick()) > 171 accessLatency) { 172 lat = cache->ticksToCycles(blk->whenReady - curTick()) + 173 accessLatency; 174 } 175 |
176 // Update number of references to accessed block 177 blk->refCount++; 178 |
179 // Update replacement data of accessed block |
180 replacementPolicy->touch(blk->replacementData); |
181 } else { 182 // If a cache miss 183 lat = lookupLatency; 184 } 185 186 return blk; 187 } 188 --- 10 unchanged lines hidden (view full) --- 199 /** 200 * Find replacement victim based on address. 201 * 202 * @param addr Address to find a victim for. 203 * @return Cache block to be replaced. 204 */ 205 CacheBlk* findVictim(Addr addr) override 206 { |
207 // Get possible locations for the victim block 208 std::vector<CacheBlk*> locations = getPossibleLocations(addr); 209 |
210 // Choose replacement victim from replacement candidates |
211 CacheBlk* victim = static_cast<CacheBlk*>(replacementPolicy->getVictim( 212 std::vector<ReplaceableEntry*>( 213 locations.begin(), locations.end()))); 214 215 DPRINTF(CacheRepl, "set %x, way %x: selecting blk for replacement\n", 216 victim->set, victim->way); 217 218 return victim; |
219 } 220 221 /** 222 * Find all possible block locations for insertion and replacement of 223 * an address. Should be called immediately before ReplacementPolicy's 224 * findVictim() not to break cache resizing. 225 * Returns blocks in all ways belonging to the set of the address. 226 * --- 12 unchanged lines hidden (view full) --- 239 * @param blk The block to update. 240 */ 241 void insertBlock(PacketPtr pkt, CacheBlk *blk) override 242 { 243 // Insert block 244 BaseTags::insertBlock(pkt, blk); 245 246 // Update replacement policy |
247 replacementPolicy->reset(blk->replacementData); |
248 } 249 250 /** 251 * Limit the allocation for the cache ways. 252 * @param ways The maximum number of ways available for replacement. 253 */ 254 virtual void setWayAllocationMax(int ways) override 255 { --- 80 unchanged lines hidden --- |