Otawa  0.10
AbstractCacheDriver.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * Copyright (c) 2007, IRIT-UPS <casse@irit.fr>.
4  *
5  * AbstractCacheDriver class interface
6  */
7 #ifndef OTAWA_SIM_ABSTRACT_DRIVER_H
8 #define OTAWA_SIM_ABSTRACT_DRIVER_H
9 
10 #include <otawa/sim/CacheDriver.h>
11 
12 namespace otawa {
13 
14 // External classes
15 namespace hard {
16  class Cache;
17 } // hard
18 
19 namespace sim {
20 
21 // AbstractCacheDriver class
23 public:
24  typedef unsigned long tag_t;
26  virtual ~AbstractCacheDriver(void);
27  virtual result_t access(address_t address, size_t size, action_t action);
28  inline const hard::Cache *cache(void) const { return _cache; }
29  static CacheDriver *lookup(const hard::Cache *cache);
30 
31 protected:
32  virtual void touch(int index, int num, tag_t *line) = 0;
33  virtual void replace(tag_t tag, int num, tag_t *line) = 0;
34 
35 private:
38 };
39 
40 // LRUCacheDriver class
42 public:
44 
45 protected:
46  virtual void touch(int index, int num, tag_t *line);
47  virtual void replace(tag_t tag, int num, tag_t *line);
48 };
49 
50 // DirectMappedCacheDriver class
52 public:
54 
55 protected:
56  virtual void touch(int index, int num, tag_t *line);
57  virtual void replace(tag_t tag, int num, tag_t *line);
58 };
59 
60 // FIFOCacheDriver class
62 public:
64  ~FIFOCacheDriver(void);
65 
66 protected:
67  virtual void touch(int index, int num, tag_t *line);
68  virtual void replace(tag_t tag, int num, tag_t *line);
69 
70 private:
71  int *counters;
72 };
73 
74 } } // otawa::sim
75 
76 #endif // OTAWA_SIM_ABSTRACT_DRIVER_H
result_t
This enumeration allows to know the result of a cache access.
Definition: CacheDriver.h:22
static CacheDriver * lookup(const hard::Cache *cache)
This method retrieve the cache driver matching the given cache description.
Definition: sim_AbstractCacheDriver.cpp:30
This class provide a cache driver implementing direct mapped cache driver.
Definition: AbstractCacheDriver.h:51
const hard::Cache * _cache
Definition: AbstractCacheDriver.h:36
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).
virtual void replace(tag_t tag, int num, tag_t *line)
This function is called each time a replacement in a set is required.
Definition: sim_AbstractCacheDriver.cpp:155
virtual result_t access(address_t address, size_t size, action_t action)
This function is called each time the cache is accessed.
Definition: sim_AbstractCacheDriver.cpp:87
virtual void replace(tag_t tag, int num, tag_t *line)
This function is called each time a replacement in a set is required.
Definition: sim_AbstractCacheDriver.cpp:125
virtual void touch(int index, int num, tag_t *line)
This function is called each time a cache block in a set is accessed (read / write).
Definition: sim_AbstractCacheDriver.cpp:179
tag_t * lines
Definition: AbstractCacheDriver.h:37
unsigned long tag_t
Definition: AbstractCacheDriver.h:24
~FIFOCacheDriver(void)
Definition: sim_AbstractCacheDriver.cpp:204
virtual void touch(int index, int num, tag_t *line)
This function is called each time a cache block in a set is accessed (read / write).
Definition: sim_AbstractCacheDriver.cpp:149
uint32 size
elm::io::IntFormat address(Address addr)
Build a format to display addresses.
Definition: base.cpp:213
This class provide a cache driver implementing a FIFO policy.
Definition: AbstractCacheDriver.h:61
virtual void touch(int index, int num, tag_t *line)
This function is called each time a cache block in a set is accessed (read / write).
Definition: sim_AbstractCacheDriver.cpp:115
virtual void replace(tag_t tag, int num, tag_t *line)
This function is called each time a replacement in a set is required.
Definition: sim_AbstractCacheDriver.cpp:185
FIFOCacheDriver(const hard::Cache *cache)
Build an associative cache driver with FIFO replacement policy.
Definition: sim_AbstractCacheDriver.cpp:195
This class contains the configuration of a level of cache of processor.
Definition: Cache.h:34
This class provides a simple interface to drive the cache management unit of a simulator.
Definition: CacheDriver.h:20
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.
The representation of an address in OTAWA.
Definition: base.h:54
virtual ~AbstractCacheDriver(void)
Definition: sim_AbstractCacheDriver.cpp:80
const hard::Cache * cache(void) const
Definition: AbstractCacheDriver.h:28
This is an abstract implementation of the cache driver allowing to customize only the cache replaceme...
Definition: AbstractCacheDriver.h:22
AbstractCacheDriver(const hard::Cache *cache)
Build a cache driver with the given cache.
Definition: sim_AbstractCacheDriver.cpp:71
int * counters
Definition: AbstractCacheDriver.h:71
DirectMappedCacheDriver(const hard::Cache *cache)
Build a direct-mapped cache driver.
Definition: sim_AbstractCacheDriver.cpp:165
action_t
This enumeration identifies the kind of cache access.
Definition: CacheDriver.h:27
LRUCacheDriver(const hard::Cache *cache)
Build a LRU cache driver.
Definition: sim_AbstractCacheDriver.cpp:136
This class provide a cache driver implementing the LRU replacement policy.
Definition: AbstractCacheDriver.h:41