gem5  v20.1.0.0
WireBuffer.hh
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 
32 #ifndef __MEM_RUBY_STRUCTURES_WIREBUFFER_HH__
33 #define __MEM_RUBY_STRUCTURES_WIREBUFFER_HH__
34 
35 #include <iostream>
36 #include <string>
37 #include <vector>
38 
41 #include "params/RubyWireBuffer.hh"
42 #include "sim/sim_object.hh"
43 
45 // This object was written to literally mimic a Wire in Ruby, in the sense
46 // that there is no way for messages to get reordered en route on the WireBuffer.
47 // With Message Buffers, even if randomization is off and ordered is on,
48 // messages can arrive in different orders than they were sent because of
49 // network issues. This mimics a Wire, such that that is not possible. This can
50 // allow for messages between closely coupled controllers that are not actually
51 // separated by a network in real systems to simplify coherence.
53 
54 class Message;
55 
56 class WireBuffer : public SimObject
57 {
58  public:
59  typedef RubyWireBufferParams Params;
60  WireBuffer(const Params *p);
61  void init();
62 
63  ~WireBuffer();
64 
65  void wakeup();
66 
67  void setConsumer(Consumer* consumer_ptr)
68  {
69  m_consumer_ptr = consumer_ptr;
70  }
72  void setDescription(const std::string& name) { m_description = name; };
73  std::string getDescription() { return m_description; };
74 
75  void enqueue(MsgPtr message, Tick current_time, Tick delta);
76  void dequeue(Tick current_time);
77  const Message* peek();
78  void recycle(Tick current_time, Tick recycle_latency);
79  bool isReady(Tick current_time);
80  // infinite queue length
81  bool areNSlotsAvailable(int n, Tick current_time) { return true; };
82 
83  void print(std::ostream& out) const;
84  uint64_t m_msg_counter;
85 
86  private:
87  // Private copy constructor and assignment operator
88  WireBuffer (const WireBuffer& obj);
89  WireBuffer& operator=(const WireBuffer& obj);
90 
91  // data members
92  Consumer* m_consumer_ptr; // Consumer to signal a wakeup()
93  std::string m_description;
94 
95  // queues where memory requests live
97 };
98 
99 std::ostream& operator<<(std::ostream& out, const WireBuffer& obj);
100 
101 #endif // __MEM_RUBY_STRUCTURES_WireBuffer_HH__
WireBuffer::Params
RubyWireBufferParams Params
Definition: WireBuffer.hh:59
WireBuffer::peek
const Message * peek()
Definition: WireBuffer.cc:100
WireBuffer::~WireBuffer
~WireBuffer()
Definition: WireBuffer.cc:68
WireBuffer::m_description
std::string m_description
Definition: WireBuffer.hh:93
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
WireBuffer::dequeue
void dequeue(Tick current_time)
Definition: WireBuffer.cc:91
WireBuffer::m_consumer_ptr
Consumer * m_consumer_ptr
Definition: WireBuffer.hh:92
std::vector< MsgPtr >
WireBuffer::getConsumer
Consumer * getConsumer()
Definition: WireBuffer.hh:71
WireBuffer::m_message_queue
std::vector< MsgPtr > m_message_queue
Definition: WireBuffer.hh:96
WireBuffer::WireBuffer
WireBuffer(const Params *p)
Definition: WireBuffer.cc:57
WireBuffer::print
void print(std::ostream &out) const
Definition: WireBuffer.cc:136
ArmISA::n
Bitfield< 31 > n
Definition: miscregs_types.hh:450
sim_object.hh
Consumer
Definition: Consumer.hh:43
WireBuffer::getDescription
std::string getDescription()
Definition: WireBuffer.hh:73
WireBuffer
Definition: WireBuffer.hh:56
WireBuffer::m_msg_counter
uint64_t m_msg_counter
Definition: WireBuffer.hh:84
MsgPtr
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:40
WireBuffer::isReady
bool isReady(Tick current_time)
Definition: WireBuffer.cc:129
WireBuffer::setDescription
void setDescription(const std::string &name)
Definition: WireBuffer.hh:72
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
WireBuffer::areNSlotsAvailable
bool areNSlotsAvailable(int n, Tick current_time)
Definition: WireBuffer.hh:81
WireBuffer::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: WireBuffer.cc:64
Consumer.hh
WireBuffer::setConsumer
void setConsumer(Consumer *consumer_ptr)
Definition: WireBuffer.hh:67
Message
Definition: Message.hh:43
WireBuffer::enqueue
void enqueue(MsgPtr message, Tick current_time, Tick delta)
Definition: WireBuffer.cc:73
operator<<
std::ostream & operator<<(std::ostream &out, const WireBuffer &obj)
WireBuffer::recycle
void recycle(Tick current_time, Tick recycle_latency)
Definition: WireBuffer.cc:108
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Message.hh
WireBuffer::wakeup
void wakeup()
Definition: WireBuffer.cc:141
WireBuffer::operator=
WireBuffer & operator=(const WireBuffer &obj)
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17