gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
53namespace gem5
54{
55
56namespace ruby
57{
58
59class Message;
60typedef std::shared_ptr<Message> MsgPtr;
61
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
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
135inline bool
136operator>(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
147inline std::ostream&
148operator<<(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__
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
virtual ~Message()
Definition Message.hh:73
uint64_t getMsgCounter() const
Definition Message.hh:111
uint64_t m_msg_counter
Definition Message.hh:128
virtual bool functionalRead(Packet *pkt, WriteMask &mask)
Definition Message.hh:92
Tick getDelayedTicks() const
Definition Message.hh:104
virtual MessageSizeType & getMessageSize()
Definition Message.hh:80
virtual bool functionalRead(Packet *pkt)
The two functions below are used for reading / writing the message functionally.
Definition Message.hh:90
virtual const NetDest & getDestination() const
Definition Message.hh:114
int getIncomingLink() const
Definition Message.hh:119
void setVnet(int net)
Definition Message.hh:122
Tick getLastEnqueueTime() const
Definition Message.hh:107
Message(const Message &other)=default
Message(Tick curTime)
Definition Message.hh:65
virtual bool functionalWrite(Packet *pkt)
Definition Message.hh:94
void updateDelayedTicks(Tick curTime)
Update the delay this message has experienced so far.
Definition Message.hh:98
virtual void print(std::ostream &out) const =0
void setIncomingLink(int link)
Definition Message.hh:120
Tick getTime() const
Definition Message.hh:109
virtual NetDest & getDestination()
Definition Message.hh:116
virtual MsgPtr clone() const =0
void setMsgCounter(uint64_t c)
Definition Message.hh:110
void setLastEnqueueTime(const Tick &time)
Definition Message.hh:106
int getVnet() const
Definition Message.hh:121
virtual const MessageSizeType & getMessageSize() const
Definition Message.hh:78
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 29 > c
Definition misc_types.hh:53
Bitfield< 5 > l
std::shared_ptr< Message > MsgPtr
Definition Message.hh:60
bool operator>(const MsgPtr &lhs, const MsgPtr &rhs)
Definition Message.hh:136
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition BoolVec.cc:49
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Tick
Tick count type.
Definition types.hh:58
Declaration of the Packet class.

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0