summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags/base.hh
diff options
context:
space:
mode:
authorDavid Guillen <david.guillen@arm.com>2015-05-05 03:22:21 -0400
committerDavid Guillen <david.guillen@arm.com>2015-05-05 03:22:21 -0400
commit5287945a8bb98476a9326c5d9c51491cdc7212f2 (patch)
treec2263df9baa298e151c2fc68c22b9e3439f07edf /src/mem/cache/tags/base.hh
parentd0d933facc9085727c12f53de76a2cb879ded4c8 (diff)
downloadgem5-5287945a8bb98476a9326c5d9c51491cdc7212f2.tar.xz
mem: Remove templates in cache model
This patch changes the cache implementation to rely on virtual methods rather than using the replacement policy as a template argument. There is no impact on the simulation performance, and overall the changes make it easier to modify (and subclass) the cache and/or replacement policy.
Diffstat (limited to 'src/mem/cache/tags/base.hh')
-rw-r--r--src/mem/cache/tags/base.hh33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh
index 03b6cfed8..e4c0f68d8 100644
--- a/src/mem/cache/tags/base.hh
+++ b/src/mem/cache/tags/base.hh
@@ -53,6 +53,7 @@
#include "base/callback.hh"
#include "base/statistics.hh"
+#include "mem/cache/blk.hh"
#include "params/BaseTags.hh"
#include "sim/clocked_object.hh"
@@ -179,6 +180,38 @@ class BaseTags : public ClockedObject
* Print all tags used
*/
virtual std::string print() const = 0;
+
+ /**
+ * Find a block using the memory address
+ */
+ virtual CacheBlk * findBlock(Addr addr, bool is_secure) const = 0;
+
+ /**
+ * Calculate the block offset of an address.
+ * @param addr the address to get the offset of.
+ * @return the block offset.
+ */
+ int extractBlkOffset(Addr addr) const
+ {
+ return (addr & (Addr)(blkSize-1));
+ }
+
+ virtual void invalidate(CacheBlk *blk) = 0;
+
+ virtual CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat,
+ int context_src) = 0;
+
+ virtual Addr extractTag(Addr addr) const = 0;
+
+ virtual void insertBlock(PacketPtr pkt, CacheBlk *blk) = 0;
+
+ virtual Addr regenerateBlkAddr(Addr tag, unsigned set) const = 0;
+
+ virtual CacheBlk* findVictim(Addr addr) = 0;
+
+ virtual int extractSet(Addr addr) const = 0;
+
+ virtual void forEachBlk(CacheBlkVisitor &visitor) = 0;
};
class BaseTagsCallback : public Callback