Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 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. |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | |
Srikant Bharadwaj | 7957b1c | 2020-09-10 03:39:45 -0400 | [diff] [blame] | 31 | #ifndef __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__ |
| 32 | #define __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__ |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 33 | |
| 34 | #include <cassert> |
| 35 | #include <iostream> |
| 36 | |
| 37 | #include "base/types.hh" |
Srikant Bharadwaj | 7957b1c | 2020-09-10 03:39:45 -0400 | [diff] [blame] | 38 | #include "mem/ruby/network/garnet/CommonTypes.hh" |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 39 | #include "mem/ruby/slicc_interface/Message.hh" |
| 40 | |
Daniel R. Carvalho | 974a47d | 2021-05-09 12:32:07 -0300 | [diff] [blame] | 41 | namespace gem5 |
| 42 | { |
| 43 | |
Daniel R. Carvalho | 60e4ad9 | 2021-06-12 09:47:31 -0300 | [diff] [blame] | 44 | namespace ruby |
| 45 | { |
| 46 | |
Daniel R. Carvalho | 00cd307 | 2021-06-12 09:27:02 -0300 | [diff] [blame] | 47 | namespace garnet |
| 48 | { |
| 49 | |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 50 | class flit |
| 51 | { |
| 52 | public: |
| 53 | flit() {} |
| 54 | flit(int id, int vc, int vnet, RouteInfo route, int size, |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 55 | MsgPtr msg_ptr, int MsgSize, uint32_t bWidth, Tick curTime); |
| 56 | |
| 57 | virtual ~flit(){}; |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 58 | |
| 59 | int get_outport() {return m_outport; } |
| 60 | int get_size() { return m_size; } |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 61 | Tick get_enqueue_time() { return m_enqueue_time; } |
| 62 | Tick get_dequeue_time() { return m_dequeue_time; } |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 63 | int get_id() { return m_id; } |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 64 | Tick get_time() { return m_time; } |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 65 | 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 Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 70 | std::pair<flit_stage, Tick> get_stage() { return m_stage; } |
| 71 | Tick get_src_delay() { return src_delay; } |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 72 | |
| 73 | void set_outport(int port) { m_outport = port; } |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 74 | void set_time(Tick time) { m_time = time; } |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 75 | void set_vc(int vc) { m_vc = vc; } |
| 76 | void set_route(RouteInfo route) { m_route = route; } |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 77 | 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 Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 80 | |
| 81 | void increment_hops() { m_route.hops_traversed++; } |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 82 | virtual void print(std::ostream& out) const; |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 83 | |
| 84 | bool |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 85 | is_stage(flit_stage stage, Tick time) |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 86 | { |
| 87 | return (stage == m_stage.first && |
| 88 | time >= m_stage.second); |
| 89 | } |
| 90 | |
| 91 | void |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 92 | advance_stage(flit_stage t_stage, Tick newTime) |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 93 | { |
| 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 Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 111 | 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 Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 116 | protected: |
| 117 | int m_id; |
| 118 | int m_vnet; |
| 119 | int m_vc; |
| 120 | RouteInfo m_route; |
| 121 | int m_size; |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 122 | Tick m_enqueue_time, m_dequeue_time; |
| 123 | Tick m_time; |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 124 | flit_type m_type; |
| 125 | MsgPtr m_msg_ptr; |
| 126 | int m_outport; |
Srikant Bharadwaj | b9f1c71 | 2018-07-19 13:34:24 -0400 | [diff] [blame] | 127 | Tick src_delay; |
| 128 | std::pair<flit_stage, Tick> m_stage; |
Tushar Krishna | dbe8892 | 2016-10-06 14:35:22 -0400 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | inline std::ostream& |
| 132 | operator<<(std::ostream& out, const flit& obj) |
| 133 | { |
| 134 | obj.print(out); |
| 135 | out << std::flush; |
| 136 | return out; |
| 137 | } |
| 138 | |
Daniel R. Carvalho | 00cd307 | 2021-06-12 09:27:02 -0300 | [diff] [blame] | 139 | } // namespace garnet |
Daniel R. Carvalho | 60e4ad9 | 2021-06-12 09:47:31 -0300 | [diff] [blame] | 140 | } // namespace ruby |
Daniel R. Carvalho | 974a47d | 2021-05-09 12:32:07 -0300 | [diff] [blame] | 141 | } // namespace gem5 |
| 142 | |
Srikant Bharadwaj | 7957b1c | 2020-09-10 03:39:45 -0400 | [diff] [blame] | 143 | #endif // __MEM_RUBY_NETWORK_GARNET_0_FLIT_HH__ |