111666Stushar@ece.gatech.edu/*
211666Stushar@ece.gatech.edu * Copyright (c) 2008 Princeton University
311666Stushar@ece.gatech.edu * Copyright (c) 2016 Georgia Institute of Technology
411666Stushar@ece.gatech.edu * All rights reserved.
511666Stushar@ece.gatech.edu *
611666Stushar@ece.gatech.edu * Redistribution and use in source and binary forms, with or without
711666Stushar@ece.gatech.edu * modification, are permitted provided that the following conditions are
811666Stushar@ece.gatech.edu * met: redistributions of source code must retain the above copyright
911666Stushar@ece.gatech.edu * notice, this list of conditions and the following disclaimer;
1011666Stushar@ece.gatech.edu * redistributions in binary form must reproduce the above copyright
1111666Stushar@ece.gatech.edu * notice, this list of conditions and the following disclaimer in the
1211666Stushar@ece.gatech.edu * documentation and/or other materials provided with the distribution;
1311666Stushar@ece.gatech.edu * neither the name of the copyright holders nor the names of its
1411666Stushar@ece.gatech.edu * contributors may be used to endorse or promote products derived from
1511666Stushar@ece.gatech.edu * this software without specific prior written permission.
1611666Stushar@ece.gatech.edu *
1711666Stushar@ece.gatech.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1811666Stushar@ece.gatech.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1911666Stushar@ece.gatech.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2011666Stushar@ece.gatech.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2111666Stushar@ece.gatech.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2211666Stushar@ece.gatech.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2311666Stushar@ece.gatech.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2411666Stushar@ece.gatech.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2511666Stushar@ece.gatech.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2611666Stushar@ece.gatech.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2711666Stushar@ece.gatech.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2811666Stushar@ece.gatech.edu *
2911666Stushar@ece.gatech.edu * Authors: Niket Agarwal
3011666Stushar@ece.gatech.edu *          Tushar Krishna
3111666Stushar@ece.gatech.edu */
3211666Stushar@ece.gatech.edu
3311666Stushar@ece.gatech.edu
3412492Sodanrc@yahoo.com.br#ifndef __MEM_RUBY_NETWORK_GARNET2_0_VIRTUALCHANNEL_HH__
3512492Sodanrc@yahoo.com.br#define __MEM_RUBY_NETWORK_GARNET2_0_VIRTUALCHANNEL_HH__
3611666Stushar@ece.gatech.edu
3711666Stushar@ece.gatech.edu#include <utility>
3811666Stushar@ece.gatech.edu
3911666Stushar@ece.gatech.edu#include "mem/ruby/network/garnet2.0/CommonTypes.hh"
4011666Stushar@ece.gatech.edu#include "mem/ruby/network/garnet2.0/flitBuffer.hh"
4111666Stushar@ece.gatech.edu
4211666Stushar@ece.gatech.educlass VirtualChannel
4311666Stushar@ece.gatech.edu{
4411666Stushar@ece.gatech.edu  public:
4511666Stushar@ece.gatech.edu    VirtualChannel(int id);
4611666Stushar@ece.gatech.edu    ~VirtualChannel();
4711666Stushar@ece.gatech.edu
4811666Stushar@ece.gatech.edu    bool need_stage(flit_stage stage, Cycles time);
4911666Stushar@ece.gatech.edu    void set_idle(Cycles curTime);
5011666Stushar@ece.gatech.edu    void set_active(Cycles curTime);
5111666Stushar@ece.gatech.edu    void set_outvc(int outvc)               { m_output_vc = outvc; }
5211666Stushar@ece.gatech.edu    inline int get_outvc()                  { return m_output_vc; }
5311666Stushar@ece.gatech.edu    void set_outport(int outport)           { m_output_port = outport; };
5411666Stushar@ece.gatech.edu    inline int get_outport()                  { return m_output_port; }
5511666Stushar@ece.gatech.edu
5611666Stushar@ece.gatech.edu    inline Cycles get_enqueue_time()          { return m_enqueue_time; }
5711666Stushar@ece.gatech.edu    inline void set_enqueue_time(Cycles time) { m_enqueue_time = time; }
5811666Stushar@ece.gatech.edu    inline VC_state_type get_state()        { return m_vc_state.first; }
5911666Stushar@ece.gatech.edu
6011666Stushar@ece.gatech.edu    inline bool isReady(Cycles curTime)
6111666Stushar@ece.gatech.edu    {
6211666Stushar@ece.gatech.edu        return m_input_buffer->isReady(curTime);
6311666Stushar@ece.gatech.edu    }
6411666Stushar@ece.gatech.edu
6511666Stushar@ece.gatech.edu    inline void
6611666Stushar@ece.gatech.edu    insertFlit(flit *t_flit)
6711666Stushar@ece.gatech.edu    {
6811666Stushar@ece.gatech.edu        m_input_buffer->insert(t_flit);
6911666Stushar@ece.gatech.edu    }
7011666Stushar@ece.gatech.edu
7111666Stushar@ece.gatech.edu    inline void
7211666Stushar@ece.gatech.edu    set_state(VC_state_type m_state, Cycles curTime)
7311666Stushar@ece.gatech.edu    {
7411666Stushar@ece.gatech.edu        m_vc_state.first = m_state;
7511666Stushar@ece.gatech.edu        m_vc_state.second = curTime;
7611666Stushar@ece.gatech.edu    }
7711666Stushar@ece.gatech.edu
7811666Stushar@ece.gatech.edu    inline flit*
7911666Stushar@ece.gatech.edu    peekTopFlit()
8011666Stushar@ece.gatech.edu    {
8111666Stushar@ece.gatech.edu        return m_input_buffer->peekTopFlit();
8211666Stushar@ece.gatech.edu    }
8311666Stushar@ece.gatech.edu
8411666Stushar@ece.gatech.edu    inline flit*
8511666Stushar@ece.gatech.edu    getTopFlit()
8611666Stushar@ece.gatech.edu    {
8711666Stushar@ece.gatech.edu        return m_input_buffer->getTopFlit();
8811666Stushar@ece.gatech.edu    }
8911666Stushar@ece.gatech.edu
9011666Stushar@ece.gatech.edu    uint32_t functionalWrite(Packet *pkt);
9111666Stushar@ece.gatech.edu
9211666Stushar@ece.gatech.edu  private:
9311666Stushar@ece.gatech.edu    int m_id;
9411666Stushar@ece.gatech.edu    flitBuffer *m_input_buffer;
9511666Stushar@ece.gatech.edu    std::pair<VC_state_type, Cycles> m_vc_state;
9611666Stushar@ece.gatech.edu    int m_output_port;
9711666Stushar@ece.gatech.edu    Cycles m_enqueue_time;
9811666Stushar@ece.gatech.edu    int m_output_vc;
9911666Stushar@ece.gatech.edu};
10011666Stushar@ece.gatech.edu
10112492Sodanrc@yahoo.com.br#endif // __MEM_RUBY_NETWORK_GARNET2_0_VIRTUALCHANNEL_HH__
102