AbstractReplacementPolicy.hh revision 10980
18512Sgeoffrey.blake@arm.com/*
29545Sandreas.hansson@arm.com * Copyright (c) 2007 Mark D. Hill and David A. Wood
38512Sgeoffrey.blake@arm.com * All rights reserved.
48512Sgeoffrey.blake@arm.com *
58512Sgeoffrey.blake@arm.com * Redistribution and use in source and binary forms, with or without
68512Sgeoffrey.blake@arm.com * modification, are permitted provided that the following conditions are
78512Sgeoffrey.blake@arm.com * met: redistributions of source code must retain the above copyright
88512Sgeoffrey.blake@arm.com * notice, this list of conditions and the following disclaimer;
98512Sgeoffrey.blake@arm.com * redistributions in binary form must reproduce the above copyright
108512Sgeoffrey.blake@arm.com * notice, this list of conditions and the following disclaimer in the
118512Sgeoffrey.blake@arm.com * documentation and/or other materials provided with the distribution;
128512Sgeoffrey.blake@arm.com * neither the name of the copyright holders nor the names of its
138512Sgeoffrey.blake@arm.com * contributors may be used to endorse or promote products derived from
148512Sgeoffrey.blake@arm.com * this software without specific prior written permission.
158512Sgeoffrey.blake@arm.com *
168512Sgeoffrey.blake@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
178512Sgeoffrey.blake@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
188512Sgeoffrey.blake@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
198512Sgeoffrey.blake@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
208512Sgeoffrey.blake@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
218512Sgeoffrey.blake@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
228512Sgeoffrey.blake@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
238512Sgeoffrey.blake@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
248512Sgeoffrey.blake@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
258512Sgeoffrey.blake@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
268512Sgeoffrey.blake@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
278512Sgeoffrey.blake@arm.com */
288512Sgeoffrey.blake@arm.com
298512Sgeoffrey.blake@arm.com#ifndef __MEM_RUBY_STRUCTURES_ABSTRACTREPLACEMENTPOLICY_HH__
308512Sgeoffrey.blake@arm.com#define __MEM_RUBY_STRUCTURES_ABSTRACTREPLACEMENTPOLICY_HH__
318512Sgeoffrey.blake@arm.com
328512Sgeoffrey.blake@arm.com#include "base/types.hh"
338512Sgeoffrey.blake@arm.com#include "mem/ruby/common/TypeDefines.hh"
348512Sgeoffrey.blake@arm.com#include "params/ReplacementPolicy.hh"
358512Sgeoffrey.blake@arm.com#include "sim/sim_object.hh"
368512Sgeoffrey.blake@arm.com
378512Sgeoffrey.blake@arm.comclass CacheMemory;
388512Sgeoffrey.blake@arm.com
398512Sgeoffrey.blake@arm.comclass AbstractReplacementPolicy : public SimObject
408512Sgeoffrey.blake@arm.com{
4111793Sbrandon.potter@amd.com  public:
4211793Sbrandon.potter@amd.com    typedef ReplacementPolicyParams Params;
438512Sgeoffrey.blake@arm.com    AbstractReplacementPolicy(const Params * p);
448512Sgeoffrey.blake@arm.com    virtual ~AbstractReplacementPolicy();
458512Sgeoffrey.blake@arm.com
468512Sgeoffrey.blake@arm.com    /* touch a block. a.k.a. update timestamp */
479525SAndreas.Sandberg@ARM.com    virtual void touch(int64 set, int64 way, Tick time) = 0;
488512Sgeoffrey.blake@arm.com
498512Sgeoffrey.blake@arm.com    /* returns the way to replace */
508512Sgeoffrey.blake@arm.com    virtual int64 getVictim(int64 set) const = 0;
518512Sgeoffrey.blake@arm.com
529808Sstever@gmail.com    /* get the time of the last access */
538512Sgeoffrey.blake@arm.com    Tick getLastAccess(int64 set, int64 way);
548512Sgeoffrey.blake@arm.com
558512Sgeoffrey.blake@arm.com    virtual bool useOccupancy() const { return false; }
568512Sgeoffrey.blake@arm.com
578512Sgeoffrey.blake@arm.com    void setCache(CacheMemory * pCache) {m_cache = pCache;}
588512Sgeoffrey.blake@arm.com    CacheMemory * m_cache;
598512Sgeoffrey.blake@arm.com
608512Sgeoffrey.blake@arm.com  protected:
618512Sgeoffrey.blake@arm.com    unsigned m_num_sets;       /** total number of sets */
628512Sgeoffrey.blake@arm.com    unsigned m_assoc;          /** set associativity */
638512Sgeoffrey.blake@arm.com    Tick **m_last_ref_ptr;         /** timestamp of last reference */
648512Sgeoffrey.blake@arm.com};
658512Sgeoffrey.blake@arm.com
668512Sgeoffrey.blake@arm.com#endif // __MEM_RUBY_STRUCTURES_ABSTRACTREPLACEMENTPOLICY_HH__
678512Sgeoffrey.blake@arm.com