VirtualChannel.hh revision 11666:10d59d546ea2
16657SN/A/*
26657SN/A * Copyright (c) 2008 Princeton University
36657SN/A * Copyright (c) 2016 Georgia Institute of Technology
46657SN/A * All rights reserved.
56657SN/A *
66657SN/A * Redistribution and use in source and binary forms, with or without
76657SN/A * modification, are permitted provided that the following conditions are
86657SN/A * met: redistributions of source code must retain the above copyright
96657SN/A * notice, this list of conditions and the following disclaimer;
106657SN/A * redistributions in binary form must reproduce the above copyright
116657SN/A * notice, this list of conditions and the following disclaimer in the
126657SN/A * documentation and/or other materials provided with the distribution;
136657SN/A * neither the name of the copyright holders nor the names of its
146657SN/A * contributors may be used to endorse or promote products derived from
156657SN/A * this software without specific prior written permission.
166657SN/A *
176657SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186657SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196657SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206657SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216657SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226657SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236657SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246657SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256657SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266657SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276657SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286657SN/A *
296657SN/A * Authors: Niket Agarwal
306657SN/A *          Tushar Krishna
316657SN/A */
326657SN/A
336657SN/A
346657SN/A#ifndef __MEM_RUBY_NETWORK_GARNET_VIRTUAL_CHANNEL_HH__
356657SN/A#define __MEM_RUBY_NETWORK_GARNET_VIRTUAL_CHANNEL_HH__
366657SN/A
376657SN/A#include <utility>
386657SN/A
396657SN/A#include "mem/ruby/network/garnet2.0/CommonTypes.hh"
406657SN/A#include "mem/ruby/network/garnet2.0/flitBuffer.hh"
416657SN/A
426657SN/Aclass VirtualChannel
436999SN/A{
446999SN/A  public:
456657SN/A    VirtualChannel(int id);
466657SN/A    ~VirtualChannel();
476657SN/A
486657SN/A    bool need_stage(flit_stage stage, Cycles time);
496657SN/A    void set_idle(Cycles curTime);
509499SN/A    void set_active(Cycles curTime);
516657SN/A    void set_outvc(int outvc)               { m_output_vc = outvc; }
526657SN/A    inline int get_outvc()                  { return m_output_vc; }
536657SN/A    void set_outport(int outport)           { m_output_port = outport; };
546657SN/A    inline int get_outport()                  { return m_output_port; }
556657SN/A
566657SN/A    inline Cycles get_enqueue_time()          { return m_enqueue_time; }
576657SN/A    inline void set_enqueue_time(Cycles time) { m_enqueue_time = time; }
589499SN/A    inline VC_state_type get_state()        { return m_vc_state.first; }
599499SN/A
609499SN/A    inline bool isReady(Cycles curTime)
616657SN/A    {
626657SN/A        return m_input_buffer->isReady(curTime);
639499SN/A    }
649499SN/A
659499SN/A    inline void
669499SN/A    insertFlit(flit *t_flit)
679499SN/A    {
689499SN/A        m_input_buffer->insert(t_flit);
699499SN/A    }
7011016Snilay@cs.wisc.edu
719499SN/A    inline void
729692Snilay@cs.wisc.edu    set_state(VC_state_type m_state, Cycles curTime)
7310521Snilay@cs.wisc.edu    {
7410521Snilay@cs.wisc.edu        m_vc_state.first = m_state;
759499SN/A        m_vc_state.second = curTime;
766657SN/A    }
779499SN/A
786657SN/A    inline flit*
799499SN/A    peekTopFlit()
809499SN/A    {
819499SN/A        return m_input_buffer->peekTopFlit();
826657SN/A    }
839499SN/A
849499SN/A    inline flit*
856657SN/A    getTopFlit()
869499SN/A    {
879499SN/A        return m_input_buffer->getTopFlit();
889499SN/A    }
899499SN/A
906657SN/A    uint32_t functionalWrite(Packet *pkt);
916657SN/A
926657SN/A  private:
936657SN/A    int m_id;
946657SN/A    flitBuffer *m_input_buffer;
956657SN/A    std::pair<VC_state_type, Cycles> m_vc_state;
969692Snilay@cs.wisc.edu    int m_output_port;
979692Snilay@cs.wisc.edu    Cycles m_enqueue_time;
989692Snilay@cs.wisc.edu    int m_output_vc;
999692Snilay@cs.wisc.edu};
1009692Snilay@cs.wisc.edu
1019692Snilay@cs.wisc.edu#endif // __MEM_RUBY_NETWORK_GARNET_VIRTUAL_CHANNEL_HH__
1029692Snilay@cs.wisc.edu