blob: 8814d3c281790b5b0109082d8860d42b1a415eba [file] [log] [blame]
Tushar Krishnadbe88922016-10-06 14:35:22 -04001/*
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.
Tushar Krishnadbe88922016-10-06 14:35:22 -040028 */
29
30
Srikant Bharadwaj7957b1c2020-09-10 03:39:45 -040031#ifndef __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__
32#define __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__
Tushar Krishnadbe88922016-10-06 14:35:22 -040033
34#include <cassert>
35#include <iostream>
36
37#include "base/types.hh"
Srikant Bharadwaj7957b1c2020-09-10 03:39:45 -040038#include "mem/ruby/network/garnet/CommonTypes.hh"
Tushar Krishnadbe88922016-10-06 14:35:22 -040039#include "mem/ruby/slicc_interface/Message.hh"
40
Daniel R. Carvalho974a47d2021-05-09 12:32:07 -030041namespace gem5
42{
43
Daniel R. Carvalho60e4ad92021-06-12 09:47:31 -030044namespace ruby
45{
46
Daniel R. Carvalho00cd3072021-06-12 09:27:02 -030047namespace garnet
48{
49
Tushar Krishnadbe88922016-10-06 14:35:22 -040050class flit
51{
52 public:
53 flit() {}
54 flit(int id, int vc, int vnet, RouteInfo route, int size,
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -040055 MsgPtr msg_ptr, int MsgSize, uint32_t bWidth, Tick curTime);
56
57 virtual ~flit(){};
Tushar Krishnadbe88922016-10-06 14:35:22 -040058
59 int get_outport() {return m_outport; }
60 int get_size() { return m_size; }
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -040061 Tick get_enqueue_time() { return m_enqueue_time; }
62 Tick get_dequeue_time() { return m_dequeue_time; }
Tushar Krishnadbe88922016-10-06 14:35:22 -040063 int get_id() { return m_id; }
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -040064 Tick get_time() { return m_time; }
Tushar Krishnadbe88922016-10-06 14:35:22 -040065 int get_vnet() { return m_vnet; }
66 int get_vc() { return m_vc; }
67 RouteInfo get_route() { return m_route; }
68 MsgPtr& get_msg_ptr() { return m_msg_ptr; }
69 flit_type get_type() { return m_type; }
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -040070 std::pair<flit_stage, Tick> get_stage() { return m_stage; }
71 Tick get_src_delay() { return src_delay; }
Tushar Krishnadbe88922016-10-06 14:35:22 -040072
73 void set_outport(int port) { m_outport = port; }
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -040074 void set_time(Tick time) { m_time = time; }
Tushar Krishnadbe88922016-10-06 14:35:22 -040075 void set_vc(int vc) { m_vc = vc; }
76 void set_route(RouteInfo route) { m_route = route; }
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -040077 void set_src_delay(Tick delay) { src_delay = delay; }
78 void set_dequeue_time(Tick time) { m_dequeue_time = time; }
79 void set_enqueue_time(Tick time) { m_enqueue_time = time; }
Tushar Krishnadbe88922016-10-06 14:35:22 -040080
81 void increment_hops() { m_route.hops_traversed++; }
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -040082 virtual void print(std::ostream& out) const;
Tushar Krishnadbe88922016-10-06 14:35:22 -040083
84 bool
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -040085 is_stage(flit_stage stage, Tick time)
Tushar Krishnadbe88922016-10-06 14:35:22 -040086 {
87 return (stage == m_stage.first &&
88 time >= m_stage.second);
89 }
90
91 void
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -040092 advance_stage(flit_stage t_stage, Tick newTime)
Tushar Krishnadbe88922016-10-06 14:35:22 -040093 {
94 m_stage.first = t_stage;
95 m_stage.second = newTime;
96 }
97
98 static bool
99 greater(flit* n1, flit* n2)
100 {
101 if (n1->get_time() == n2->get_time()) {
102 //assert(n1->flit_id != n2->flit_id);
103 return (n1->get_id() > n2->get_id());
104 } else {
105 return (n1->get_time() > n2->get_time());
106 }
107 }
108
109 bool functionalWrite(Packet *pkt);
110
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -0400111 virtual flit* serialize(int ser_id, int parts, uint32_t bWidth);
112 virtual flit* deserialize(int des_id, int num_flits, uint32_t bWidth);
113
114 uint32_t m_width;
115 int msgSize;
Tushar Krishnadbe88922016-10-06 14:35:22 -0400116 protected:
117 int m_id;
118 int m_vnet;
119 int m_vc;
120 RouteInfo m_route;
121 int m_size;
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -0400122 Tick m_enqueue_time, m_dequeue_time;
123 Tick m_time;
Tushar Krishnadbe88922016-10-06 14:35:22 -0400124 flit_type m_type;
125 MsgPtr m_msg_ptr;
126 int m_outport;
Srikant Bharadwajb9f1c712018-07-19 13:34:24 -0400127 Tick src_delay;
128 std::pair<flit_stage, Tick> m_stage;
Tushar Krishnadbe88922016-10-06 14:35:22 -0400129};
130
131inline std::ostream&
132operator<<(std::ostream& out, const flit& obj)
133{
134 obj.print(out);
135 out << std::flush;
136 return out;
137}
138
Daniel R. Carvalho00cd3072021-06-12 09:27:02 -0300139} // namespace garnet
Daniel R. Carvalho60e4ad92021-06-12 09:47:31 -0300140} // namespace ruby
Daniel R. Carvalho974a47d2021-05-09 12:32:07 -0300141} // namespace gem5
142
Srikant Bharadwaj7957b1c2020-09-10 03:39:45 -0400143#endif // __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__