Otawa  0.10
otawa::sim::AbstractCacheDriver Class Referenceabstract

This is an abstract implementation of the cache driver allowing to customize only the cache replacement policy. More...

#include <otawa/sim/AbstractCacheDriver.h>

Inheritance diagram for otawa::sim::AbstractCacheDriver:
otawa::sim::CacheDriver otawa::sim::DirectMappedCacheDriver otawa::sim::FIFOCacheDriver otawa::sim::LRUCacheDriver

Public Types

typedef unsigned long tag_t
 
enum  result_t { MISS = 0, HIT = 1 }
 This enumeration allows to know the result of a cache access. More...
 
enum  action_t { READ, WRITE }
 This enumeration identifies the kind of cache access. More...
 

Public Member Functions

 AbstractCacheDriver (const hard::Cache *cache)
 Build a cache driver with the given cache. More...
 
virtual ~AbstractCacheDriver (void)
 
virtual result_t access (address_t address, size_t size, action_t action)
 This function is called each time the cache is accessed. More...
 
const hard::Cachecache (void) const
 

Static Public Member Functions

static CacheDriverlookup (const hard::Cache *cache)
 This method retrieve the cache driver matching the given cache description. More...
 

Static Public Attributes

static CacheDriverALWAYS_HIT = HIT_DRIVER
 This cache driver specialization generates a hit each time it is accessed. More...
 
static CacheDriverALWAYS_MISS = MISS_DRIVER
 This cache driver specialization generates a miss each time it is accessed. More...
 

Protected Member Functions

virtual void touch (int index, int num, tag_t *line)=0
 This function is called each time a cache block in a set is accessed (read / write). More...
 
virtual void replace (tag_t tag, int num, tag_t *line)=0
 This function is called each time a replacement in a set is required. More...
 

Private Attributes

const hard::Cache_cache
 
tag_tlines
 

Detailed Description

This is an abstract implementation of the cache driver allowing to customize only the cache replacement policy.

Implementations of this class includes:

Member Typedef Documentation

Member Enumeration Documentation

This enumeration identifies the kind of cache access.

Enumerator
READ 

A read is performed on the cache.

WRITE 

A write is performed on the cache.

This enumeration allows to know the result of a cache access.

Enumerator
MISS 

The result of a cache access produces a miss.

HIT 

The result of a cache access produces a hit.

Constructor & Destructor Documentation

otawa::sim::AbstractCacheDriver::AbstractCacheDriver ( const hard::Cache cache)

Build a cache driver with the given cache.

Parameters
cacheUsed cache.

References lines.

otawa::sim::AbstractCacheDriver::~AbstractCacheDriver ( void  )
virtual

References lines.

Member Function Documentation

CacheDriver::result_t otawa::sim::AbstractCacheDriver::access ( address_t  address,
size_t  size,
action_t  action 
)
virtual

This function is called each time the cache is accessed.

It must be overload to specialize the cache behavior.

Parameters
addressAddress of the accessed data.
sizeSize of the accessed data.
actionAction performed.
Returns
HIT or MISS according presence of the block of data in the cache.

Implements otawa::sim::CacheDriver.

References _cache, otawa::sim::CacheDriver::HIT, otawa::hard::Cache::line(), lines, otawa::sim::CacheDriver::MISS, replace(), otawa::hard::Cache::tag(), touch(), and otawa::hard::Cache::wayCount().

const hard::Cache* otawa::sim::AbstractCacheDriver::cache ( void  ) const
inline
CacheDriver * otawa::sim::AbstractCacheDriver::lookup ( const hard::Cache cache)
static

This method retrieve the cache driver matching the given cache description.

Parameters
cacheCache to look a driver for.
Returns
Matching cache driver or null.

References otawa::hard::Cache::FIFO, otawa::hard::Cache::LRU, otawa::hard::Cache::replacementPolicy(), and otawa::hard::Cache::wayCount().

void otawa::sim::AbstractCacheDriver::replace ( tag_t  tag,
int  num,
tag_t line 
)
protectedpure virtual

This function is called each time a replacement in a set is required.

This method implementer must wipe out one of the block and replaced it by the given tag.

Parameters
tagNew tag to store in the set.
numNumber of the affected set/line.
lineArray base containing tags of the line.

Implemented in otawa::sim::FIFOCacheDriver, otawa::sim::DirectMappedCacheDriver, and otawa::sim::LRUCacheDriver.

Referenced by access().

void otawa::sim::AbstractCacheDriver::touch ( int  index,
int  num,
tag_t line 
)
protectedpure virtual

This function is called each time a cache block in a set is accessed (read / write).

The implementer may use this call to update its tag order in the set.

Parameters
indexIndex of the accessed tag in the tag array.
numNumber of the set/line accessed.
lineBase of the array containing tags of the current set/line.

Implemented in otawa::sim::FIFOCacheDriver, otawa::sim::DirectMappedCacheDriver, and otawa::sim::LRUCacheDriver.

Referenced by access().

Member Data Documentation

const hard::Cache* otawa::sim::AbstractCacheDriver::_cache
private

Referenced by access(), and cache().

CacheDriver & otawa::sim::CacheDriver::ALWAYS_HIT = HIT_DRIVER
staticinherited

This cache driver specialization generates a hit each time it is accessed.

CacheDriver & otawa::sim::CacheDriver::ALWAYS_MISS = MISS_DRIVER
staticinherited

This cache driver specialization generates a miss each time it is accessed.

tag_t* otawa::sim::AbstractCacheDriver::lines
private

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