gem5 v24.1.0.1
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, int block_size, const RubySystem *rs)
66 : m_block_size(block_size),
67 m_time(curTime),
68 m_LastEnqueueTime(curTime),
70 { }
71
72 Message(const Message &other) = default;
73
74 virtual ~Message() { }
75
76 virtual MsgPtr clone() const = 0;
77 virtual void print(std::ostream& out) const = 0;
78
79 virtual const MessageSizeType& getMessageSize() const
80 { panic("MessageSizeType() called on wrong message!"); }
81 virtual MessageSizeType& getMessageSize()
82 { panic("MessageSizeType() called on wrong message!"); }
83
91 virtual bool functionalRead(Packet *pkt)
92 { panic("functionalRead(Packet) not implemented"); }
93 virtual bool functionalRead(Packet *pkt, WriteMask &mask)
94 { panic("functionalRead(Packet,WriteMask) not implemented"); }
95 virtual bool functionalWrite(Packet *pkt)
96 { panic("functionalWrite(Packet) not implemented"); }
97
100 {
101 assert(m_LastEnqueueTime <= curTime);
102 Tick delta = curTime - m_LastEnqueueTime;
103 m_DelayedTicks += delta;
104 }
106
107 void setLastEnqueueTime(const Tick& time) { m_LastEnqueueTime = time; }
109
110 Tick getTime() const { return m_time; }
111 void setMsgCounter(uint64_t c) { m_msg_counter = c; }
112 uint64_t getMsgCounter() const { return m_msg_counter; }
113
114 // Functions related to network traversal
115 virtual const NetDest& getDestination() const
116 { panic("getDestination() called on wrong message!"); }
118 { panic("getDestination() called on wrong message!"); }
119
120 int getIncomingLink() const { return incoming_link; }
121 void setIncomingLink(int link) { incoming_link = link; }
122 int getVnet() const { return vnet; }
123 void setVnet(int net) { vnet = net; }
124
125 protected:
127
128 private:
130 Tick m_LastEnqueueTime; // my last enqueue time
131 Tick m_DelayedTicks; // my delayed cycles
132 uint64_t m_msg_counter; // FIXME, should this be a 64-bit value?
133
134 // Variables for required network traversal
136 int vnet;
137};
138
139inline bool
140operator>(const MsgPtr &lhs, const MsgPtr &rhs)
141{
142 const Message *l = lhs.get();
143 const Message *r = rhs.get();
144
145 if (l->getLastEnqueueTime() == r->getLastEnqueueTime()) {
146 return l->getMsgCounter() > r->getMsgCounter();
147 }
148 return l->getLastEnqueueTime() > r->getLastEnqueueTime();
149}
150
151inline std::ostream&
152operator<<(std::ostream& out, const Message& obj)
153{
154 obj.print(out);
155 out << std::flush;
156 return out;
157}
158
159} // namespace ruby
160} // namespace gem5
161
162#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:74
uint64_t getMsgCounter() const
Definition Message.hh:112
uint64_t m_msg_counter
Definition Message.hh:132
Message(Tick curTime, int block_size, const RubySystem *rs)
Definition Message.hh:65
virtual bool functionalRead(Packet *pkt, WriteMask &mask)
Definition Message.hh:93
Tick getDelayedTicks() const
Definition Message.hh:105
virtual MessageSizeType & getMessageSize()
Definition Message.hh:81
virtual bool functionalRead(Packet *pkt)
The two functions below are used for reading / writing the message functionally.
Definition Message.hh:91
virtual const NetDest & getDestination() const
Definition Message.hh:115
int getIncomingLink() const
Definition Message.hh:120
void setVnet(int net)
Definition Message.hh:123
Tick getLastEnqueueTime() const
Definition Message.hh:108
Message(const Message &other)=default
virtual bool functionalWrite(Packet *pkt)
Definition Message.hh:95
void updateDelayedTicks(Tick curTime)
Update the delay this message has experienced so far.
Definition Message.hh:99
virtual void print(std::ostream &out) const =0
void setIncomingLink(int link)
Definition Message.hh:121
Tick getTime() const
Definition Message.hh:110
virtual NetDest & getDestination()
Definition Message.hh:117
virtual MsgPtr clone() const =0
void setMsgCounter(uint64_t c)
Definition Message.hh:111
void setLastEnqueueTime(const Tick &time)
Definition Message.hh:107
int getVnet() const
Definition Message.hh:122
virtual const MessageSizeType & getMessageSize() const
Definition Message.hh:79
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 9, 8 > rs
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:140
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t Tick
Tick count type.
Definition types.hh:58
std::ostream & operator<<(std::ostream &os, const BaseSemihosting::InPlaceArg &ipa)
Declaration of the Packet class.

Generated on Mon Jan 13 2025 04:28:40 for gem5 by doxygen 1.9.8