gem5 v24.1.0.1
Loading...
Searching...
No Matches
tagged_entry.hh
Go to the documentation of this file.
1
41#ifndef __CACHE_TAGGED_ENTRY_HH__
42#define __CACHE_TAGGED_ENTRY_HH__
43
44#include <cassert>
45
46#include "base/cprintf.hh"
47#include "base/types.hh"
50#include "params/TaggedIndexingPolicy.hh"
51#include "params/TaggedSetAssociative.hh"
52
53namespace gem5
54{
55
57{
58 public:
59 struct KeyType
60 {
62 bool secure;
63 };
64 using Params = TaggedIndexingPolicyParams;
65};
66
69
77{
78 protected:
79 virtual uint32_t
80 extractSet(const KeyType &key) const
81 {
82 return (key.address >> setShift) & setMask;
83 }
84
85 public:
88 : TaggedIndexingPolicy(p, p.size / p.entry_size, floorLog2(p.entry_size))
89 {}
90
92 getPossibleEntries(const KeyType &key) const override
93 {
94 return sets[extractSet(key)];
95 }
96
97 Addr
99 const ReplaceableEntry *entry) const override
100 {
101 return (key.address << tagShift) | (entry->getSet() << setShift);
102 }
103};
104
111{
112 public:
115 using TagExtractor = std::function<Addr(Addr)>;
116
118 : _valid(false), _secure(false), _tag(MaxAddr)
119 {}
120 ~TaggedEntry() = default;
121
122 void
124 {
125 extractTag = ext;
126 }
127
133 virtual bool isValid() const { return _valid; }
134
140 bool isSecure() const { return _secure; }
141
147 virtual Addr getTag() const { return _tag; }
148
156 bool
157 match(const KeyType &key) const
158 {
159 return isValid() && (getTag() == extractTag(key.address)) &&
160 (isSecure() == key.secure);
161 }
162
169 virtual void
170 insert(const KeyType &key)
171 {
172 setValid();
173 setTag(extractTag(key.address));
174 if (key.secure) {
175 setSecure();
176 }
177 }
178
180 virtual void invalidate()
181 {
182 _valid = false;
183 setTag(MaxAddr);
184 clearSecure();
185 }
186
187 std::string
188 print() const override
189 {
190 return csprintf("tag: %#x secure: %d valid: %d | %s", getTag(),
191 isSecure(), isValid(), ReplaceableEntry::print());
192 }
193
194 protected:
200 virtual void setTag(Addr tag) { _tag = tag; }
201
203 virtual void setSecure() { _secure = true; }
204
206 void clearSecure() { _secure = false; }
207
209 virtual void
211 {
212 assert(!isValid());
213 _valid = true;
214 }
215
218
219 private:
225 bool _valid;
226
232
235};
236
245static constexpr auto
247{
248 return [ip] (Addr addr) { return ip->extractTag(addr); };
249}
250
251} // namespace gem5
252
253#endif//__CACHE_TAGGED_ENTRY_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
A common base class for indexing table locations.
Definition base.hh:73
typename Types::KeyType KeyType
Definition base.hh:75
typename Types::Params Params
Definition base.hh:76
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
uint32_t getSet() const
Get set number.
virtual std::string print() const
Prints relevant information about this entry.
A tagged entry is an entry containing a tag.
virtual bool isValid() const
Checks if the entry is valid.
void registerTagExtractor(TagExtractor ext)
std::string print() const override
Prints relevant information about this entry.
void clearSecure()
Clear secure bit.
bool match(const KeyType &key) const
Checks if the given tag information corresponds to this entry's.
~TaggedEntry()=default
virtual void setTag(Addr tag)
Set tag associated to this block.
virtual void invalidate()
Invalidate the block.
virtual void insert(const KeyType &key)
Insert the block by assigning it a tag and marking it valid.
bool _valid
Valid bit.
bool isSecure() const
Check if this block holds data from the secure memory space.
Addr _tag
The entry's tag.
virtual Addr getTag() const
Get tag associated to this block.
std::function< Addr(Addr)> TagExtractor
TagExtractor extractTag
Callback used to extract the tag from the entry.
bool _secure
Secure bit.
virtual void setValid()
Set valid bit.
virtual void setSecure()
Set secure bit.
This version of set associative indexing deals with a Lookup structure made of address and secure bit...
PARAMS(TaggedSetAssociative)
Addr regenerateAddr(const KeyType &key, const ReplaceableEntry *entry) const override
Regenerate an entry's address from its tag and assigned indexing bits.
virtual uint32_t extractSet(const KeyType &key) const
std::vector< ReplaceableEntry * > getPossibleEntries(const KeyType &key) const override
Find all possible entries for insertion and replacement of an address.
TaggedSetAssociative(const Params &p)
TaggedIndexingPolicyParams Params
STL vector class.
Definition stl.hh:37
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
Definition intmath.hh:59
Declaration of a common framework for indexing policies.
bool isSecure(ThreadContext *tc)
Definition utility.cc:74
Bitfield< 12 > ext
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
IndexingPolicyTemplate< TaggedTypes > TaggedIndexingPolicy
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
static constexpr auto genTagExtractor(BTBIndexingPolicy *ip)
This helper generates a tag extractor function object which will be typically used by Replaceable ent...
Definition btb_entry.hh:281
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:38 for gem5 by doxygen 1.9.8