sc_fifo.hh revision 12853:e23d6f09069a
11689SN/A/* 22325SN/A * Copyright 2018 Google, Inc. 31689SN/A * 41689SN/A * Redistribution and use in source and binary forms, with or without 51689SN/A * modification, are permitted provided that the following conditions are 61689SN/A * met: redistributions of source code must retain the above copyright 71689SN/A * notice, this list of conditions and the following disclaimer; 81689SN/A * redistributions in binary form must reproduce the above copyright 91689SN/A * notice, this list of conditions and the following disclaimer in the 101689SN/A * documentation and/or other materials provided with the distribution; 111689SN/A * neither the name of the copyright holders nor the names of its 121689SN/A * contributors may be used to endorse or promote products derived from 131689SN/A * this software without specific prior written permission. 141689SN/A * 151689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 161689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 171689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 181689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 191689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 201689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 211689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 221689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 231689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 241689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 251689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 261689SN/A * 272665Ssaidi@eecs.umich.edu * Authors: Gabe Black 282665Ssaidi@eecs.umich.edu */ 292756Sksewell@umich.edu 301689SN/A#ifndef __SYSTEMC_EXT_CHANNEL_SC_FIFO_HH__ 311689SN/A#define __SYSTEMC_EXT_CHANNEL_SC_FIFO_HH__ 321858SN/A 332733Sktlim@umich.edu#include "../core/sc_module.hh" // for sc_gen_unique_name 341858SN/A#include "../core/sc_prim.hh" 351858SN/A#include "sc_fifo_in_if.hh" 361060SN/A#include "sc_fifo_out_if.hh" 371060SN/A#include "warn_unimpl.hh" 381060SN/A 391060SN/Anamespace sc_core 401060SN/A{ 412325SN/A 422683Sktlim@umich.educlass sc_port_base; 432680Sktlim@umich.educlass sc_event; 442817Sksewell@umich.edu 451717SN/Atemplate <class T> 461060SN/Aclass sc_fifo : public sc_fifo_in_if<T>, 472325SN/A public sc_fifo_out_if<T>, 482292SN/A public sc_prim_channel 492292SN/A{ 502794Sktlim@umich.edu public: 512794Sktlim@umich.edu explicit sc_fifo(int size=16) : 522794Sktlim@umich.edu sc_fifo_in_if<T>(), sc_fifo_out_if<T>(), 532794Sktlim@umich.edu sc_prim_channel(sc_gen_unique_name("fifo")) 541060SN/A {} 552669Sktlim@umich.edu explicit sc_fifo(const char *name, int size=16) : 561060SN/A sc_fifo_in_if<T>(), sc_fifo_out_if<T>(), 572733Sktlim@umich.edu sc_prim_channel(name) 582292SN/A {} 591060SN/A virtual ~sc_fifo() {} 601060SN/A 611060SN/A virtual void 622292SN/A register_port(sc_port_base &, const char *) 632733Sktlim@umich.edu { 642292SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 652292SN/A } 662292SN/A 672292SN/A virtual void 681060SN/A read(T &) 691755SN/A { 701060SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 711060SN/A } 721060SN/A virtual T 731060SN/A read() 741060SN/A { 751060SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 761755SN/A return *(T *)nullptr; 771060SN/A } 781060SN/A virtual bool 791060SN/A nb_read(T &) 801060SN/A { 811060SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 821060SN/A return false; 831755SN/A } 841060SN/A operator T() 851755SN/A { 861060SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 871060SN/A return *(T *)nullptr; 881060SN/A } 892829Sksewell@umich.edu 902829Sksewell@umich.edu virtual void 912829Sksewell@umich.edu write(const T &) 922829Sksewell@umich.edu { 932829Sksewell@umich.edu sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 942829Sksewell@umich.edu } 952829Sksewell@umich.edu virtual bool 962829Sksewell@umich.edu nb_write(const T&) 972829Sksewell@umich.edu { 982829Sksewell@umich.edu sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 992829Sksewell@umich.edu return false; 1002829Sksewell@umich.edu } 1012829Sksewell@umich.edu sc_fifo<T> & 1022829Sksewell@umich.edu operator = (const T &) 1032829Sksewell@umich.edu { 1042829Sksewell@umich.edu sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 1052829Sksewell@umich.edu return *this; 1062829Sksewell@umich.edu } 1072829Sksewell@umich.edu 1082829Sksewell@umich.edu virtual const sc_event & 1092829Sksewell@umich.edu data_written_event() const 1102829Sksewell@umich.edu { 1112829Sksewell@umich.edu sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 1122829Sksewell@umich.edu return *(const sc_event *)nullptr; 1132829Sksewell@umich.edu } 1142829Sksewell@umich.edu virtual const sc_event & 1152829Sksewell@umich.edu data_read_event() const 1162829Sksewell@umich.edu { 1172829Sksewell@umich.edu sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 1182292SN/A return *(const sc_event *)nullptr; 1192733Sktlim@umich.edu } 1201060SN/A 1212292SN/A virtual int 1221060SN/A num_available() const 1231060SN/A { 1241060SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 1251060SN/A return 0; 1261060SN/A } 1271060SN/A virtual int 1282292SN/A num_free() const 1291060SN/A { 1302831Sksewell@umich.edu sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 1312292SN/A return 0; 1322292SN/A } 1331060SN/A 1342292SN/A virtual void 1352292SN/A print(std::ostream & =std::cout) const 1362292SN/A { 1371060SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 1382831Sksewell@umich.edu } 1392292SN/A virtual void 1402292SN/A dump(std::ostream & =std::cout) const 1412292SN/A { 1422292SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 1431060SN/A } 1441060SN/A virtual const char *kind() const { return "sc_fifo"; } 1452325SN/A 1462325SN/A protected: 1471061SN/A virtual void 1481061SN/A update() 1491061SN/A { 1501061SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 1511061SN/A } 1522325SN/A 1531060SN/A private: 1541060SN/A // Disabled 1551060SN/A sc_fifo(const sc_fifo<T> &) : 1561858SN/A sc_fifo_in_if<T>(), sc_fifo_in_if<T>(), sc_prim_channel() 1572292SN/A {} 1581060SN/A sc_fifo &operator = (const sc_fifo<T> &) { return *this; } 1591060SN/A}; 1602292SN/A 1612843Sktlim@umich.edutemplate <class T> 1622316SN/Ainline std::ostream & 1632316SN/Aoperator << (std::ostream &os, const sc_fifo<T> &) 1641060SN/A{ 1651060SN/A sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 1661681SN/A return os; 1672733Sktlim@umich.edu} 1682733Sktlim@umich.edu 1692794Sktlim@umich.edu} // namespace sc_core 1702733Sktlim@umich.edu 1712316SN/A#endif //__SYSTEMC_EXT_CHANNEL_SC_FIFO_HH__ 1722316SN/A