gem5  v22.0.0.2
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 
36 namespace gem5
37 {
38 
39 namespace ruby
40 {
41 
42 namespace garnet
43 {
44 
45 // Constructor for the flit
46 flit::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 = 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 
76 flit *
77 flit::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 
93 flit *
94 flit::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
109 void
110 flit::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 
128 bool
130 {
131  Message *msg = m_msg_ptr.get();
132  return msg->functionalWrite(pkt);
133 }
134 
135 } // namespace garnet
136 } // namespace ruby
137 } // namespace gem5
gem5::ruby::garnet::flit
Definition: flit.hh:50
gem5::ruby::garnet::flit::src_delay
Tick src_delay
Definition: flit.hh:129
gem5::ruby::garnet::flit::m_route
RouteInfo m_route
Definition: flit.hh:122
gem5::ruby::garnet::flit::functionalWrite
bool functionalWrite(Packet *pkt)
Definition: flit.cc:129
gem5::ruby::MsgPtr
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:59
gem5::ruby::garnet::flit::m_size
int m_size
Definition: flit.hh:123
gem5::ruby::garnet::flit::m_vc
int m_vc
Definition: flit.hh:121
gem5::ruby::garnet::HEAD_TAIL_
@ HEAD_TAIL_
Definition: CommonTypes.hh:47
gem5::ruby::garnet::flit::m_dequeue_time
Tick m_dequeue_time
Definition: flit.hh:124
gem5::ruby::garnet::RouteInfo
Definition: CommonTypes.hh:56
gem5::ruby::garnet::flit::deserialize
virtual flit * deserialize(int des_id, int num_flits, uint32_t bWidth)
Definition: flit.cc:94
gem5::ruby::garnet::flit::msgSize
int msgSize
Definition: flit.hh:116
gem5::ruby::garnet::RouteInfo::src_router
int src_router
Definition: CommonTypes.hh:69
gem5::ruby::garnet::I_
@ I_
Definition: CommonTypes.hh:51
gem5::ruby::garnet::RouteInfo::dest_ni
int dest_ni
Definition: CommonTypes.hh:70
gem5::ruby::garnet::RouteInfo::src_ni
int src_ni
Definition: CommonTypes.hh:68
gem5::ruby::garnet::flit::flit
flit()
Definition: flit.hh:53
gem5::ruby::garnet::flit::m_stage
std::pair< flit_stage, Tick > m_stage
Definition: flit.hh:130
gem5::ruby::garnet::flit::set_src_delay
void set_src_delay(Tick delay)
Definition: flit.hh:78
gem5::ruby::garnet::flit::m_vnet
int m_vnet
Definition: flit.hh:120
gem5::ruby::garnet::flit::set_enqueue_time
void set_enqueue_time(Tick time)
Definition: flit.hh:80
gem5::ruby::garnet::flit::m_packet_id
int m_packet_id
Definition: flit.hh:118
gem5::ruby::garnet::BODY_
@ BODY_
Definition: CommonTypes.hh:47
gem5::ruby::garnet::HEAD_
@ HEAD_
Definition: CommonTypes.hh:47
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:291
gem5::ruby::garnet::RouteInfo::dest_router
int dest_router
Definition: CommonTypes.hh:71
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::ruby::Message::functionalWrite
virtual bool functionalWrite(Packet *pkt)
Definition: Message.hh:94
gem5::ruby::garnet::flit::m_time
Tick m_time
Definition: flit.hh:125
gem5::ruby::garnet::flit::m_id
int m_id
Definition: flit.hh:119
flit.hh
gem5::divCeil
static constexpr T divCeil(const T &a, const U &b)
Definition: intmath.hh:110
gem5::ruby::garnet::flit::m_type
flit_type m_type
Definition: flit.hh:126
gem5::ruby::garnet::TAIL_
@ TAIL_
Definition: CommonTypes.hh:47
gem5::ArmISA::id
Bitfield< 33 > id
Definition: misc_types.hh:251
gem5::ruby::garnet::flit::m_enqueue_time
Tick m_enqueue_time
Definition: flit.hh:124
gem5::ruby::Message
Definition: Message.hh:62
gem5::ruby::garnet::flit::print
virtual void print(std::ostream &out) const
Definition: flit.cc:110
intmath.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::ruby::garnet::flit::m_width
uint32_t m_width
Definition: flit.hh:115
gem5::ruby::garnet::flit::serialize
virtual flit * serialize(int ser_id, int parts, uint32_t bWidth)
Definition: flit.cc:77
gem5::ruby::garnet::flit::m_msg_ptr
MsgPtr m_msg_ptr
Definition: flit.hh:127

Generated on Thu Jul 28 2022 13:32:35 for gem5 by doxygen 1.8.17