gem5  v22.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 
44 namespace gem5
45 {
46 
47 namespace ruby
48 {
49 
51 // This object was written to literally mimic a Wire in Ruby, in the sense
52 // that there is no way for messages to get reordered en route on the WireBuffer.
53 // With Message Buffers, even if randomization is off and ordered is on,
54 // messages can arrive in different orders than they were sent because of
55 // network issues. This mimics a Wire, such that that is not possible. This can
56 // allow for messages between closely coupled controllers that are not actually
57 // separated by a network in real systems to simplify coherence.
59 
60 class Message;
61 
62 class WireBuffer : public SimObject
63 {
64  public:
65  typedef RubyWireBufferParams Params;
66  WireBuffer(const Params &p);
67  void init();
68 
69  ~WireBuffer();
70 
71  void wakeup();
72 
73  void setConsumer(Consumer* consumer_ptr)
74  {
75  m_consumer_ptr = consumer_ptr;
76  }
78  void setDescription(const std::string& name) { m_description = name; };
79  std::string getDescription() { return m_description; };
80 
81  void enqueue(MsgPtr message, Tick current_time, Tick delta);
82  void dequeue(Tick current_time);
83  const Message* peek();
84  void recycle(Tick current_time, Tick recycle_latency);
85  bool isReady(Tick current_time);
86  // infinite queue length
87  bool areNSlotsAvailable(int n, Tick current_time) { return true; };
88 
89  void print(std::ostream& out) const;
90  uint64_t m_msg_counter;
91 
92  private:
93  // Private copy constructor and assignment operator
94  WireBuffer (const WireBuffer& obj);
96 
97  // data members
98  Consumer* m_consumer_ptr; // Consumer to signal a wakeup()
99  std::string m_description;
100 
101  // queues where memory requests live
103 };
104 
105 std::ostream& operator<<(std::ostream& out, const WireBuffer& obj);
106 
107 } // namespace ruby
108 } // namespace gem5
109 
110 #endif // __MEM_RUBY_STRUCTURES_WireBuffer_HH__
virtual std::string name() const
Definition: named.hh:47
Abstract superclass for simulation objects.
Definition: sim_object.hh:148
std::string getDescription()
Definition: WireBuffer.hh:79
Consumer * getConsumer()
Definition: WireBuffer.hh:77
WireBuffer(const Params &p)
Definition: WireBuffer.cc:61
void enqueue(MsgPtr message, Tick current_time, Tick delta)
Definition: WireBuffer.cc:77
WireBuffer(const WireBuffer &obj)
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: WireBuffer.cc:68
WireBuffer & operator=(const WireBuffer &obj)
void setDescription(const std::string &name)
Definition: WireBuffer.hh:78
void recycle(Tick current_time, Tick recycle_latency)
Definition: WireBuffer.cc:112
std::string m_description
Definition: WireBuffer.hh:99
void print(std::ostream &out) const
Definition: WireBuffer.cc:141
void setConsumer(Consumer *consumer_ptr)
Definition: WireBuffer.hh:73
std::vector< MsgPtr > m_message_queue
Definition: WireBuffer.hh:102
const Message * peek()
Definition: WireBuffer.cc:104
Consumer * m_consumer_ptr
Definition: WireBuffer.hh:98
bool areNSlotsAvailable(int n, Tick current_time)
Definition: WireBuffer.hh:87
void dequeue(Tick current_time)
Definition: WireBuffer.cc:95
RubyWireBufferParams Params
Definition: WireBuffer.hh:65
bool isReady(Tick current_time)
Definition: WireBuffer.cc:134
Bitfield< 31 > n
Definition: misc_types.hh:462
Bitfield< 54 > p
Definition: pagetable.hh:70
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:59
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Tick
Tick count type.
Definition: types.hh:58

Generated on Wed Dec 21 2022 10:22:38 for gem5 by doxygen 1.9.1