flitBuffer.cc revision 11666
1955SN/A/* 2955SN/A * Copyright (c) 2008 Princeton University 39812Sandreas.hansson@arm.com * Copyright (c) 2016 Georgia Institute of Technology 49812Sandreas.hansson@arm.com * All rights reserved. 59812Sandreas.hansson@arm.com * 69812Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 79812Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 89812Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 99812Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 109812Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 119812Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 129812Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 139812Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 149812Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 157816Ssteve.reinhardt@amd.com * this software without specific prior written permission. 165871Snate@binkert.org * 171762SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21955SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22955SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23955SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28955SN/A * 29955SN/A * Authors: Niket Agarwal 30955SN/A * Tushar Krishna 31955SN/A */ 32955SN/A 33955SN/A 34955SN/A#include "mem/ruby/network/garnet2.0/flitBuffer.hh" 35955SN/A 36955SN/AflitBuffer::flitBuffer() 37955SN/A{ 38955SN/A max_size = INFINITE_; 39955SN/A} 40955SN/A 41955SN/AflitBuffer::flitBuffer(int maximum_size) 422665Ssaidi@eecs.umich.edu{ 432665Ssaidi@eecs.umich.edu max_size = maximum_size; 445863Snate@binkert.org} 45955SN/A 46955SN/Abool 47955SN/AflitBuffer::isEmpty() 48955SN/A{ 49955SN/A return (m_buffer.size() == 0); 508878Ssteve.reinhardt@amd.com} 512632Sstever@eecs.umich.edu 528878Ssteve.reinhardt@amd.combool 532632Sstever@eecs.umich.eduflitBuffer::isReady(Cycles curTime) 54955SN/A{ 558878Ssteve.reinhardt@amd.com if (m_buffer.size() != 0 ) { 562632Sstever@eecs.umich.edu flit *t_flit = peekTopFlit(); 572761Sstever@eecs.umich.edu if (t_flit->get_time() <= curTime) 582632Sstever@eecs.umich.edu return true; 592632Sstever@eecs.umich.edu } 602632Sstever@eecs.umich.edu return false; 612761Sstever@eecs.umich.edu} 622761Sstever@eecs.umich.edu 632761Sstever@eecs.umich.eduvoid 648878Ssteve.reinhardt@amd.comflitBuffer::print(std::ostream& out) const 658878Ssteve.reinhardt@amd.com{ 662761Sstever@eecs.umich.edu out << "[flitBuffer: " << m_buffer.size() << "] " << std::endl; 672761Sstever@eecs.umich.edu} 682761Sstever@eecs.umich.edu 692761Sstever@eecs.umich.edubool 702761Sstever@eecs.umich.eduflitBuffer::isFull() 718878Ssteve.reinhardt@amd.com{ 728878Ssteve.reinhardt@amd.com return (m_buffer.size() >= max_size); 732632Sstever@eecs.umich.edu} 742632Sstever@eecs.umich.edu 758878Ssteve.reinhardt@amd.comvoid 768878Ssteve.reinhardt@amd.comflitBuffer::setMaxSize(int maximum) 772632Sstever@eecs.umich.edu{ 78955SN/A max_size = maximum; 79955SN/A} 80955SN/A 815863Snate@binkert.orguint32_t 825863Snate@binkert.orgflitBuffer::functionalWrite(Packet *pkt) 835863Snate@binkert.org{ 845863Snate@binkert.org uint32_t num_functional_writes = 0; 855863Snate@binkert.org 865863Snate@binkert.org for (unsigned int i = 0; i < m_buffer.size(); ++i) { 875863Snate@binkert.org if (m_buffer[i]->functionalWrite(pkt)) { 885863Snate@binkert.org num_functional_writes++; 895863Snate@binkert.org } 905863Snate@binkert.org } 915863Snate@binkert.org 928878Ssteve.reinhardt@amd.com return num_functional_writes; 935863Snate@binkert.org} 945863Snate@binkert.org