gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
37 #include "mem/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:
107  const Tick m_time;
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__
virtual const MessageSizeType & getMessageSize() const
Definition: Message.hh:64
virtual const NetDest & getDestination() const
Definition: Message.hh:96
virtual ~Message()
Definition: Message.hh:59
Tick getLastEnqueueTime() const
Definition: Message.hh:89
virtual void print(std::ostream &out) const =0
Message(Tick curTime)
Definition: Message.hh:46
virtual NetDest & getDestination()
Definition: Message.hh:98
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:40
#define panic(...)
Definition: misc.hh:153
virtual bool functionalRead(Packet *pkt)=0
The two functions below are used for reading / writing the message functionally.
int incoming_link
Definition: Message.hh:113
void setVnet(int net)
Definition: Message.hh:104
bool operator>(const MsgPtr &lhs, const MsgPtr &rhs)
Definition: Message.hh:118
int getVnet() const
Definition: Message.hh:103
Tick m_DelayedTicks
Definition: Message.hh:109
void setIncomingLink(int link)
Definition: Message.hh:102
Tick getDelayedTicks() const
Definition: Message.hh:86
void setMsgCounter(uint64_t c)
Definition: Message.hh:92
virtual bool functionalWrite(Packet *pkt)=0
uint64_t Tick
Tick count type.
Definition: types.hh:63
uint64_t m_msg_counter
Definition: Message.hh:110
int vnet
Definition: Message.hh:114
virtual MsgPtr clone() const =0
virtual MessageSizeType & getMessageSize()
Definition: Message.hh:66
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
const Tick m_time
Definition: Message.hh:107
int getIncomingLink() const
Definition: Message.hh:101
Bitfield< 29 > c
Definition: miscregs.hh:1365
Declaration of the Packet class.
uint64_t getMsgCounter() const
Definition: Message.hh:93
Tick getTime() const
Definition: Message.hh:91
void updateDelayedTicks(Tick curTime)
Update the delay this message has experienced so far.
Definition: Message.hh:80
std::ostream & operator<<(std::ostream &out, const Message &obj)
Definition: Message.hh:130
Message(const Message &other)
Definition: Message.hh:52
Bitfield< 5 > l
void setLastEnqueueTime(const Tick &time)
Definition: Message.hh:88
Tick m_LastEnqueueTime
Definition: Message.hh:108

Generated on Fri Jun 9 2017 13:03:50 for gem5 by doxygen 1.8.6