gem5  v20.1.0.0
flit.hh
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 
31 #ifndef __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__
32 #define __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__
33 
34 #include <cassert>
35 #include <iostream>
36 
37 #include "base/types.hh"
40 
41 class flit
42 {
43  public:
44  flit() {}
45  flit(int id, int vc, int vnet, RouteInfo route, int size,
46  MsgPtr msg_ptr, int MsgSize, uint32_t bWidth, Tick curTime);
47 
48  virtual ~flit(){};
49 
50  int get_outport() {return m_outport; }
51  int get_size() { return m_size; }
54  int get_id() { return m_id; }
55  Tick get_time() { return m_time; }
56  int get_vnet() { return m_vnet; }
57  int get_vc() { return m_vc; }
58  RouteInfo get_route() { return m_route; }
59  MsgPtr& get_msg_ptr() { return m_msg_ptr; }
60  flit_type get_type() { return m_type; }
63 
64  void set_outport(int port) { m_outport = port; }
65  void set_time(Tick time) { m_time = time; }
66  void set_vc(int vc) { m_vc = vc; }
67  void set_route(RouteInfo route) { m_route = route; }
68  void set_src_delay(Tick delay) { src_delay = delay; }
69  void set_dequeue_time(Tick time) { m_dequeue_time = time; }
70  void set_enqueue_time(Tick time) { m_enqueue_time = time; }
71 
73  virtual void print(std::ostream& out) const;
74 
75  bool
76  is_stage(flit_stage stage, Tick time)
77  {
78  return (stage == m_stage.first &&
79  time >= m_stage.second);
80  }
81 
82  void
83  advance_stage(flit_stage t_stage, Tick newTime)
84  {
85  m_stage.first = t_stage;
86  m_stage.second = newTime;
87  }
88 
89  static bool
90  greater(flit* n1, flit* n2)
91  {
92  if (n1->get_time() == n2->get_time()) {
93  //assert(n1->flit_id != n2->flit_id);
94  return (n1->get_id() > n2->get_id());
95  } else {
96  return (n1->get_time() > n2->get_time());
97  }
98  }
99 
100  bool functionalWrite(Packet *pkt);
101 
102  virtual flit* serialize(int ser_id, int parts, uint32_t bWidth);
103  virtual flit* deserialize(int des_id, int num_flits, uint32_t bWidth);
104 
105  uint32_t m_width;
106  int msgSize;
107  protected:
108  int m_id;
109  int m_vnet;
110  int m_vc;
112  int m_size;
120 };
121 
122 inline std::ostream&
123 operator<<(std::ostream& out, const flit& obj)
124 {
125  obj.print(out);
126  out << std::flush;
127  return out;
128 }
129 
130 #endif // __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__
flit::get_vnet
int get_vnet()
Definition: flit.hh:56
flit::m_msg_ptr
MsgPtr m_msg_ptr
Definition: flit.hh:116
flit::is_stage
bool is_stage(flit_stage stage, Tick time)
Definition: flit.hh:76
flit::get_msg_ptr
MsgPtr & get_msg_ptr()
Definition: flit.hh:59
flit::increment_hops
void increment_hops()
Definition: flit.hh:72
flit
Definition: flit.hh:41
RouteInfo
Definition: CommonTypes.hh:47
flit::m_enqueue_time
Tick m_enqueue_time
Definition: flit.hh:113
flit::get_enqueue_time
Tick get_enqueue_time()
Definition: flit.hh:52
flit::advance_stage
void advance_stage(flit_stage t_stage, Tick newTime)
Definition: flit.hh:83
flit_stage
flit_stage
Definition: CommonTypes.hh:42
flit::get_stage
std::pair< flit_stage, Tick > get_stage()
Definition: flit.hh:61
flit::greater
static bool greater(flit *n1, flit *n2)
Definition: flit.hh:90
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
flit::m_id
int m_id
Definition: flit.hh:108
flit::set_vc
void set_vc(int vc)
Definition: flit.hh:66
CommonTypes.hh
flit::m_outport
int m_outport
Definition: flit.hh:117
flit::get_route
RouteInfo get_route()
Definition: flit.hh:58
flit::set_outport
void set_outport(int port)
Definition: flit.hh:64
flit::get_id
int get_id()
Definition: flit.hh:54
flit::m_time
Tick m_time
Definition: flit.hh:114
flit::get_size
int get_size()
Definition: flit.hh:51
flit::~flit
virtual ~flit()
Definition: flit.hh:48
flit::set_dequeue_time
void set_dequeue_time(Tick time)
Definition: flit.hh:69
flit::set_src_delay
void set_src_delay(Tick delay)
Definition: flit.hh:68
flit::src_delay
Tick src_delay
Definition: flit.hh:118
flit::m_vc
int m_vc
Definition: flit.hh:110
flit::m_type
flit_type m_type
Definition: flit.hh:115
flit::get_time
Tick get_time()
Definition: flit.hh:55
flit::set_route
void set_route(RouteInfo route)
Definition: flit.hh:67
flit::get_type
flit_type get_type()
Definition: flit.hh:60
flit::msgSize
int msgSize
Definition: flit.hh:106
flit::get_outport
int get_outport()
Definition: flit.hh:50
std::pair< flit_stage, Tick >
flit::get_dequeue_time
Tick get_dequeue_time()
Definition: flit.hh:53
operator<<
std::ostream & operator<<(std::ostream &out, const flit &obj)
Definition: flit.hh:123
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::set_time
void set_time(Tick time)
Definition: flit.hh:65
flit::print
virtual void print(std::ostream &out) const
Definition: flit.cc:100
flit::get_vc
int get_vc()
Definition: flit.hh:57
flit::m_dequeue_time
Tick m_dequeue_time
Definition: flit.hh:113
types.hh
flit::get_src_delay
Tick get_src_delay()
Definition: flit.hh:62
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
flit::functionalWrite
bool functionalWrite(Packet *pkt)
Definition: flit.cc:118
flit::m_size
int m_size
Definition: flit.hh:112
flit_type
flit_type
Definition: CommonTypes.hh:38
RouteInfo::hops_traversed
int hops_traversed
Definition: CommonTypes.hh:63
Message.hh
flit::serialize
virtual flit * serialize(int ser_id, int parts, uint32_t bWidth)
Definition: flit.cc:67
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