gem5  v21.1.0.2
TimerTable.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
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 
30 
32 
33 namespace gem5
34 {
35 
36 namespace ruby
37 {
38 
40  : m_next_time(0)
41 {
42  m_consumer_ptr = NULL;
43  m_next_valid = false;
44  m_next_address = 0;
45 }
46 
47 bool
48 TimerTable::isReady(Tick curTime) const
49 {
50  if (m_map.empty())
51  return false;
52 
53  if (!m_next_valid) {
54  updateNext();
55  }
56  assert(m_next_valid);
57  return (curTime >= m_next_time);
58 }
59 
60 Addr
62 {
63  if (!m_next_valid) {
64  updateNext();
65  }
66  assert(m_next_valid);
67  return m_next_address;
68 }
69 
70 void
71 TimerTable::set(Addr address, Tick ready_time)
72 {
73  assert(address == makeLineAddress(address));
74  assert(!m_map.count(address));
75 
76  m_map[address] = ready_time;
77  assert(m_consumer_ptr != NULL);
79  m_next_valid = false;
80 
81  // Don't always recalculate the next ready address
82  if (ready_time <= m_next_time) {
83  m_next_valid = false;
84  }
85 }
86 
87 void
89 {
90  assert(address == makeLineAddress(address));
91  assert(m_map.count(address));
92  m_map.erase(address);
93 
94  // Don't always recalculate the next ready address
95  if (address == m_next_address) {
96  m_next_valid = false;
97  }
98 }
99 
100 void
101 TimerTable::print(std::ostream& out) const
102 {
103 }
104 
105 void
107 {
108  if (m_map.empty()) {
109  assert(!m_next_valid);
110  return;
111  }
112 
113  AddressMap::const_iterator i = m_map.begin();
114  AddressMap::const_iterator end = m_map.end();
115 
116  m_next_address = i->first;
117  m_next_time = i->second;
118  ++i;
119 
120  for (; i != end; ++i) {
121  if (i->second < m_next_time) {
122  m_next_address = i->first;
123  m_next_time = i->second;
124  }
125  }
126 
127  m_next_valid = true;
128 }
129 
130 } // namespace ruby
131 } // namespace gem5
gem5::ruby::TimerTable::m_next_valid
bool m_next_valid
Definition: TimerTable.hh:84
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
gem5::ruby::makeLineAddress
Addr makeLineAddress(Addr addr)
Definition: Address.cc:60
gem5::ruby::TimerTable::set
void set(Addr address, Tick ready_time)
Definition: TimerTable.cc:71
gem5::ruby::TimerTable::TimerTable
TimerTable()
Definition: TimerTable.cc:39
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
RubySystem.hh
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::ruby::TimerTable::m_map
AddressMap m_map
Definition: TimerTable.hh:83
gem5::ruby::TimerTable::print
void print(std::ostream &out) const
Definition: TimerTable.cc:101
gem5::ruby::TimerTable::updateNext
void updateNext() const
Definition: TimerTable.cc:106
TimerTable.hh
gem5::ruby::TimerTable::unset
void unset(Addr address)
Definition: TimerTable.cc:88
gem5::ruby::TimerTable::isReady
bool isReady(Tick curTime) const
Definition: TimerTable.cc:48
gem5::ruby::TimerTable::m_next_time
Tick m_next_time
Definition: TimerTable.hh:85
gem5::ruby::TimerTable::nextAddress
Addr nextAddress() const
Definition: TimerTable.cc:61
gem5::ruby::TimerTable::m_consumer_ptr
Consumer * m_consumer_ptr
Consumer to signal a wakeup()
Definition: TimerTable.hh:89
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ruby::TimerTable::m_next_address
Addr m_next_address
Definition: TimerTable.hh:86
gem5::ruby::Consumer::scheduleEventAbsolute
void scheduleEventAbsolute(Tick timeAbs)
Definition: Consumer.cc:63

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