gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
page_walk_cache.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Jason Lowe-Power
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __ARCH_AMDGPU_VEGA_PAGE_WALK_CACHE_HH__
30#define __ARCH_AMDGPU_VEGA_PAGE_WALK_CACHE_HH__
31
32
37#include "params/VegaPWCIndexingPolicy.hh"
38
39namespace gem5
40{
41
42
43namespace VegaISA
44{
45
46// Page walk cache entry
48{
49 public:
51 using KeyType = Addr;
52
53 // The data stored in PTE
55
56 // The physical address of the page table entry
58
59 bool valid;
60
61 void
63 {
64 valid = false;
65 }
66
67 void insert(const KeyType &key) {}
68 bool isValid() const { return valid; }
69
70 bool
71 match(const KeyType &key) const
72 {
73 return valid && paddr == key;
74 }
75};
76
84{
85 protected:
86 virtual uint32_t extractSet(const Addr addr) const
87 {
88 // Extract the set bits from the address
89 return (addr >> setShift) & setMask;
90 }
91
92 public:
96 typedef VegaPWCIndexingPolicyParams Params;
97
103 BaseIndexingPolicy(p, p.entries, 3)
104 {}
105
110
112 override
113 {
114 return sets[extractSet(addr)];
115 }
116
118 const ReplaceableEntry* entry) const override
119 {
120 panic("PWCSetAssociative::regenerateAddr() not implemented");
121 return 0;
122 }
123};
124
125// Page walk cache
126class PageWalkCache : public AssociativeCache<PWCEntry>
127{
128 public:
131
132 PWCEntry* accessEntry(const KeyType &key) override
133 {
134 auto entry = findEntry(key);
135 accessEntry(entry);
136 return entry;
137 }
138 PWCEntry* findEntry(const KeyType &key) const override
139 {
140 for (auto candidate : indexingPolicy->getPossibleEntries(key)) {
141 auto entry = static_cast<PWCEntry*>(candidate);
142 if (entry->match(key))
143 return entry;
144 }
145 return nullptr;
146 }
147 void insert(const KeyType &key, const PageTableEntry &pte_entry) {
148 PWCEntry *vict = findVictim(key);
149 vict->pteEntry = pte_entry;
150 vict->paddr = key;
151 vict->valid = true;
152 insertEntry(key, vict);
153 }
154};
155
156} // namespace VegaISA
157} // namespace gem5
158
159#endif // __ARCH_AMDGPU_VEGA_PAGE_WALK_CACHE_HH__
virtual PWCEntry * findVictim(const KeyType &key)
virtual void insertEntry(const KeyType &key, PWCEntry *entry)
std::vector< std::vector< ReplaceableEntry * > > sets
Definition base.hh:101
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
void insert(const KeyType &key, const PageTableEntry &pte_entry)
PWCEntry * accessEntry(const KeyType &key) override
PWCEntry * findEntry(const KeyType &key) const override
Set associative indexing policy for the page walk cache.
VegaPWCIndexingPolicyParams Params
Convenience typedef.
Addr regenerateAddr(const Addr &tag, const ReplaceableEntry *entry) const override
Regenerate an entry's address from its tag and assigned indexing bits.
std::vector< ReplaceableEntry * > getPossibleEntries(const Addr &addr) const override
Find all possible entries for insertion and replacement of an address.
VegaPWCIndexingPolicy(const Params &p)
Construct and initialize this policy.
virtual uint32_t extractSet(const Addr addr) const
STL vector class.
Definition stl.hh:37
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:220
classes that represnt vector/scalar operands in VEGA ISA.
Definition faults.cc:39
Bitfield< 54 > p
Definition pagetable.hh:70
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
IndexingPolicyTemplate< AddrTypes > BaseIndexingPolicy
Definition base.hh:215
Declaration of a set associative indexing policy.
VegaPWCIndexingPolicy IndexingPolicy
void insert(const KeyType &key)
bool match(const KeyType &key) const

Generated on Mon May 26 2025 09:18:57 for gem5 by doxygen 1.13.2