gem5  v21.2.0.0
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 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_id = id;
55  m_vnet = vnet;
56  m_vc = vc;
57  m_route = route;
58  m_stage.first = I_;
59  m_stage.second = curTime;
60  m_width = bWidth;
61  msgSize = MsgSize;
62 
63  if (size == 1) {
65  return;
66  }
67  if (id == 0)
68  m_type = HEAD_;
69  else if (id == (size - 1))
70  m_type = TAIL_;
71  else
72  m_type = BODY_;
73 }
74 
75 flit *
76 flit::serialize(int ser_id, int parts, uint32_t bWidth)
77 {
78  assert(m_width > bWidth);
79 
80  int ratio = (int)divCeil(m_width, bWidth);
81  int new_id = (m_id*ratio) + ser_id;
82  int new_size = (int)divCeil((float)msgSize, (float)bWidth);
83  assert(new_id < new_size);
84 
85  flit *fl = new flit(new_id, m_vc, m_vnet, m_route,
86  new_size, m_msg_ptr, msgSize, bWidth, m_time);
89  return fl;
90 }
91 
92 flit *
93 flit::deserialize(int des_id, int num_flits, uint32_t bWidth)
94 {
95  int ratio = (int)divCeil((float)bWidth, (float)m_width);
96  int new_id = ((int)divCeil((float)(m_id+1), (float)ratio)) - 1;
97  int new_size = (int)divCeil((float)msgSize, (float)bWidth);
98  assert(new_id < new_size);
99 
100  flit *fl = new flit(new_id, m_vc, m_vnet, m_route,
101  new_size, m_msg_ptr, msgSize, bWidth, m_time);
104  return fl;
105 }
106 
107 // Flit can be printed out for debugging purposes
108 void
109 flit::print(std::ostream& out) const
110 {
111  out << "[flit:: ";
112  out << "Id=" << m_id << " ";
113  out << "Type=" << m_type << " ";
114  out << "Size=" << m_size << " ";
115  out << "Vnet=" << m_vnet << " ";
116  out << "VC=" << m_vc << " ";
117  out << "Src NI=" << m_route.src_ni << " ";
118  out << "Src Router=" << m_route.src_router << " ";
119  out << "Dest NI=" << m_route.dest_ni << " ";
120  out << "Dest Router=" << m_route.dest_router << " ";
121  out << "Set Time=" << m_time << " ";
122  out << "Width=" << m_width<< " ";
123  out << "]";
124 }
125 
126 bool
128 {
129  Message *msg = m_msg_ptr.get();
130  return msg->functionalWrite(pkt);
131 }
132 
133 } // namespace garnet
134 } // namespace ruby
135 } // namespace gem5
gem5::ruby::garnet::flit
Definition: flit.hh:50
gem5::ruby::garnet::flit::src_delay
Tick src_delay
Definition: flit.hh:127
gem5::ruby::garnet::flit::m_route
RouteInfo m_route
Definition: flit.hh:120
gem5::ruby::garnet::flit::functionalWrite
bool functionalWrite(Packet *pkt)
Definition: flit.cc:127
gem5::ruby::MsgPtr
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:59
gem5::ruby::garnet::flit::m_size
int m_size
Definition: flit.hh:121
gem5::ruby::garnet::flit::m_vc
int m_vc
Definition: flit.hh:119
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:122
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:93
gem5::ruby::garnet::flit::msgSize
int msgSize
Definition: flit.hh:115
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:128
gem5::ruby::garnet::flit::set_src_delay
void set_src_delay(Tick delay)
Definition: flit.hh:77
gem5::ruby::garnet::flit::m_vnet
int m_vnet
Definition: flit.hh:118
gem5::ruby::garnet::flit::set_enqueue_time
void set_enqueue_time(Tick time)
Definition: flit.hh:79
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:283
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:123
gem5::ruby::garnet::flit::m_id
int m_id
Definition: flit.hh:117
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:124
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:122
gem5::ruby::Message
Definition: Message.hh:62
gem5::ruby::garnet::flit::print
virtual void print(std::ostream &out) const
Definition: flit.cc:109
intmath.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::ruby::garnet::flit::m_width
uint32_t m_width
Definition: flit.hh:114
gem5::ruby::garnet::flit::serialize
virtual flit * serialize(int ser_id, int parts, uint32_t bWidth)
Definition: flit.cc:76
gem5::ruby::garnet::flit::m_msg_ptr
MsgPtr m_msg_ptr
Definition: flit.hh:125

Generated on Tue Dec 21 2021 11:34:33 for gem5 by doxygen 1.8.17