CohereSim: A Bus-based Cache Simulator  v3.3
A tool for education in computing - learn about coherence protocols, replacement policies, and SMP vs DSM
Public Member Functions | Protected Attributes
ReplacementPolicy Class Reference

The base class for replacement policies. More...

#include <replacement_policy.h>

Inheritance diagram for ReplacementPolicy:
Inheritance graph
[legend]
Collaboration diagram for ReplacementPolicy:
Collaboration graph
[legend]

Public Member Functions

 ReplacementPolicy (CacheABC &cache, uint32_t num_sets, uint32_t assoc)
 Construct a new replacement policy. More...
 
virtual uint32_t getVictim (uint32_t set_idx)
 Determine which line of a range of lines to replace. More...
 
virtual void touch (uint32_t set_idx, uint32_t way_idx)
 Notify the replacement policy that a line was just accessed. More...
 
virtual void printState (uint32_t set_idx)
 Print out the replacer's internal state. More...
 

Protected Attributes

CacheABCcache
 The parent cache.
 
uint32_t num_sets
 The number of sets in the cache.
 
uint32_t assoc
 The associativity of the cache.
 

Detailed Description

The base class for replacement policies.

Constructor & Destructor Documentation

◆ ReplacementPolicy()

ReplacementPolicy::ReplacementPolicy ( CacheABC cache,
uint32_t  num_sets,
uint32_t  assoc 
)
inline

Construct a new replacement policy.

Parameters
cacheThe parent cache
num_setsThe number of sets in the cache
assocThe associativity of the chace

Member Function Documentation

◆ getVictim()

virtual uint32_t ReplacementPolicy::getVictim ( uint32_t  set_idx)
inlinevirtual

Determine which line of a range of lines to replace.

Parameters
set_idxThe index of the set to choose from
Returns
The chosen line's way (0 to assoc-1)

Reimplemented in RR, LRU, and FIFO.

◆ printState()

virtual void ReplacementPolicy::printState ( uint32_t  set_idx)
inlinevirtual

Print out the replacer's internal state.

Parameters
set_idxThe index of the set

Reimplemented in LRU, and FIFO.

◆ touch()

virtual void ReplacementPolicy::touch ( uint32_t  set_idx,
uint32_t  way_idx 
)
inlinevirtual

Notify the replacement policy that a line was just accessed.

Parameters
set_idxThe index of the set containing the line
way_idxThe index of the way containing the line (0 to assoc-1)

Reimplemented in LRU.


The documentation for this class was generated from the following file: