gem5 v24.0.0.0
Loading...
Searching...
No Matches
TBETable.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef __MEM_RUBY_STRUCTURES_TBETABLE_HH__
42#define __MEM_RUBY_STRUCTURES_TBETABLE_HH__
43
44#include <iostream>
45#include <unordered_map>
46
48
49namespace gem5
50{
51
52namespace ruby
53{
54
55template<class ENTRY>
57{
58 public:
59 TBETable(int number_of_TBEs)
60 : m_number_of_TBEs(number_of_TBEs)
61 {
62 }
63
64 bool isPresent(Addr address) const;
65 void allocate(Addr address);
66 void deallocate(Addr address);
67 bool
68 areNSlotsAvailable(int n, Tick current_time) const
69 {
70 return (m_number_of_TBEs - m_map.size()) >= n;
71 }
72
73 ENTRY *getNullEntry();
74 ENTRY *lookup(Addr address);
75
76 // Print cache contents
77 void print(std::ostream& out) const;
78
79 protected:
80 // Protected copy constructor and assignment operator
81 TBETable(const TBETable& obj);
83
84 // Data Members (m_prefix)
85 std::unordered_map<Addr, ENTRY> m_map;
86
87 private:
89};
90
91template<class ENTRY>
92inline std::ostream&
93operator<<(std::ostream& out, const TBETable<ENTRY>& obj)
94{
95 obj.print(out);
96 out << std::flush;
97 return out;
98}
99
100template<class ENTRY>
101inline bool
103{
104 assert(address == makeLineAddress(address));
105 assert(m_map.size() <= m_number_of_TBEs);
106 return !!m_map.count(address);
107}
108
109template<class ENTRY>
110inline void
112{
113 assert(!isPresent(address));
114 assert(m_map.size() < m_number_of_TBEs);
115 m_map[address] = ENTRY();
116}
117
118template<class ENTRY>
119inline void
121{
122 assert(isPresent(address));
123 assert(m_map.size() > 0);
124 m_map.erase(address);
125}
126
127template<class ENTRY>
128inline ENTRY*
130{
131 return nullptr;
132}
133
134// looks an address up in the cache
135template<class ENTRY>
136inline ENTRY*
138{
139 if (m_map.find(address) != m_map.end()) return &(m_map.find(address)->second);
140 return NULL;
141}
142
143
144template<class ENTRY>
145inline void
146TBETable<ENTRY>::print(std::ostream& out) const
147{
148}
149
150} // namespace ruby
151} // namespace gem5
152
153#endif // __MEM_RUBY_STRUCTURES_TBETABLE_HH__
std::unordered_map< Addr, ENTRY > m_map
Definition TBETable.hh:85
ENTRY * getNullEntry()
Definition TBETable.hh:129
TBETable(const TBETable &obj)
bool areNSlotsAvailable(int n, Tick current_time) const
Definition TBETable.hh:68
bool isPresent(Addr address) const
Definition TBETable.hh:102
TBETable(int number_of_TBEs)
Definition TBETable.hh:59
ENTRY * lookup(Addr address)
Definition TBETable.hh:137
void print(std::ostream &out) const
Definition TBETable.hh:146
void allocate(Addr address)
Definition TBETable.hh:111
void deallocate(Addr address)
Definition TBETable.hh:120
TBETable & operator=(const TBETable &obj)
Bitfield< 31 > n
Addr makeLineAddress(Addr addr)
Definition Address.cc:60
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition BoolVec.cc:49
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria 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
uint64_t Tick
Tick count type.
Definition types.hh:58

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0