gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Authors: Niket Agarwal
30  * Tushar Krishna
31  */
32 
33 
34 #ifndef __MEM_RUBY_NETWORK_GARNET_FLIT_HH__
35 #define __MEM_RUBY_NETWORK_GARNET_FLIT_HH__
36 
37 #include <cassert>
38 #include <iostream>
39 
40 #include "base/types.hh"
43 
44 class flit
45 {
46  public:
47  flit() {}
48  flit(int id, int vc, int vnet, RouteInfo route, int size,
49  MsgPtr msg_ptr, Cycles curTime);
50 
51  int get_outport() {return m_outport; }
52  int get_size() { return m_size; }
55  int get_id() { return m_id; }
56  Cycles get_time() { return m_time; }
57  int get_vnet() { return m_vnet; }
58  int get_vc() { return m_vc; }
59  RouteInfo get_route() { return m_route; }
60  MsgPtr& get_msg_ptr() { return m_msg_ptr; }
61  flit_type get_type() { return m_type; }
64 
65  void set_outport(int port) { m_outport = port; }
66  void set_time(Cycles time) { m_time = time; }
67  void set_vc(int vc) { m_vc = vc; }
68  void set_route(RouteInfo route) { m_route = route; }
69  void set_src_delay(Cycles delay) { src_delay = delay; }
70  void set_dequeue_time(Cycles time) { m_dequeue_time = time; }
71 
73  void print(std::ostream& out) const;
74 
75  bool
76  is_stage(flit_stage stage, Cycles time)
77  {
78  return (stage == m_stage.first &&
79  time >= m_stage.second);
80  }
81 
82  void
83  advance_stage(flit_stage t_stage, Cycles 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  protected:
103  int m_id;
104  int m_vnet;
105  int m_vc;
107  int m_size;
114 };
115 
116 inline std::ostream&
117 operator<<(std::ostream& out, const flit& obj)
118 {
119  obj.print(out);
120  out << std::flush;
121  return out;
122 }
123 
124 #endif // __MEM_RUBY_NETWORK_GARNET_FLIT_HH__
void set_dequeue_time(Cycles time)
Definition: flit.hh:70
void set_time(Cycles time)
Definition: flit.hh:66
void set_outport(int port)
Definition: flit.hh:65
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
int get_vc()
Definition: flit.hh:58
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:40
int get_size()
Definition: flit.hh:52
void set_route(RouteInfo route)
Definition: flit.hh:68
int get_outport()
Definition: flit.hh:51
int m_vc
Definition: flit.hh:105
Cycles m_enqueue_time
Definition: flit.hh:108
std::pair< flit_stage, Cycles > m_stage
Definition: flit.hh:113
flit()
Definition: flit.hh:47
MsgPtr m_msg_ptr
Definition: flit.hh:110
flit_type
Definition: CommonTypes.hh:41
Definition: flit.hh:44
Cycles m_dequeue_time
Definition: flit.hh:108
std::pair< flit_stage, Cycles > get_stage()
Definition: flit.hh:62
int m_id
Definition: flit.hh:103
void set_src_delay(Cycles delay)
Definition: flit.hh:69
int m_vnet
Definition: flit.hh:104
bool functionalWrite(Packet *pkt)
Definition: flit.cc:82
Cycles get_src_delay()
Definition: flit.hh:63
int m_size
Definition: flit.hh:107
Cycles get_dequeue_time()
Definition: flit.hh:54
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
void set_vc(int vc)
Definition: flit.hh:67
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
bool is_stage(flit_stage stage, Cycles time)
Definition: flit.hh:76
int get_vnet()
Definition: flit.hh:57
Cycles get_enqueue_time()
Definition: flit.hh:53
void increment_hops()
Definition: flit.hh:72
MsgPtr & get_msg_ptr()
Definition: flit.hh:60
int get_id()
Definition: flit.hh:55
int size()
Definition: pagetable.hh:146
flit_stage
Definition: CommonTypes.hh:44
Cycles m_time
Definition: flit.hh:108
std::ostream & operator<<(std::ostream &out, const flit &obj)
Definition: flit.hh:117
void print(std::ostream &out) const
Definition: flit.cc:66
Cycles get_time()
Definition: flit.hh:56
void advance_stage(flit_stage t_stage, Cycles newTime)
Definition: flit.hh:83
flit_type get_type()
Definition: flit.hh:61
static bool greater(flit *n1, flit *n2)
Definition: flit.hh:90
flit_type m_type
Definition: flit.hh:109
int hops_traversed
Definition: CommonTypes.hh:60
int m_outport
Definition: flit.hh:111
RouteInfo get_route()
Definition: flit.hh:59
Cycles src_delay
Definition: flit.hh:112
RouteInfo m_route
Definition: flit.hh:106

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6