gem5  v21.1.0.2
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 
49 namespace gem5
50 {
51 
52 namespace ruby
53 {
54 
55 template<class ENTRY>
56 class TBETable
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  private:
80  // Private copy constructor and assignment operator
81  TBETable(const TBETable& obj);
82  TBETable& operator=(const TBETable& obj);
83 
84  // Data Members (m_prefix)
85  std::unordered_map<Addr, ENTRY> m_map;
86 
87  private:
89 };
90 
91 template<class ENTRY>
92 inline std::ostream&
93 operator<<(std::ostream& out, const TBETable<ENTRY>& obj)
94 {
95  obj.print(out);
96  out << std::flush;
97  return out;
98 }
99 
100 template<class ENTRY>
101 inline bool
103 {
104  assert(address == makeLineAddress(address));
105  assert(m_map.size() <= m_number_of_TBEs);
106  return !!m_map.count(address);
107 }
108 
109 template<class ENTRY>
110 inline void
112 {
113  assert(!isPresent(address));
114  assert(m_map.size() < m_number_of_TBEs);
115  m_map[address] = ENTRY();
116 }
117 
118 template<class ENTRY>
119 inline void
121 {
122  assert(isPresent(address));
123  assert(m_map.size() > 0);
124  m_map.erase(address);
125 }
126 
127 template<class ENTRY>
128 inline ENTRY*
130 {
131  return nullptr;
132 }
133 
134 // looks an address up in the cache
135 template<class ENTRY>
136 inline ENTRY*
138 {
139  if (m_map.find(address) != m_map.end()) return &(m_map.find(address)->second);
140  return NULL;
141 }
142 
143 
144 template<class ENTRY>
145 inline void
146 TBETable<ENTRY>::print(std::ostream& out) const
147 {
148 }
149 
150 } // namespace ruby
151 } // namespace gem5
152 
153 #endif // __MEM_RUBY_STRUCTURES_TBETABLE_HH__
gem5::ruby::TBETable
Definition: TBETable.hh:56
gem5::ruby::TBETable::m_number_of_TBEs
int m_number_of_TBEs
Definition: TBETable.hh:88
gem5::ruby::operator<<
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
gem5::ruby::makeLineAddress
Addr makeLineAddress(Addr addr)
Definition: Address.cc:60
gem5::ruby::TBETable::TBETable
TBETable(int number_of_TBEs)
Definition: TBETable.hh:59
gem5::ruby::TBETable::areNSlotsAvailable
bool areNSlotsAvailable(int n, Tick current_time) const
Definition: TBETable.hh:68
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::ruby::TBETable::m_map
std::unordered_map< Addr, ENTRY > m_map
Definition: TBETable.hh:85
gem5::ruby::TBETable::operator=
TBETable & operator=(const TBETable &obj)
gem5::ruby::TBETable::isPresent
bool isPresent(Addr address) const
Definition: TBETable.hh:102
gem5::ruby::TBETable::allocate
void allocate(Addr address)
Definition: TBETable.hh:111
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::ruby::TBETable::getNullEntry
ENTRY * getNullEntry()
Definition: TBETable.hh:129
gem5::ruby::TBETable::deallocate
void deallocate(Addr address)
Definition: TBETable.hh:120
gem5::ruby::TBETable::print
void print(std::ostream &out) const
Definition: TBETable.hh:146
Address.hh
gem5::ArmISA::n
Bitfield< 31 > n
Definition: misc_types.hh:455
gem5::ruby::TBETable::lookup
ENTRY * lookup(Addr address)
Definition: TBETable.hh:137
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40

Generated on Tue Sep 21 2021 12:25:41 for gem5 by doxygen 1.8.17