gem5  v20.1.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 // Constructor for the flit
37 flit::flit(int id, int vc, int vnet, RouteInfo route, int size,
38  MsgPtr msg_ptr, int MsgSize, uint32_t bWidth, Tick curTime)
39 {
40  m_size = size;
41  m_msg_ptr = msg_ptr;
42  m_enqueue_time = curTime;
43  m_dequeue_time = curTime;
44  m_time = curTime;
45  m_id = id;
46  m_vnet = vnet;
47  m_vc = vc;
48  m_route = route;
49  m_stage.first = I_;
50  m_stage.second = curTime;
51  m_width = bWidth;
52  msgSize = MsgSize;
53 
54  if (size == 1) {
56  return;
57  }
58  if (id == 0)
59  m_type = HEAD_;
60  else if (id == (size - 1))
61  m_type = TAIL_;
62  else
63  m_type = BODY_;
64 }
65 
66 flit *
67 flit::serialize(int ser_id, int parts, uint32_t bWidth)
68 {
69  assert(m_width > bWidth);
70 
71  int ratio = (int)divCeil(m_width, bWidth);
72  int new_id = (m_id*ratio) + ser_id;
73  int new_size = (int)divCeil((float)msgSize, (float)bWidth);
74  assert(new_id < new_size);
75 
76  flit *fl = new flit(new_id, m_vc, m_vnet, m_route,
77  new_size, m_msg_ptr, msgSize, bWidth, m_time);
80  return fl;
81 }
82 
83 flit *
84 flit::deserialize(int des_id, int num_flits, uint32_t bWidth)
85 {
86  int ratio = (int)divCeil((float)bWidth, (float)m_width);
87  int new_id = ((int)divCeil((float)(m_id+1), (float)ratio)) - 1;
88  int new_size = (int)divCeil((float)msgSize, (float)bWidth);
89  assert(new_id < new_size);
90 
91  flit *fl = new flit(new_id, m_vc, m_vnet, m_route,
92  new_size, m_msg_ptr, msgSize, bWidth, m_time);
95  return fl;
96 }
97 
98 // Flit can be printed out for debugging purposes
99 void
100 flit::print(std::ostream& out) const
101 {
102  out << "[flit:: ";
103  out << "Id=" << m_id << " ";
104  out << "Type=" << m_type << " ";
105  out << "Size=" << m_size << " ";
106  out << "Vnet=" << m_vnet << " ";
107  out << "VC=" << m_vc << " ";
108  out << "Src NI=" << m_route.src_ni << " ";
109  out << "Src Router=" << m_route.src_router << " ";
110  out << "Dest NI=" << m_route.dest_ni << " ";
111  out << "Dest Router=" << m_route.dest_router << " ";
112  out << "Set Time=" << m_time << " ";
113  out << "Width=" << m_width<< " ";
114  out << "]";
115 }
116 
117 bool
119 {
120  Message *msg = m_msg_ptr.get();
121  return msg->functionalWrite(pkt);
122 }
flit::m_msg_ptr
MsgPtr m_msg_ptr
Definition: flit.hh:116
RouteInfo::dest_ni
int dest_ni
Definition: CommonTypes.hh:61
flit
Definition: flit.hh:41
RouteInfo
Definition: CommonTypes.hh:47
flit::m_enqueue_time
Tick m_enqueue_time
Definition: flit.hh:113
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
flit::m_id
int m_id
Definition: flit.hh:108
I_
@ I_
Definition: CommonTypes.hh:42
flit::m_time
Tick m_time
Definition: flit.hh:114
divCeil
T divCeil(const T &a, const U &b)
Definition: intmath.hh:114
flit::set_src_delay
void set_src_delay(Tick delay)
Definition: flit.hh:68
RouteInfo::src_router
int src_router
Definition: CommonTypes.hh:60
flit::src_delay
Tick src_delay
Definition: flit.hh:118
flit::m_vc
int m_vc
Definition: flit.hh:110
RouteInfo::src_ni
int src_ni
Definition: CommonTypes.hh:59
flit::m_type
flit_type m_type
Definition: flit.hh:115
HEAD_
@ HEAD_
Definition: CommonTypes.hh:38
flit::msgSize
int msgSize
Definition: flit.hh:106
flit.hh
BODY_
@ BODY_
Definition: CommonTypes.hh:38
flit::m_stage
std::pair< flit_stage, Tick > m_stage
Definition: flit.hh:119
MsgPtr
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:40
flit::m_route
RouteInfo m_route
Definition: flit.hh:111
flit::print
virtual void print(std::ostream &out) const
Definition: flit.cc:100
TAIL_
@ TAIL_
Definition: CommonTypes.hh:38
flit::m_dequeue_time
Tick m_dequeue_time
Definition: flit.hh:113
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
flit::deserialize
virtual flit * deserialize(int des_id, int num_flits, uint32_t bWidth)
Definition: flit.cc:84
flit::m_vnet
int m_vnet
Definition: flit.hh:109
flit::set_enqueue_time
void set_enqueue_time(Tick time)
Definition: flit.hh:70
RouteInfo::dest_router
int dest_router
Definition: CommonTypes.hh:62
flit::functionalWrite
bool functionalWrite(Packet *pkt)
Definition: flit.cc:118
Message
Definition: Message.hh:43
HEAD_TAIL_
@ HEAD_TAIL_
Definition: CommonTypes.hh:38
flit::m_size
int m_size
Definition: flit.hh:112
intmath.hh
flit::serialize
virtual flit * serialize(int ser_id, int parts, uint32_t bWidth)
Definition: flit.cc:67
ArmISA::id
Bitfield< 33 > id
Definition: miscregs_types.hh:247
Message::functionalWrite
virtual bool functionalWrite(Packet *pkt)=0
flit::m_width
uint32_t m_width
Definition: flit.hh:105
flit::flit
flit()
Definition: flit.hh:44

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17