2 * Copyright (c) 2020 Inria
3 * Copyright (c) 2016 Georgia Institute of Technology
4 * Copyright (c) 2008 Princeton University
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met: redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer;
11 * redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution;
14 * neither the name of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef __MEM_RUBY_NETWORK_GARNET2_0_INPUTUNIT_HH__
33 #define __MEM_RUBY_NETWORK_GARNET2_0_INPUTUNIT_HH__
38 #include "mem/ruby/common/Consumer.hh"
39 #include "mem/ruby/network/garnet2.0/CommonTypes.hh"
40 #include "mem/ruby/network/garnet2.0/CreditLink.hh"
41 #include "mem/ruby/network/garnet2.0/NetworkLink.hh"
42 #include "mem/ruby/network/garnet2.0/Router.hh"
43 #include "mem/ruby/network/garnet2.0/VirtualChannel.hh"
44 #include "mem/ruby/network/garnet2.0/flitBuffer.hh"
46 class InputUnit : public Consumer
49 InputUnit(int id, PortDirection direction, Router *router);
50 ~InputUnit() = default;
53 void print(std::ostream& out) const {};
55 inline PortDirection get_direction() { return m_direction; }
58 set_vc_idle(int vc, Tick curTime)
60 virtualChannels[vc].set_idle(curTime);
64 set_vc_active(int vc, Tick curTime)
66 virtualChannels[vc].set_active(curTime);
70 grant_outport(int vc, int outport)
72 virtualChannels[vc].set_outport(outport);
76 grant_outvc(int vc, int outvc)
78 virtualChannels[vc].set_outvc(outvc);
84 return virtualChannels[invc].get_outport();
90 return virtualChannels[invc].get_outvc();
94 get_enqueue_time(int invc)
96 return virtualChannels[invc].get_enqueue_time();
99 void increment_credit(int in_vc, bool free_signal, Tick curTime);
104 return virtualChannels[vc].peekTopFlit();
110 return virtualChannels[vc].getTopFlit();
114 need_stage(int vc, flit_stage stage, Tick time)
116 return virtualChannels[vc].need_stage(stage, time);
120 isReady(int invc, Tick curTime)
122 return virtualChannels[invc].isReady(curTime);
125 flitBuffer* getCreditQueue() { return &creditQueue; }
128 set_in_link(NetworkLink *link)
133 inline int get_inlink_id() { return m_in_link->get_id(); }
136 set_credit_link(CreditLink *credit_link)
138 m_credit_link = credit_link;
141 double get_buf_read_activity(unsigned int vnet) const
142 { return m_num_buffer_reads[vnet]; }
143 double get_buf_write_activity(unsigned int vnet) const
144 { return m_num_buffer_writes[vnet]; }
146 uint32_t functionalWrite(Packet *pkt);
152 PortDirection m_direction;
154 NetworkLink *m_in_link;
155 CreditLink *m_credit_link;
156 flitBuffer creditQueue;
158 // Input Virtual channels
159 std::vector<VirtualChannel> virtualChannels;
161 // Statistical variables
162 std::vector<double> m_num_buffer_writes;
163 std::vector<double> m_num_buffer_reads;
166 #endif // __MEM_RUBY_NETWORK_GARNET2_0_INPUTUNIT_HH__