VirtualChannel.hh revision 12492
12SN/A/*
21762SN/A * Copyright (c) 2008 Princeton University
32SN/A * Copyright (c) 2016 Georgia Institute of Technology
42SN/A * All rights reserved.
52SN/A *
62SN/A * Redistribution and use in source and binary forms, with or without
72SN/A * modification, are permitted provided that the following conditions are
82SN/A * met: redistributions of source code must retain the above copyright
92SN/A * notice, this list of conditions and the following disclaimer;
102SN/A * redistributions in binary form must reproduce the above copyright
112SN/A * notice, this list of conditions and the following disclaimer in the
122SN/A * documentation and/or other materials provided with the distribution;
132SN/A * neither the name of the copyright holders nor the names of its
142SN/A * contributors may be used to endorse or promote products derived from
152SN/A * this software without specific prior written permission.
162SN/A *
172SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272665Ssaidi@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu *
292665Ssaidi@eecs.umich.edu * Authors: Niket Agarwal
302665Ssaidi@eecs.umich.edu *          Tushar Krishna
312SN/A */
322SN/A
332SN/A
342SN/A#ifndef __MEM_RUBY_NETWORK_GARNET2_0_VIRTUALCHANNEL_HH__
352SN/A#define __MEM_RUBY_NETWORK_GARNET2_0_VIRTUALCHANNEL_HH__
362984Sgblack@eecs.umich.edu
372171SN/A#include <utility>
382984Sgblack@eecs.umich.edu
39146SN/A#include "mem/ruby/network/garnet2.0/CommonTypes.hh"
40146SN/A#include "mem/ruby/network/garnet2.0/flitBuffer.hh"
41146SN/A
421858SN/Aclass VirtualChannel
432680Sktlim@umich.edu{
444762Snate@binkert.org  public:
454762Snate@binkert.org    VirtualChannel(int id);
462SN/A    ~VirtualChannel();
472SN/A
481147SN/A    bool need_stage(flit_stage stage, Cycles time);
492SN/A    void set_idle(Cycles curTime);
504088Sbinkertn@umich.edu    void set_active(Cycles curTime);
513838Shsul@eecs.umich.edu    void set_outvc(int outvc)               { m_output_vc = outvc; }
523838Shsul@eecs.umich.edu    inline int get_outvc()                  { return m_output_vc; }
533838Shsul@eecs.umich.edu    void set_outport(int outport)           { m_output_port = outport; };
543838Shsul@eecs.umich.edu    inline int get_outport()                  { return m_output_port; }
55860SN/A
563838Shsul@eecs.umich.edu    inline Cycles get_enqueue_time()          { return m_enqueue_time; }
573838Shsul@eecs.umich.edu    inline void set_enqueue_time(Cycles time) { m_enqueue_time = time; }
58860SN/A    inline VC_state_type get_state()        { return m_vc_state.first; }
59860SN/A
601147SN/A    inline bool isReady(Cycles curTime)
611147SN/A    {
623838Shsul@eecs.umich.edu        return m_input_buffer->isReady(curTime);
633838Shsul@eecs.umich.edu    }
643838Shsul@eecs.umich.edu
653838Shsul@eecs.umich.edu    inline void
663838Shsul@eecs.umich.edu    insertFlit(flit *t_flit)
673838Shsul@eecs.umich.edu    {
682SN/A        m_input_buffer->insert(t_flit);
693838Shsul@eecs.umich.edu    }
703838Shsul@eecs.umich.edu
713838Shsul@eecs.umich.edu    inline void
723838Shsul@eecs.umich.edu    set_state(VC_state_type m_state, Cycles curTime)
733838Shsul@eecs.umich.edu    {
742SN/A        m_vc_state.first = m_state;
753838Shsul@eecs.umich.edu        m_vc_state.second = curTime;
763838Shsul@eecs.umich.edu    }
773838Shsul@eecs.umich.edu
783838Shsul@eecs.umich.edu    inline flit*
793838Shsul@eecs.umich.edu    peekTopFlit()
803838Shsul@eecs.umich.edu    {
812SN/A        return m_input_buffer->peekTopFlit();
823838Shsul@eecs.umich.edu    }
833838Shsul@eecs.umich.edu
843838Shsul@eecs.umich.edu    inline flit*
851413SN/A    getTopFlit()
863453Sgblack@eecs.umich.edu    {
871413SN/A        return m_input_buffer->getTopFlit();
883838Shsul@eecs.umich.edu    }
893838Shsul@eecs.umich.edu
903838Shsul@eecs.umich.edu    uint32_t functionalWrite(Packet *pkt);
911413SN/A
922SN/A  private:
931413SN/A    int m_id;
941413SN/A    flitBuffer *m_input_buffer;
952SN/A    std::pair<VC_state_type, Cycles> m_vc_state;
962SN/A    int m_output_port;
973838Shsul@eecs.umich.edu    Cycles m_enqueue_time;
983838Shsul@eecs.umich.edu    int m_output_vc;
993838Shsul@eecs.umich.edu};
1003838Shsul@eecs.umich.edu
1012SN/A#endif // __MEM_RUBY_NETWORK_GARNET2_0_VIRTUALCHANNEL_HH__
1022SN/A