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_OUTPUTUNIT_HH__
33 #define __MEM_RUBY_NETWORK_GARNET2_0_OUTPUTUNIT_HH__
38 #include "base/compiler.hh"
39 #include "mem/ruby/common/Consumer.hh"
40 #include "mem/ruby/network/garnet2.0/CommonTypes.hh"
41 #include "mem/ruby/network/garnet2.0/NetworkLink.hh"
42 #include "mem/ruby/network/garnet2.0/OutVcState.hh"
47 class OutputUnit : public Consumer
50 OutputUnit(int id, PortDirection direction, Router *router,
51 uint32_t consumerVcs);
52 ~OutputUnit() = default;
53 void set_out_link(NetworkLink *link);
54 void set_credit_link(CreditLink *credit_link);
56 flitBuffer* getOutQueue();
57 void print(std::ostream& out) const {};
58 void decrement_credit(int out_vc);
59 void increment_credit(int out_vc);
60 bool has_credit(int out_vc);
61 bool has_free_vc(int vnet);
62 int select_free_vc(int vnet);
64 inline PortDirection get_direction() { return m_direction; }
67 get_credit_count(int vc)
69 return outVcState[vc].get_credit_count();
75 return m_out_link->get_id();
79 set_vc_state(VC_state_type state, int vc, Tick curTime)
81 outVcState[vc].setState(state, curTime);
85 is_vc_idle(int vc, Tick curTime)
87 return (outVcState[vc].isInState(IDLE_, curTime));
90 void insert_flit(flit *t_flit);
98 uint32_t functionalWrite(Packet *pkt);
102 int M5_CLASS_VAR_USED m_id;
103 PortDirection m_direction;
105 NetworkLink *m_out_link;
106 CreditLink *m_credit_link;
108 // This is for the network link to consume
109 flitBuffer outBuffer;
110 // vc state of downstream router
111 std::vector<OutVcState> outVcState;
114 #endif // __MEM_RUBY_NETWORK_GARNET2_0_OUTPUTUNIT_HH__