gem5  v21.1.0.2
WireBuffer.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Advanced Micro Devices, Inc.
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  * Author: Lisa Hsu
29  *
30  */
31 
33 
34 #include <algorithm>
35 #include <functional>
36 
37 #include "base/cprintf.hh"
38 #include "base/stl_helpers.hh"
40 
41 namespace gem5
42 {
43 
44 namespace ruby
45 {
46 
47 // Output operator definition
48 
49 std::ostream&
50 operator<<(std::ostream& out, const WireBuffer& obj)
51 {
52  obj.print(out);
53  out << std::flush;
54  return out;
55 }
56 
57 
58 // ****************************************************************
59 
60 // CONSTRUCTOR
62  : SimObject(p)
63 {
64  m_msg_counter = 0;
65 }
66 
67 void
69 {
70 }
71 
73 {
74 }
75 
76 void
77 WireBuffer::enqueue(MsgPtr message, Tick current_time, Tick delta)
78 {
79  m_msg_counter++;
80  Tick arrival_time = current_time + delta;
81  assert(arrival_time > current_time);
82 
83  Message* msg_ptr = message.get();
84  msg_ptr->setLastEnqueueTime(arrival_time);
85  m_message_queue.push_back(message);
86  if (m_consumer_ptr != NULL) {
88  scheduleEventAbsolute(arrival_time);
89  } else {
90  panic("No Consumer for WireBuffer! %s\n", *this);
91  }
92 }
93 
94 void
96 {
97  assert(isReady(current_time));
98  pop_heap(m_message_queue.begin(), m_message_queue.end(),
99  std::greater<MsgPtr>());
100  m_message_queue.pop_back();
101 }
102 
103 const Message*
105 {
106  Message* msg_ptr = m_message_queue.front().get();
107  assert(msg_ptr != NULL);
108  return msg_ptr;
109 }
110 
111 void
112 WireBuffer::recycle(Tick current_time, Tick recycle_latency)
113 {
114  // Because you don't want anything reordered, make sure the recycle latency
115  // is just 1 cycle. As a result, you really want to use this only in
116  // Wire-like situations because you don't want to deadlock as a result of
117  // being stuck behind something if you're not actually supposed to.
118  assert(isReady(current_time));
119  MsgPtr node = m_message_queue.front();
120  pop_heap(m_message_queue.begin(), m_message_queue.end(),
121  std::greater<MsgPtr>());
122 
123  Tick future_time = current_time + recycle_latency;
124  node->setLastEnqueueTime(future_time);
125 
126  m_message_queue.back() = node;
127  push_heap(m_message_queue.begin(), m_message_queue.end(),
128  std::greater<MsgPtr>());
130  scheduleEventAbsolute(future_time);
131 }
132 
133 bool
135 {
136  return ((!m_message_queue.empty()) &&
137  (m_message_queue.front()->getLastEnqueueTime() <= current_time));
138 }
139 
140 void
141 WireBuffer::print(std::ostream& out) const
142 {
143 }
144 
145 void
147 {
148 }
149 
150 } // namespace ruby
151 } // namespace gem5
gem5::ruby::WireBuffer::recycle
void recycle(Tick current_time, Tick recycle_latency)
Definition: WireBuffer.cc:112
gem5::ruby::MsgPtr
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:59
gem5::ruby::operator<<
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
gem5::ruby::WireBuffer::peek
const Message * peek()
Definition: WireBuffer.cc:104
gem5::ruby::WireBuffer::print
void print(std::ostream &out) const
Definition: WireBuffer.cc:141
gem5::ruby::WireBuffer::m_message_queue
std::vector< MsgPtr > m_message_queue
Definition: WireBuffer.hh:102
gem5::ruby::WireBuffer::wakeup
void wakeup()
Definition: WireBuffer.cc:146
gem5::ruby::WireBuffer::Params
RubyWireBufferParams Params
Definition: WireBuffer.hh:65
gem5::ruby::WireBuffer::enqueue
void enqueue(MsgPtr message, Tick current_time, Tick delta)
Definition: WireBuffer.cc:77
gem5::ruby::WireBuffer::m_consumer_ptr
Consumer * m_consumer_ptr
Definition: WireBuffer.hh:98
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::ruby::WireBuffer::dequeue
void dequeue(Tick current_time)
Definition: WireBuffer.cc:95
gem5::ruby::WireBuffer::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: WireBuffer.cc:68
cprintf.hh
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::ruby::WireBuffer::~WireBuffer
~WireBuffer()
Definition: WireBuffer.cc:72
RubySystem.hh
gem5::ruby::WireBuffer::isReady
bool isReady(Tick current_time)
Definition: WireBuffer.cc:134
gem5::ruby::WireBuffer::m_msg_counter
uint64_t m_msg_counter
Definition: WireBuffer.hh:90
gem5::ruby::Message::setLastEnqueueTime
void setLastEnqueueTime(const Tick &time)
Definition: Message.hh:106
gem5::ruby::Message
Definition: Message.hh:62
WireBuffer.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
stl_helpers.hh
gem5::ruby::WireBuffer::WireBuffer
WireBuffer(const Params &p)
Definition: WireBuffer.cc:61
gem5::ruby::WireBuffer
Definition: WireBuffer.hh:62
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177

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