gem5  v22.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 namespace gem5
42 {
43 
44 namespace ruby
45 {
46 
47 namespace garnet
48 {
49 
50 class flit
51 {
52  public:
53  flit() {}
54  flit(int packet_id, int id, int vc, int vnet, RouteInfo route, int size,
55  MsgPtr msg_ptr, int MsgSize, uint32_t bWidth, Tick curTime);
56 
57  virtual ~flit(){};
58 
59  int get_outport() {return m_outport; }
60  int get_size() { return m_size; }
63  int getPacketID() { return m_packet_id; }
64  int get_id() { return m_id; }
65  Tick get_time() { return m_time; }
66  int get_vnet() { return m_vnet; }
67  int get_vc() { return m_vc; }
68  RouteInfo get_route() { return m_route; }
69  MsgPtr& get_msg_ptr() { return m_msg_ptr; }
70  flit_type get_type() { return m_type; }
73 
74  void set_outport(int port) { m_outport = port; }
75  void set_time(Tick time) { m_time = time; }
76  void set_vc(int vc) { m_vc = vc; }
77  void set_route(RouteInfo route) { m_route = route; }
78  void set_src_delay(Tick delay) { src_delay = delay; }
79  void set_dequeue_time(Tick time) { m_dequeue_time = time; }
80  void set_enqueue_time(Tick time) { m_enqueue_time = time; }
81 
83  virtual void print(std::ostream& out) const;
84 
85  bool
86  is_stage(flit_stage stage, Tick time)
87  {
88  return (stage == m_stage.first &&
89  time >= m_stage.second);
90  }
91 
92  void
93  advance_stage(flit_stage t_stage, Tick newTime)
94  {
95  m_stage.first = t_stage;
96  m_stage.second = newTime;
97  }
98 
99  static bool
100  greater(flit* n1, flit* n2)
101  {
102  if (n1->get_time() == n2->get_time()) {
103  //assert(n1->flit_id != n2->flit_id);
104  return (n1->get_id() > n2->get_id());
105  } else {
106  return (n1->get_time() > n2->get_time());
107  }
108  }
109 
110  bool functionalRead(Packet *pkt, WriteMask &mask);
111  bool functionalWrite(Packet *pkt);
112 
113  virtual flit* serialize(int ser_id, int parts, uint32_t bWidth);
114  virtual flit* deserialize(int des_id, int num_flits, uint32_t bWidth);
115 
116  uint32_t m_width;
117  int msgSize;
118  protected:
120  int m_id;
121  int m_vnet;
122  int m_vc;
124  int m_size;
132 };
133 
134 inline std::ostream&
135 operator<<(std::ostream& out, const flit& obj)
136 {
137  obj.print(out);
138  out << std::flush;
139  return out;
140 }
141 
142 } // namespace garnet
143 } // namespace ruby
144 } // namespace gem5
145 
146 #endif // __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
RouteInfo get_route()
Definition: flit.hh:68
bool functionalWrite(Packet *pkt)
Definition: flit.cc:136
void set_time(Tick time)
Definition: flit.hh:75
Tick get_enqueue_time()
Definition: flit.hh:61
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
Tick get_dequeue_time()
Definition: flit.hh:62
void set_enqueue_time(Tick time)
Definition: flit.hh:80
bool is_stage(flit_stage stage, Tick time)
Definition: flit.hh:86
virtual void print(std::ostream &out) const
Definition: flit.cc:110
std::pair< flit_stage, Tick > get_stage()
Definition: flit.hh:71
static bool greater(flit *n1, flit *n2)
Definition: flit.hh:100
void set_dequeue_time(Tick time)
Definition: flit.hh:79
flit_type get_type()
Definition: flit.hh:70
void advance_stage(flit_stage t_stage, Tick newTime)
Definition: flit.hh:93
void set_outport(int port)
Definition: flit.hh:74
void set_vc(int vc)
Definition: flit.hh:76
MsgPtr & get_msg_ptr()
Definition: flit.hh:69
bool functionalRead(Packet *pkt, WriteMask &mask)
Definition: flit.cc:129
std::pair< flit_stage, Tick > m_stage
Definition: flit.hh:131
void set_route(RouteInfo route)
Definition: flit.hh:77
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
std::ostream & operator<<(std::ostream &out, const flit &obj)
Definition: flit.hh:135
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:59
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Tick
Tick count type.
Definition: types.hh:58

Generated on Wed Dec 21 2022 10:22:38 for gem5 by doxygen 1.9.1