17008SN/A/* 27008SN/A * Copyright (c) 2007 Mark D. Hill and David A. Wood 37008SN/A * All rights reserved. 47008SN/A * 57008SN/A * Redistribution and use in source and binary forms, with or without 67008SN/A * modification, are permitted provided that the following conditions are 77008SN/A * met: redistributions of source code must retain the above copyright 87008SN/A * notice, this list of conditions and the following disclaimer; 97008SN/A * redistributions in binary form must reproduce the above copyright 107008SN/A * notice, this list of conditions and the following disclaimer in the 117008SN/A * documentation and/or other materials provided with the distribution; 127008SN/A * neither the name of the copyright holders nor the names of its 137008SN/A * contributors may be used to endorse or promote products derived from 147008SN/A * this software without specific prior written permission. 157008SN/A * 167008SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 177008SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 187008SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 197008SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 207008SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 217008SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 227008SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 237008SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 247008SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 257008SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 267008SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 277008SN/A */ 286145SN/A 2910441Snilay@cs.wisc.edu#ifndef __MEM_RUBY_STRUCTURES_ABSTRACTREPLACEMENTPOLICY_HH__ 3010441Snilay@cs.wisc.edu#define __MEM_RUBY_STRUCTURES_ABSTRACTREPLACEMENTPOLICY_HH__ 316145SN/A 329505SN/A#include "base/types.hh" 3310970Sdavid.hashe@amd.com#include "mem/ruby/common/TypeDefines.hh" 3410970Sdavid.hashe@amd.com#include "params/ReplacementPolicy.hh" 3510970Sdavid.hashe@amd.com#include "sim/sim_object.hh" 366145SN/A 3710980Sdavid.hashe@amd.comclass CacheMemory; 3810980Sdavid.hashe@amd.com 3910970Sdavid.hashe@amd.comclass AbstractReplacementPolicy : public SimObject 407039SN/A{ 417039SN/A public: 4210970Sdavid.hashe@amd.com typedef ReplacementPolicyParams Params; 4310970Sdavid.hashe@amd.com AbstractReplacementPolicy(const Params * p); 447039SN/A virtual ~AbstractReplacementPolicy(); 456145SN/A 467039SN/A /* touch a block. a.k.a. update timestamp */ 4711061Snilay@cs.wisc.edu virtual void touch(int64_t set, int64_t way, Tick time) = 0; 486145SN/A 497039SN/A /* returns the way to replace */ 5011061Snilay@cs.wisc.edu virtual int64_t getVictim(int64_t set) const = 0; 516145SN/A 527039SN/A /* get the time of the last access */ 5311061Snilay@cs.wisc.edu Tick getLastAccess(int64_t set, int64_t way); 546145SN/A 5510970Sdavid.hashe@amd.com virtual bool useOccupancy() const { return false; } 5610970Sdavid.hashe@amd.com 5710980Sdavid.hashe@amd.com void setCache(CacheMemory * pCache) {m_cache = pCache;} 5810980Sdavid.hashe@amd.com CacheMemory * m_cache; 5910980Sdavid.hashe@amd.com 607039SN/A protected: 617039SN/A unsigned m_num_sets; /** total number of sets */ 627039SN/A unsigned m_assoc; /** set associativity */ 639505SN/A Tick **m_last_ref_ptr; /** timestamp of last reference */ 646145SN/A}; 656145SN/A 6610441Snilay@cs.wisc.edu#endif // __MEM_RUBY_STRUCTURES_ABSTRACTREPLACEMENTPOLICY_HH__ 67