includes: sort all includes
[gem5.git] / src / mem / ruby / network / garnet / fixed-pipeline / OutVcState_d.hh
1 /*
2 * Copyright (c) 2008 Princeton University
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Niket Agarwal
29 */
30
31 #ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUT_VC_STATE_D_HH__
32 #define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUT_VC_STATE_D_HH__
33
34 #include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
35 #include "mem/ruby/network/garnet/NetworkHeader.hh"
36
37 class OutVcState_d
38 {
39 public:
40 OutVcState_d(int id, GarnetNetwork_d *network_ptr);
41
42 int get_inport() { return m_in_port; }
43 int get_invc() { return m_in_vc; }
44 int get_credit_count() { return m_credit_count; }
45 void
46 set_credit_count()
47 {
48 // only need to initialize credit count for data VCs
49 // constructor sets this to BuffersPerCtrlVC by default
50
51 if (m_network_ptr->get_vnet_type(m_id) == DATA_VNET_)
52 m_credit_count = m_network_ptr->getBuffersPerDataVC();
53 }
54
55 void set_inport(int port) { m_in_port = port; }
56 void set_invc(int vc) { m_in_vc = vc; }
57 inline bool
58 isInState(VC_state_type state, Time request_time)
59 {
60 return ((m_vc_state == state) && (request_time >= m_time) );
61 }
62 inline void
63 setState(VC_state_type state, Time time)
64 {
65 m_vc_state = state;
66 m_time = time;
67 }
68 inline bool has_credits() { return (m_credit_count > 0); }
69 inline void increment_credit() { m_credit_count++; }
70 inline void decrement_credit() { m_credit_count--; }
71
72 private:
73 GarnetNetwork_d *m_network_ptr;
74 int m_id ;
75 Time m_time;
76 VC_state_type m_vc_state;
77 int m_in_port;
78 int m_in_vc;
79 int m_credit_count;
80 };
81
82 #endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUT_VC_STATE_D_HH__