From 7704113d94f2e574afeb079e0cc5b98fc6bed33b Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Mon, 16 Apr 2018 15:36:33 +0200 Subject: mem-cache: Create an address aware TempCacheBlk tempBlock has its member variables manually set in order to allow it to be used in the block address regeneration function. This is not necessary, and ti can be simply given the address, so it does not need to be aware of set and tag. This will simplify implementation of sector and skewed caches. Change-Id: Iaffb10c323509722cd5589fe1030b818d43336d6 Reviewed-on: https://gem5-review.googlesource.com/9961 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- src/mem/cache/blk.hh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'src/mem/cache/blk.hh') diff --git a/src/mem/cache/blk.hh b/src/mem/cache/blk.hh index c94c3ba7d..c4ec12ff3 100644 --- a/src/mem/cache/blk.hh +++ b/src/mem/cache/blk.hh @@ -166,7 +166,6 @@ class CacheBlk : public ReplaceableEntry std::list lockList; public: - CacheBlk() { invalidate(); @@ -261,7 +260,7 @@ class CacheBlk : public ReplaceableEntry * @param src_master_ID The source requestor ID. * @param task_ID The new task ID. */ - void insert(const Addr tag, const State is_secure, const int src_master_ID, + void insert(const Addr tag, const bool is_secure, const int src_master_ID, const uint32_t task_ID); /** @@ -393,6 +392,66 @@ class CacheBlk : public ReplaceableEntry } }; +/** + * Special instance of CacheBlk for use with tempBlk that deals with its + * block address regeneration. + * @sa Cache + */ +class TempCacheBlk final : public CacheBlk +{ + private: + /** + * Copy of the block's address, used to regenerate tempBlock's address. + */ + Addr _addr; + + public: + TempCacheBlk() : CacheBlk() {} + TempCacheBlk(const TempCacheBlk&) = delete; + TempCacheBlk& operator=(const TempCacheBlk&) = delete; + ~TempCacheBlk() {}; + + /** + * Invalidate the block and clear all state. + */ + void invalidate() override { + CacheBlk::invalidate(); + + _addr = MaxAddr; + } + + /** + * Set member variables when a block insertion occurs. A TempCacheBlk does + * not have all the information required to regenerate the block's address, + * so it is provided the address itself for easy regeneration. + * + * @param addr Block address. + * @param is_secure Whether the block is in secure space or not. + */ + void insert(const Addr addr, const bool is_secure) + { + // Set block address + _addr = addr; + + // Set secure state + if (is_secure) { + status = BlkSecure; + } else { + status = 0; + } + } + + /** + * Get block's address. + * + * @return addr Address value. + */ + Addr getAddr() const + { + return _addr; + } +}; + /** * Simple class to provide virtual print() method on cache blocks * without allocating a vtable pointer for every single cache block. -- cgit v1.2.3