gem5  v20.1.0.0
Message.hh
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 
29 #ifndef __MEM_RUBY_SLICC_INTERFACE_MESSAGE_HH__
30 #define __MEM_RUBY_SLICC_INTERFACE_MESSAGE_HH__
31 
32 #include <iostream>
33 #include <memory>
34 #include <stack>
35 
36 #include "mem/packet.hh"
38 #include "mem/ruby/protocol/MessageSizeType.hh"
39 
40 class Message;
41 typedef std::shared_ptr<Message> MsgPtr;
42 
43 class Message
44 {
45  public:
46  Message(Tick curTime)
47  : m_time(curTime),
48  m_LastEnqueueTime(curTime),
50  { }
51 
52  Message(const Message &other)
53  : m_time(other.m_time),
57  { }
58 
59  virtual ~Message() { }
60 
61  virtual MsgPtr clone() const = 0;
62  virtual void print(std::ostream& out) const = 0;
63 
64  virtual const MessageSizeType& getMessageSize() const
65  { panic("MessageSizeType() called on wrong message!"); }
66  virtual MessageSizeType& getMessageSize()
67  { panic("MessageSizeType() called on wrong message!"); }
68 
76  virtual bool functionalRead(Packet *pkt) = 0;
77  virtual bool functionalWrite(Packet *pkt) = 0;
78 
80  void updateDelayedTicks(Tick curTime)
81  {
82  assert(m_LastEnqueueTime <= curTime);
83  Tick delta = curTime - m_LastEnqueueTime;
84  m_DelayedTicks += delta;
85  }
87 
88  void setLastEnqueueTime(const Tick& time) { m_LastEnqueueTime = time; }
90 
91  Tick getTime() const { return m_time; }
92  void setMsgCounter(uint64_t c) { m_msg_counter = c; }
93  uint64_t getMsgCounter() const { return m_msg_counter; }
94 
95  // Functions related to network traversal
96  virtual const NetDest& getDestination() const
97  { panic("getDestination() called on wrong message!"); }
99  { panic("getDestination() called on wrong message!"); }
100 
101  int getIncomingLink() const { return incoming_link; }
102  void setIncomingLink(int link) { incoming_link = link; }
103  int getVnet() const { return vnet; }
104  void setVnet(int net) { vnet = net; }
105 
106  private:
108  Tick m_LastEnqueueTime; // my last enqueue time
109  Tick m_DelayedTicks; // my delayed cycles
110  uint64_t m_msg_counter; // FIXME, should this be a 64-bit value?
111 
112  // Variables for required network traversal
114  int vnet;
115 };
116 
117 inline bool
118 operator>(const MsgPtr &lhs, const MsgPtr &rhs)
119 {
120  const Message *l = lhs.get();
121  const Message *r = rhs.get();
122 
123  if (l->getLastEnqueueTime() == r->getLastEnqueueTime()) {
124  return l->getMsgCounter() > r->getMsgCounter();
125  }
126  return l->getLastEnqueueTime() > r->getLastEnqueueTime();
127 }
128 
129 inline std::ostream&
130 operator<<(std::ostream& out, const Message& obj)
131 {
132  obj.print(out);
133  out << std::flush;
134  return out;
135 }
136 
137 #endif // __MEM_RUBY_SLICC_INTERFACE_MESSAGE_HH__
Message::getDelayedTicks
Tick getDelayedTicks() const
Definition: Message.hh:86
Message::getMessageSize
virtual MessageSizeType & getMessageSize()
Definition: Message.hh:66
Message::getDestination
virtual const NetDest & getDestination() const
Definition: Message.hh:96
Message::getLastEnqueueTime
Tick getLastEnqueueTime() const
Definition: Message.hh:89
Message::~Message
virtual ~Message()
Definition: Message.hh:59
Message::m_DelayedTicks
Tick m_DelayedTicks
Definition: Message.hh:109
Message::getVnet
int getVnet() const
Definition: Message.hh:103
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
Message::getMessageSize
virtual const MessageSizeType & getMessageSize() const
Definition: Message.hh:64
Message::print
virtual void print(std::ostream &out) const =0
Message::getIncomingLink
int getIncomingLink() const
Definition: Message.hh:101
packet.hh
Message::clone
virtual MsgPtr clone() const =0
Message::m_LastEnqueueTime
Tick m_LastEnqueueTime
Definition: Message.hh:108
Message::updateDelayedTicks
void updateDelayedTicks(Tick curTime)
Update the delay this message has experienced so far.
Definition: Message.hh:80
Message::getDestination
virtual NetDest & getDestination()
Definition: Message.hh:98
Message::vnet
int vnet
Definition: Message.hh:114
Message::getTime
Tick getTime() const
Definition: Message.hh:91
Message::Message
Message(const Message &other)
Definition: Message.hh:52
MipsISA::r
r
Definition: pra_constants.hh:95
Message::m_msg_counter
uint64_t m_msg_counter
Definition: Message.hh:110
MsgPtr
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:40
Message::m_time
Tick m_time
Definition: Message.hh:107
Message::Message
Message(Tick curTime)
Definition: Message.hh:46
Message::setLastEnqueueTime
void setLastEnqueueTime(const Tick &time)
Definition: Message.hh:88
operator>
bool operator>(const MsgPtr &lhs, const MsgPtr &rhs)
Definition: Message.hh:118
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Message::getMsgCounter
uint64_t getMsgCounter() const
Definition: Message.hh:93
operator<<
std::ostream & operator<<(std::ostream &out, const Message &obj)
Definition: Message.hh:130
Message
Definition: Message.hh:43
ArmISA::c
Bitfield< 29 > c
Definition: miscregs_types.hh:50
Message::functionalRead
virtual bool functionalRead(Packet *pkt)=0
The two functions below are used for reading / writing the message functionally.
MipsISA::l
Bitfield< 5 > l
Definition: pra_constants.hh:320
Message::setVnet
void setVnet(int net)
Definition: Message.hh:104
Message::setIncomingLink
void setIncomingLink(int link)
Definition: Message.hh:102
NetDest
Definition: NetDest.hh:39
Message::incoming_link
int incoming_link
Definition: Message.hh:113
NetDest.hh
Message::setMsgCounter
void setMsgCounter(uint64_t c)
Definition: Message.hh:92
Message::functionalWrite
virtual bool functionalWrite(Packet *pkt)=0
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171

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