gem5 v24.0.0.0
Loading...
Searching...
No Matches
flit.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 Princeton University
3 * Copyright (c) 2016 Georgia Institute of Technology
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30
32
33#include "base/intmath.hh"
34#include "debug/RubyNetwork.hh"
35
36namespace gem5
37{
38
39namespace ruby
40{
41
42namespace garnet
43{
44
45// Constructor for the flit
46flit::flit(int packet_id, int id, int vc, int vnet, RouteInfo route, int size,
47 MsgPtr msg_ptr, int MsgSize, uint32_t bWidth, Tick curTime)
48{
49 m_size = size;
50 m_msg_ptr = msg_ptr;
51 m_enqueue_time = curTime;
52 m_dequeue_time = curTime;
53 m_time = curTime;
54 m_packet_id = packet_id;
55 m_id = id;
56 m_vnet = vnet;
57 m_vc = vc;
58 m_route = route;
59 m_stage.first = I_;
60 m_stage.second = curTime;
61 m_width = bWidth;
62 msgSize = MsgSize;
63
64 if (size == 1) {
66 return;
67 }
68 if (id == 0)
69 m_type = HEAD_;
70 else if (id == (size - 1))
71 m_type = TAIL_;
72 else
73 m_type = BODY_;
74}
75
76flit *
77flit::serialize(int ser_id, int parts, uint32_t bWidth)
78{
79 assert(m_width > bWidth);
80
81 int ratio = (int)divCeil(m_width, bWidth);
82 int new_id = (m_id*ratio) + ser_id;
83 int new_size = (int)divCeil((float)msgSize, (float)bWidth);
84 assert(new_id < new_size);
85
86 flit *fl = new flit(m_packet_id, new_id, m_vc, m_vnet, m_route,
87 new_size, m_msg_ptr, msgSize, bWidth, m_time);
90 return fl;
91}
92
93flit *
94flit::deserialize(int des_id, int num_flits, uint32_t bWidth)
95{
96 int ratio = (int)divCeil((float)bWidth, (float)m_width);
97 int new_id = ((int)divCeil((float)(m_id+1), (float)ratio)) - 1;
98 int new_size = (int)divCeil((float)msgSize, (float)bWidth);
99 assert(new_id < new_size);
100
101 flit *fl = new flit(m_packet_id, new_id, m_vc, m_vnet, m_route,
102 new_size, m_msg_ptr, msgSize, bWidth, m_time);
105 return fl;
106}
107
108// Flit can be printed out for debugging purposes
109void
110flit::print(std::ostream& out) const
111{
112 out << "[flit:: ";
113 out << "PacketId=" << m_packet_id << " ";
114 out << "Id=" << m_id << " ";
115 out << "Type=" << m_type << " ";
116 out << "Size=" << m_size << " ";
117 out << "Vnet=" << m_vnet << " ";
118 out << "VC=" << m_vc << " ";
119 out << "Src NI=" << m_route.src_ni << " ";
120 out << "Src Router=" << m_route.src_router << " ";
121 out << "Dest NI=" << m_route.dest_ni << " ";
122 out << "Dest Router=" << m_route.dest_router << " ";
123 out << "Set Time=" << m_time << " ";
124 out << "Width=" << m_width<< " ";
125 out << "]";
126}
127
128bool
130{
131 Message *msg = m_msg_ptr.get();
132 return msg->functionalRead(pkt, mask);
133}
134
135bool
137{
138 Message *msg = m_msg_ptr.get();
139 return msg->functionalWrite(pkt);
140}
141
142} // namespace garnet
143} // namespace ruby
144} // namespace gem5
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
virtual bool functionalRead(Packet *pkt)
The two functions below are used for reading / writing the message functionally.
Definition Message.hh:90
virtual bool functionalWrite(Packet *pkt)
Definition Message.hh:94
bool functionalWrite(Packet *pkt)
Definition flit.cc:136
virtual flit * serialize(int ser_id, int parts, uint32_t bWidth)
Definition flit.cc:77
void set_src_delay(Tick delay)
Definition flit.hh:78
virtual flit * deserialize(int des_id, int num_flits, uint32_t bWidth)
Definition flit.cc:94
void set_enqueue_time(Tick time)
Definition flit.hh:80
virtual void print(std::ostream &out) const
Definition flit.cc:110
bool functionalRead(Packet *pkt, WriteMask &mask)
Definition flit.cc:129
std::pair< flit_stage, Tick > m_stage
Definition flit.hh:131
static constexpr T divCeil(const T &a, const U &b)
Definition intmath.hh:110
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 33 > id
std::shared_ptr< Message > MsgPtr
Definition Message.hh:60
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

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