src/mem/cache/tags/lru.cc
// create and initialize a LRU/MRU cache structure
create and initialize a LRU/MRU cache structure
create and initialize a LRU / MRU cache structure
LRU::LRU(unsigned _numSets, unsigned _blkSize, unsigned _assoc,
         unsigned _hit_latency)
    : numSets(_numSets), blkSize(_blkSize), assoc(_assoc),
      hitLatency(_hit_latency)
{
    if (blkSize < 4 || !isPowerOf2(blkSize)) {
        fatal("Block size must be at least 4 and a power of 2");
    }
    if (numSets <= 0 || !isPowerOf2(numSets)) {
        fatal("# of sets must be non-zero and a power of 2");
    }
    if (assoc <= 0) {
        fatal("associativity must be greater than zero");
    }
    if (hitLatency <= 0) {
        fatal("access latency must be greater than zero");
    }
    blkMask = blkSize - 1;
    setShift = floorLog2(blkSize);
    setMask = numSets - 1;
    tagShift = setShift + floorLog2(numSets);
    warmedUp = false;
    warmupBound = numSets * assoc;
	missCounter = new unsigned[numSets];
	for (unsigned i = 0; i < numSets; i++)
		missCounter[i] = 0;
    init_sets();
}
LRU :: LRU ( unsigned _numSets , unsigned _blkSize , unsigned _assoc , unsigned _hit_latency ) : numSets ( _numSets ) , blkSize ( _blkSize ) , assoc ( _assoc ) , hitLatency ( _hit_latency ) { if ( blkSize < 4 || ! isPowerOf2 ( blkSize ) ) { fatal ( " " ) ; } if ( numSets <= 0 || ! isPowerOf2 ( numSets ) ) { fatal ( " " ) ; } if ( assoc <= 0 ) { fatal ( " " ) ; } if ( hitLatency <= 0 ) { fatal ( " " ) ; } blkMask = blkSize - 1 ; setShift = floorLog2 ( blkSize ) ; setMask = numSets - 1 ; tagShift = setShift + floorLog2 ( numSets ) ; warmedUp = false ; warmupBound = numSets * assoc ; missCounter = new unsigned [ numSets ] ; for ( unsigned i = 0 ; i < numSets ; i ++ ) missCounter [ i ] = 0 ; init_sets ( ) ; }
create and initialize a LRU/MRU cache structure
create and initialize a LRU / MRU cache structure
// Check parameters /** @todo Make warmup percentage a parameter. */ /** initialize miss counter */