gem5  v21.1.0.2
Message.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 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_SLICC_INTERFACE_MESSAGE_HH__
42 #define __MEM_RUBY_SLICC_INTERFACE_MESSAGE_HH__
43 
44 #include <iostream>
45 #include <memory>
46 #include <stack>
47 
48 #include "mem/packet.hh"
51 #include "mem/ruby/protocol/MessageSizeType.hh"
52 
53 namespace gem5
54 {
55 
56 namespace ruby
57 {
58 
59 class Message;
60 typedef std::shared_ptr<Message> MsgPtr;
61 
62 class Message
63 {
64  public:
65  Message(Tick curTime)
66  : m_time(curTime),
67  m_LastEnqueueTime(curTime),
69  { }
70 
71  Message(const Message &other) = default;
72 
73  virtual ~Message() { }
74 
75  virtual MsgPtr clone() const = 0;
76  virtual void print(std::ostream& out) const = 0;
77 
78  virtual const MessageSizeType& getMessageSize() const
79  { panic("MessageSizeType() called on wrong message!"); }
80  virtual MessageSizeType& getMessageSize()
81  { panic("MessageSizeType() called on wrong message!"); }
82 
90  virtual bool functionalRead(Packet *pkt)
91  { panic("functionalRead(Packet) not implemented"); }
92  virtual bool functionalRead(Packet *pkt, WriteMask &mask)
93  { panic("functionalRead(Packet,WriteMask) not implemented"); }
94  virtual bool functionalWrite(Packet *pkt)
95  { panic("functionalWrite(Packet) not implemented"); }
96 
98  void updateDelayedTicks(Tick curTime)
99  {
100  assert(m_LastEnqueueTime <= curTime);
101  Tick delta = curTime - m_LastEnqueueTime;
102  m_DelayedTicks += delta;
103  }
105 
106  void setLastEnqueueTime(const Tick& time) { m_LastEnqueueTime = time; }
108 
109  Tick getTime() const { return m_time; }
110  void setMsgCounter(uint64_t c) { m_msg_counter = c; }
111  uint64_t getMsgCounter() const { return m_msg_counter; }
112 
113  // Functions related to network traversal
114  virtual const NetDest& getDestination() const
115  { panic("getDestination() called on wrong message!"); }
117  { panic("getDestination() called on wrong message!"); }
118 
119  int getIncomingLink() const { return incoming_link; }
120  void setIncomingLink(int link) { incoming_link = link; }
121  int getVnet() const { return vnet; }
122  void setVnet(int net) { vnet = net; }
123 
124  private:
126  Tick m_LastEnqueueTime; // my last enqueue time
127  Tick m_DelayedTicks; // my delayed cycles
128  uint64_t m_msg_counter; // FIXME, should this be a 64-bit value?
129 
130  // Variables for required network traversal
132  int vnet;
133 };
134 
135 inline bool
136 operator>(const MsgPtr &lhs, const MsgPtr &rhs)
137 {
138  const Message *l = lhs.get();
139  const Message *r = rhs.get();
140 
141  if (l->getLastEnqueueTime() == r->getLastEnqueueTime()) {
142  return l->getMsgCounter() > r->getMsgCounter();
143  }
144  return l->getLastEnqueueTime() > r->getLastEnqueueTime();
145 }
146 
147 inline std::ostream&
148 operator<<(std::ostream& out, const Message& obj)
149 {
150  obj.print(out);
151  out << std::flush;
152  return out;
153 }
154 
155 } // namespace ruby
156 } // namespace gem5
157 
158 #endif // __MEM_RUBY_SLICC_INTERFACE_MESSAGE_HH__
gem5::ruby::operator>
bool operator>(const MsgPtr &lhs, const MsgPtr &rhs)
Definition: Message.hh:136
gem5::ruby::Message::Message
Message(Tick curTime)
Definition: Message.hh:65
gem5::ruby::Message::getMessageSize
virtual MessageSizeType & getMessageSize()
Definition: Message.hh:80
gem5::ruby::Message::vnet
int vnet
Definition: Message.hh:132
gem5::ruby::MsgPtr
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:59
gem5::ruby::Message::print
virtual void print(std::ostream &out) const =0
gem5::ruby::WriteMask
Definition: WriteMask.hh:59
gem5::ruby::Message::clone
virtual MsgPtr clone() const =0
gem5::ruby::Message::incoming_link
int incoming_link
Definition: Message.hh:131
gem5::ruby::Message::setIncomingLink
void setIncomingLink(int link)
Definition: Message.hh:120
gem5::ruby::operator<<
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
gem5::ruby::Message::getMessageSize
virtual const MessageSizeType & getMessageSize() const
Definition: Message.hh:78
gem5::ruby::Message::getLastEnqueueTime
Tick getLastEnqueueTime() const
Definition: Message.hh:107
gem5::ruby::Message::getIncomingLink
int getIncomingLink() const
Definition: Message.hh:119
gem5::ruby::Message::getVnet
int getVnet() const
Definition: Message.hh:121
gem5::mask
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
packet.hh
gem5::ruby::Message::setMsgCounter
void setMsgCounter(uint64_t c)
Definition: Message.hh:110
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
WriteMask.hh
gem5::ruby::Message::m_DelayedTicks
Tick m_DelayedTicks
Definition: Message.hh:127
gem5::ruby::Message::m_msg_counter
uint64_t m_msg_counter
Definition: Message.hh:128
gem5::ruby::Message::getDelayedTicks
Tick getDelayedTicks() const
Definition: Message.hh:104
gem5::ruby::Message::functionalWrite
virtual bool functionalWrite(Packet *pkt)
Definition: Message.hh:94
gem5::MipsISA::l
Bitfield< 5 > l
Definition: pra_constants.hh:323
gem5::ruby::Message::m_time
Tick m_time
Definition: Message.hh:125
gem5::ruby::Message::setVnet
void setVnet(int net)
Definition: Message.hh:122
gem5::ruby::Message::getMsgCounter
uint64_t getMsgCounter() const
Definition: Message.hh:111
gem5::ArmISA::c
Bitfield< 29 > c
Definition: misc_types.hh:53
gem5::ruby::Message::functionalRead
virtual bool functionalRead(Packet *pkt)
The two functions below are used for reading / writing the message functionally.
Definition: Message.hh:90
gem5::ruby::Message::updateDelayedTicks
void updateDelayedTicks(Tick curTime)
Update the delay this message has experienced so far.
Definition: Message.hh:98
gem5::ruby::NetDest
Definition: NetDest.hh:45
gem5::ruby::Message::~Message
virtual ~Message()
Definition: Message.hh:73
gem5::ruby::Message::getTime
Tick getTime() const
Definition: Message.hh:109
gem5::ruby::Message::getDestination
virtual NetDest & getDestination()
Definition: Message.hh:116
gem5::ruby::Message::setLastEnqueueTime
void setLastEnqueueTime(const Tick &time)
Definition: Message.hh:106
gem5::MipsISA::r
r
Definition: pra_constants.hh:98
gem5::ruby::Message
Definition: Message.hh:62
gem5::ruby::Message::functionalRead
virtual bool functionalRead(Packet *pkt, WriteMask &mask)
Definition: Message.hh:92
gem5::ruby::Message::getDestination
virtual const NetDest & getDestination() const
Definition: Message.hh:114
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
NetDest.hh
gem5::ruby::Message::m_LastEnqueueTime
Tick m_LastEnqueueTime
Definition: Message.hh:126
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177

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