gem5 v24.1.0.1
Loading...
Searching...
No Matches
cache_entry.hh
Go to the documentation of this file.
1
42#ifndef __BASE_CACHE_CACHE_ENTRY_HH__
43#define __BASE_CACHE_CACHE_ENTRY_HH__
44
45#include <cassert>
46
47#include "base/cprintf.hh"
48#include "base/types.hh"
51
52namespace gem5
53{
54
60{
61 public:
63 using KeyType = Addr;
64 using TagExtractor = std::function<Addr(Addr)>;
65
69 ~CacheEntry() = default;
70
76 virtual bool isValid() const { return valid; }
77
83 virtual Addr getTag() const { return tag; }
84
91 virtual bool
92 match(const Addr addr) const
93 {
94 return isValid() && (getTag() == extractTag(addr));
95 }
96
103 virtual void
105 {
106 setValid();
108 }
109
111 virtual void
113 {
114 valid = false;
116 }
117
118 std::string
119 print() const override
120 {
121 return csprintf("tag: %#x valid: %d | %s", getTag(),
123 }
124
125 protected:
131 virtual void setTag(Addr _tag) { tag = _tag; }
132
134 virtual void
136 {
137 assert(!isValid());
138 valid = true;
139 }
140
141 private:
144
150 bool valid;
151
154};
155
156} // namespace gem5
157
158#endif //__CACHE_ENTRY_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
A CacheEntry is an entry containing a tag.
virtual bool match(const Addr addr) const
Checks if the given tag information corresponds to this entry's.
CacheEntry(TagExtractor ext)
std::function< Addr(Addr)> TagExtractor
virtual void insert(const Addr addr)
Insert the block by assigning it a tag and marking it valid.
virtual void invalidate()
Invalidate the block.
virtual Addr getTag() const
Get tag associated to this block.
TagExtractor extractTag
Callback used to extract the tag from the entry.
virtual void setValid()
Set valid bit.
~CacheEntry()=default
std::string print() const override
Prints relevant information about this entry.
bool valid
Valid bit.
Addr tag
The entry's tag.
virtual bool isValid() const
Checks if the entry is valid.
virtual void setTag(Addr _tag)
Set tag associated to this block.
A common base class for indexing table locations.
Definition base.hh:73
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
virtual std::string print() const
Prints relevant information about this entry.
Declaration of a common framework for indexing policies.
Bitfield< 12 > ext
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
IndexingPolicyTemplate< AddrTypes > BaseIndexingPolicy
Definition base.hh:215
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161
const Addr MaxAddr
Definition types.hh:171

Generated on Mon Jan 13 2025 04:28:29 for gem5 by doxygen 1.9.8