includes: sort all includes
[gem5.git] / src / mem / ruby / network / garnet / fixed-pipeline / VirtualChannel_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_VIRTUAL_CHANNEL_D_HH__
32 #define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VIRTUAL_CHANNEL_D_HH__
33
34 #include <utility>
35
36 #include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
37 #include "mem/ruby/network/garnet/NetworkHeader.hh"
38
39 class VirtualChannel_d
40 {
41 public:
42 VirtualChannel_d(int id);
43 ~VirtualChannel_d();
44
45 bool need_stage(VC_state_type state, flit_stage stage);
46 bool need_stage_nextcycle(VC_state_type state, flit_stage stage);
47 void set_outport(int outport);
48 void grant_vc(int out_vc);
49
50 inline Time get_enqueue_time() { return m_enqueue_time; }
51 inline void set_enqueue_time(Time time) { m_enqueue_time = time; }
52 inline VC_state_type get_state() { return m_vc_state.first; }
53 inline int get_outvc() { return m_output_vc; }
54 inline bool has_credits() { return (m_credit_count > 0); }
55 inline int get_route() { return route; }
56 inline void update_credit(int credit) { m_credit_count = credit; }
57 inline void increment_credit() { m_credit_count++; }
58
59 inline bool isReady() { return m_input_buffer->isReady(); }
60
61 inline void
62 insertFlit(flit_d *t_flit)
63 {
64 m_input_buffer->insert(t_flit);
65 }
66
67 inline void
68 set_state(VC_state_type m_state)
69 {
70 m_vc_state.first = m_state;
71 m_vc_state.second = g_eventQueue_ptr->getTime() + 1;
72 }
73
74 inline flit_d*
75 peekTopFlit()
76 {
77 return m_input_buffer->peekTopFlit();
78 }
79
80 inline flit_d*
81 getTopFlit()
82 {
83 return m_input_buffer->getTopFlit();
84 }
85
86 private:
87 int m_id;
88 flitBuffer_d *m_input_buffer;
89 std::pair<VC_state_type, Time> m_vc_state; // I/R/V/A/C
90 int route;
91 Time m_enqueue_time;
92 int m_output_vc;
93 int m_credit_count;
94 };
95
96 #endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VIRTUAL_CHANNEL_D_HH__