sc_in.hh revision 13383
112841Sgabeblack@google.com/* 212841Sgabeblack@google.com * Copyright 2018 Google, Inc. 312841Sgabeblack@google.com * 412841Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 512841Sgabeblack@google.com * modification, are permitted provided that the following conditions are 612841Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 712841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 812841Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 912841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1012841Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1112841Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1212841Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1312841Sgabeblack@google.com * this software without specific prior written permission. 1412841Sgabeblack@google.com * 1512841Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612841Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712841Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812841Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912841Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012841Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112841Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212841Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312841Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412841Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512841Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612841Sgabeblack@google.com * 2712841Sgabeblack@google.com * Authors: Gabe Black 2812841Sgabeblack@google.com */ 2912841Sgabeblack@google.com 3012841Sgabeblack@google.com#ifndef __SYSTEMC_EXT_CHANNEL_SC_IN_HH__ 3112841Sgabeblack@google.com#define __SYSTEMC_EXT_CHANNEL_SC_IN_HH__ 3212841Sgabeblack@google.com 3312841Sgabeblack@google.com#include <string> 3412841Sgabeblack@google.com 3513054Sgabeblack@google.com#include "../core/sc_event.hh" 3613269Sgabeblack@google.com#include "../core/sc_main.hh" 3712841Sgabeblack@google.com#include "../core/sc_port.hh" 3813245Sgabeblack@google.com#include "../utils/sc_trace_file.hh" 3912841Sgabeblack@google.com#include "sc_signal_in_if.hh" 4012841Sgabeblack@google.com#include "sc_signal_inout_if.hh" 4112841Sgabeblack@google.com 4212841Sgabeblack@google.comnamespace sc_core 4312841Sgabeblack@google.com{ 4412841Sgabeblack@google.com 4512841Sgabeblack@google.comclass sc_event; 4612841Sgabeblack@google.comclass sc_trace_file; 4712841Sgabeblack@google.com 4812841Sgabeblack@google.comtemplate <class T> 4912841Sgabeblack@google.comclass sc_in : public sc_port<sc_signal_in_if<T>, 1> 5012841Sgabeblack@google.com{ 5112841Sgabeblack@google.com public: 5213054Sgabeblack@google.com sc_in() : sc_port<sc_signal_in_if<T>, 1>(), 5313054Sgabeblack@google.com _valueChangedFinder(*this, &sc_signal_in_if<T>::value_changed_event) 5413054Sgabeblack@google.com {} 5513054Sgabeblack@google.com explicit sc_in(const char *name) : sc_port<sc_signal_in_if<T>, 1>(name), 5613054Sgabeblack@google.com _valueChangedFinder(*this, &sc_signal_in_if<T>::value_changed_event) 5713054Sgabeblack@google.com {} 5812841Sgabeblack@google.com virtual ~sc_in() {} 5912841Sgabeblack@google.com 6012868Sgabeblack@google.com // Deprecated binding constructors. 6112868Sgabeblack@google.com explicit sc_in(const sc_signal_in_if<T> &interface) : 6213054Sgabeblack@google.com sc_port<sc_signal_in_if<T>, 1>(interface), 6313054Sgabeblack@google.com _valueChangedFinder(*this, &sc_signal_in_if<T>::value_changed_event) 6412868Sgabeblack@google.com {} 6512868Sgabeblack@google.com sc_in(const char *name, const sc_signal_in_if<T> &interface) : 6613054Sgabeblack@google.com sc_port<sc_signal_in_if<T>, 1>(name, interface), 6713054Sgabeblack@google.com _valueChangedFinder(*this, &sc_signal_in_if<T>::value_changed_event) 6812868Sgabeblack@google.com {} 6912868Sgabeblack@google.com explicit sc_in(sc_port_b<sc_signal_in_if<T> > &parent) : 7013054Sgabeblack@google.com sc_port<sc_signal_in_if<T>, 1>(parent), 7113054Sgabeblack@google.com _valueChangedFinder(*this, &sc_signal_in_if<T>::value_changed_event) 7212868Sgabeblack@google.com {} 7312868Sgabeblack@google.com sc_in(const char *name, sc_port_b<sc_signal_in_if<T> > &parent) : 7413054Sgabeblack@google.com sc_port<sc_signal_in_if<T>, 1>(name, parent), 7513054Sgabeblack@google.com _valueChangedFinder(*this, &sc_signal_in_if<T>::value_changed_event) 7612868Sgabeblack@google.com {} 7712868Sgabeblack@google.com explicit sc_in(sc_port<sc_signal_in_if<T>, 1> &parent) : 7813054Sgabeblack@google.com sc_port<sc_signal_in_if<T>, 1>(parent), 7913054Sgabeblack@google.com _valueChangedFinder(*this, &sc_signal_in_if<T>::value_changed_event) 8012868Sgabeblack@google.com {} 8112868Sgabeblack@google.com sc_in(const char *name, sc_port<sc_signal_in_if<T>, 1> &parent) : 8213054Sgabeblack@google.com sc_port<sc_signal_in_if<T>, 1>(name, parent), 8313054Sgabeblack@google.com _valueChangedFinder(*this, &sc_signal_in_if<T>::value_changed_event) 8412868Sgabeblack@google.com {} 8512868Sgabeblack@google.com 8612841Sgabeblack@google.com virtual void 8713054Sgabeblack@google.com bind(const sc_signal_in_if<T> &i) 8812841Sgabeblack@google.com { 8913054Sgabeblack@google.com sc_port<sc_signal_in_if<T>, 1>::bind( 9013054Sgabeblack@google.com const_cast<sc_signal_in_if<T> &>(i)); 9113054Sgabeblack@google.com } 9213054Sgabeblack@google.com void operator () (const sc_signal_in_if<T> &i) { bind(i); } 9313054Sgabeblack@google.com 9413054Sgabeblack@google.com virtual void 9513054Sgabeblack@google.com bind(sc_port<sc_signal_in_if<T>, 1> &i) 9613054Sgabeblack@google.com { 9713054Sgabeblack@google.com sc_port<sc_signal_in_if<T>, 1>::bind(i); 9812841Sgabeblack@google.com } 9912841Sgabeblack@google.com void 10013054Sgabeblack@google.com operator () (sc_port<sc_signal_in_if<T>, 1> &p) 10112841Sgabeblack@google.com { 10213054Sgabeblack@google.com bind(p); 10312841Sgabeblack@google.com } 10412841Sgabeblack@google.com 10512841Sgabeblack@google.com virtual void 10613054Sgabeblack@google.com bind(sc_port<sc_signal_inout_if<T>, 1> &p) 10712841Sgabeblack@google.com { 10813054Sgabeblack@google.com sc_port_base::bind(p); 10912841Sgabeblack@google.com } 11012841Sgabeblack@google.com void 11113054Sgabeblack@google.com operator () (sc_port<sc_signal_inout_if<T>, 1> &p) 11212841Sgabeblack@google.com { 11313054Sgabeblack@google.com bind(p); 11412841Sgabeblack@google.com } 11512841Sgabeblack@google.com 11613245Sgabeblack@google.com virtual void 11713245Sgabeblack@google.com end_of_elaboration() 11813245Sgabeblack@google.com { 11913245Sgabeblack@google.com for (auto params: traceParamsVec) 12013245Sgabeblack@google.com sc_trace(params->tf, (*this)->read(), params->name); 12113245Sgabeblack@google.com 12213245Sgabeblack@google.com traceParamsVec.clear(); 12313245Sgabeblack@google.com } 12412841Sgabeblack@google.com 12513054Sgabeblack@google.com const T &read() const { return (*this)->read(); } 12613054Sgabeblack@google.com operator const T& () const { return (*this)->read(); } 12712841Sgabeblack@google.com 12813054Sgabeblack@google.com const sc_event &default_event() const { return (*this)->default_event(); } 12912841Sgabeblack@google.com const sc_event & 13012841Sgabeblack@google.com value_changed_event() const 13112841Sgabeblack@google.com { 13213054Sgabeblack@google.com return (*this)->value_changed_event(); 13312841Sgabeblack@google.com } 13413054Sgabeblack@google.com bool event() const { return (*this)->event(); } 13513054Sgabeblack@google.com sc_event_finder &value_changed() const { return _valueChangedFinder; } 13612841Sgabeblack@google.com 13712841Sgabeblack@google.com virtual const char *kind() const { return "sc_in"; } 13812841Sgabeblack@google.com 13913245Sgabeblack@google.com void 14013245Sgabeblack@google.com add_trace(sc_trace_file *tf, const std::string &name) const 14113245Sgabeblack@google.com { 14213245Sgabeblack@google.com traceParamsVec.push_back(new sc_trace_params(tf, name)); 14313245Sgabeblack@google.com } 14413245Sgabeblack@google.com 14512841Sgabeblack@google.com private: 14613054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<T> > _valueChangedFinder; 14713054Sgabeblack@google.com 14813245Sgabeblack@google.com mutable sc_trace_params_vec traceParamsVec; 14913245Sgabeblack@google.com 15012841Sgabeblack@google.com // Disabled 15113054Sgabeblack@google.com sc_in(const sc_in<T> &); 15213054Sgabeblack@google.com sc_in<T> &operator = (const sc_in<T> &); 15312841Sgabeblack@google.com}; 15412841Sgabeblack@google.com 15512841Sgabeblack@google.comtemplate <class T> 15612841Sgabeblack@google.cominline void 15713245Sgabeblack@google.comsc_trace(sc_trace_file *tf, const sc_in<T> &i, const std::string &name) 15812841Sgabeblack@google.com{ 15913269Sgabeblack@google.com if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION) 16013269Sgabeblack@google.com i.add_trace(tf, name); 16113269Sgabeblack@google.com else 16213245Sgabeblack@google.com sc_trace(tf, i->read(), name); 16312841Sgabeblack@google.com} 16412841Sgabeblack@google.com 16512841Sgabeblack@google.comtemplate <> 16612841Sgabeblack@google.comclass sc_in<bool> : public sc_port<sc_signal_in_if<bool>, 1> 16712841Sgabeblack@google.com{ 16812841Sgabeblack@google.com public: 16913054Sgabeblack@google.com sc_in() : sc_port<sc_signal_in_if<bool>, 1>(), 17013054Sgabeblack@google.com _valueChangedFinder(*this, 17113054Sgabeblack@google.com &sc_signal_in_if<bool>::value_changed_event), 17213054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<bool>::posedge_event), 17313054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<bool>::negedge_event) 17413054Sgabeblack@google.com {} 17512841Sgabeblack@google.com explicit sc_in(const char *name) : 17613054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>(name), 17713054Sgabeblack@google.com _valueChangedFinder(*this, 17813054Sgabeblack@google.com &sc_signal_in_if<bool>::value_changed_event), 17913054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<bool>::posedge_event), 18013054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<bool>::negedge_event) 18113054Sgabeblack@google.com {} 18212841Sgabeblack@google.com virtual ~sc_in() {} 18312841Sgabeblack@google.com 18412868Sgabeblack@google.com // Deprecated binding constructors. 18512868Sgabeblack@google.com explicit sc_in(const sc_signal_in_if<bool> &interface) : 18613054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>(interface), 18713054Sgabeblack@google.com _valueChangedFinder(*this, 18813054Sgabeblack@google.com &sc_signal_in_if<bool>::value_changed_event), 18913054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<bool>::posedge_event), 19013054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<bool>::negedge_event) 19112868Sgabeblack@google.com {} 19212868Sgabeblack@google.com sc_in(const char *name, const sc_signal_in_if<bool> &interface) : 19313054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>(name, interface), 19413054Sgabeblack@google.com _valueChangedFinder(*this, 19513054Sgabeblack@google.com &sc_signal_in_if<bool>::value_changed_event), 19613054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<bool>::posedge_event), 19713054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<bool>::negedge_event) 19812868Sgabeblack@google.com {} 19912868Sgabeblack@google.com explicit sc_in(sc_port_b<sc_signal_in_if<bool> > &parent) : 20013054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>(parent), 20113054Sgabeblack@google.com _valueChangedFinder(*this, 20213054Sgabeblack@google.com &sc_signal_in_if<bool>::value_changed_event), 20313054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<bool>::posedge_event), 20413054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<bool>::negedge_event) 20512868Sgabeblack@google.com {} 20612868Sgabeblack@google.com sc_in(const char *name, sc_port_b<sc_signal_in_if<bool> > &parent) : 20713054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>(name, parent), 20813054Sgabeblack@google.com _valueChangedFinder(*this, 20913054Sgabeblack@google.com &sc_signal_in_if<bool>::value_changed_event), 21013054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<bool>::posedge_event), 21113054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<bool>::negedge_event) 21212868Sgabeblack@google.com {} 21312868Sgabeblack@google.com explicit sc_in(sc_port<sc_signal_in_if<bool>, 1> &parent) : 21413054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>(parent), 21513054Sgabeblack@google.com _valueChangedFinder(*this, 21613054Sgabeblack@google.com &sc_signal_in_if<bool>::value_changed_event), 21713054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<bool>::posedge_event), 21813054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<bool>::negedge_event) 21912868Sgabeblack@google.com {} 22012868Sgabeblack@google.com sc_in(const char *name, sc_port<sc_signal_in_if<bool>, 1> &parent) : 22113054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>(name, parent), 22213054Sgabeblack@google.com _valueChangedFinder(*this, 22313054Sgabeblack@google.com &sc_signal_in_if<bool>::value_changed_event), 22413054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<bool>::posedge_event), 22513054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<bool>::negedge_event) 22612868Sgabeblack@google.com {} 22712868Sgabeblack@google.com 22813383Sgabeblack@google.com using sc_port<sc_signal_in_if<bool>, 1>::bind; 22913383Sgabeblack@google.com 23012841Sgabeblack@google.com virtual void 23113054Sgabeblack@google.com bind(const sc_signal_in_if<bool> &i) 23212841Sgabeblack@google.com { 23313054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>::bind( 23413054Sgabeblack@google.com const_cast<sc_signal_in_if<bool> &>(i)); 23513054Sgabeblack@google.com } 23613054Sgabeblack@google.com void operator () (const sc_signal_in_if<bool> &i) { bind(i); } 23713054Sgabeblack@google.com 23813054Sgabeblack@google.com virtual void 23913054Sgabeblack@google.com bind(sc_port<sc_signal_in_if<bool>, 1> &p) 24013054Sgabeblack@google.com { 24113054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>::bind(p); 24212841Sgabeblack@google.com } 24312841Sgabeblack@google.com void 24413054Sgabeblack@google.com operator () (sc_port<sc_signal_in_if<bool>, 1> &p) 24512841Sgabeblack@google.com { 24613054Sgabeblack@google.com bind(p); 24712841Sgabeblack@google.com } 24812841Sgabeblack@google.com 24912841Sgabeblack@google.com virtual void 25013054Sgabeblack@google.com bind(sc_port<sc_signal_inout_if<bool>, 1> &p) 25112841Sgabeblack@google.com { 25213054Sgabeblack@google.com sc_port_base::bind(p); 25312841Sgabeblack@google.com } 25412841Sgabeblack@google.com void 25513054Sgabeblack@google.com operator () (sc_port<sc_signal_inout_if<bool>, 1> &p) 25612841Sgabeblack@google.com { 25713054Sgabeblack@google.com bind(p); 25812841Sgabeblack@google.com } 25912841Sgabeblack@google.com 26013245Sgabeblack@google.com virtual void 26113245Sgabeblack@google.com end_of_elaboration() 26213245Sgabeblack@google.com { 26313245Sgabeblack@google.com for (auto params: traceParamsVec) 26413245Sgabeblack@google.com sc_trace(params->tf, (*this)->read(), params->name); 26513245Sgabeblack@google.com 26613245Sgabeblack@google.com traceParamsVec.clear(); 26713245Sgabeblack@google.com } 26812841Sgabeblack@google.com 26913054Sgabeblack@google.com const bool &read() const { return (*this)->read(); } 27013054Sgabeblack@google.com operator const bool& () const { return (*this)->read(); } 27112841Sgabeblack@google.com 27213054Sgabeblack@google.com const sc_event &default_event() const { return (*this)->default_event(); } 27312841Sgabeblack@google.com const sc_event & 27412841Sgabeblack@google.com value_changed_event() const 27512841Sgabeblack@google.com { 27613054Sgabeblack@google.com return (*this)->value_changed_event(); 27712841Sgabeblack@google.com } 27812841Sgabeblack@google.com const sc_event & 27912841Sgabeblack@google.com posedge_event() const 28012841Sgabeblack@google.com { 28113054Sgabeblack@google.com return (*this)->posedge_event(); 28212841Sgabeblack@google.com } 28312841Sgabeblack@google.com const sc_event & 28412841Sgabeblack@google.com negedge_event() const 28512841Sgabeblack@google.com { 28613054Sgabeblack@google.com return (*this)->negedge_event(); 28712841Sgabeblack@google.com } 28812841Sgabeblack@google.com 28913054Sgabeblack@google.com bool event() const { return (*this)->event(); } 29013054Sgabeblack@google.com bool posedge() const { return (*this)->posedge(); } 29113054Sgabeblack@google.com bool negedge() const { return (*this)->negedge(); } 29212841Sgabeblack@google.com 29313054Sgabeblack@google.com sc_event_finder &value_changed() const { return _valueChangedFinder; } 29413054Sgabeblack@google.com sc_event_finder &pos() const { return _posFinder; } 29513054Sgabeblack@google.com sc_event_finder &neg() const { return _negFinder; } 29612841Sgabeblack@google.com 29712841Sgabeblack@google.com virtual const char *kind() const { return "sc_in"; } 29812841Sgabeblack@google.com 29913245Sgabeblack@google.com void 30013245Sgabeblack@google.com add_trace(sc_trace_file *tf, const std::string &name) const 30113245Sgabeblack@google.com { 30213245Sgabeblack@google.com traceParamsVec.push_back(new sc_trace_params(tf, name)); 30313245Sgabeblack@google.com } 30413245Sgabeblack@google.com 30512841Sgabeblack@google.com private: 30613054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<bool> > _valueChangedFinder; 30713054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<bool> > _posFinder; 30813054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<bool> > _negFinder; 30913054Sgabeblack@google.com 31013245Sgabeblack@google.com mutable sc_trace_params_vec traceParamsVec; 31113245Sgabeblack@google.com 31212841Sgabeblack@google.com // Disabled 31313054Sgabeblack@google.com sc_in(const sc_in<bool> &); 31413054Sgabeblack@google.com sc_in<bool> &operator = (const sc_in<bool> &); 31512841Sgabeblack@google.com}; 31612841Sgabeblack@google.com 31712841Sgabeblack@google.comtemplate <> 31812841Sgabeblack@google.cominline void 31913245Sgabeblack@google.comsc_trace<bool>(sc_trace_file *tf, const sc_in<bool> &i, 32013245Sgabeblack@google.com const std::string &name) 32112841Sgabeblack@google.com{ 32213269Sgabeblack@google.com if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION) 32313269Sgabeblack@google.com i.add_trace(tf, name); 32413269Sgabeblack@google.com else 32513245Sgabeblack@google.com sc_trace(tf, i->read(), name); 32612841Sgabeblack@google.com} 32712841Sgabeblack@google.com 32812841Sgabeblack@google.comtemplate <> 32912841Sgabeblack@google.comclass sc_in<sc_dt::sc_logic> : 33012841Sgabeblack@google.com public sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> 33112841Sgabeblack@google.com{ 33212841Sgabeblack@google.com public: 33313054Sgabeblack@google.com sc_in() : sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(), 33413054Sgabeblack@google.com _valueChangedFinder(*this, 33513054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 33613054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 33713054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 33813054Sgabeblack@google.com {} 33912841Sgabeblack@google.com explicit sc_in(const char *name) : 34013054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name), 34113054Sgabeblack@google.com _valueChangedFinder(*this, 34213054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 34313054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 34413054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 34512841Sgabeblack@google.com {} 34612841Sgabeblack@google.com virtual ~sc_in() {} 34712841Sgabeblack@google.com 34812868Sgabeblack@google.com // Deprecated binding constructors. 34912868Sgabeblack@google.com explicit sc_in(const sc_signal_in_if<sc_dt::sc_logic> &interface) : 35013054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(interface), 35113054Sgabeblack@google.com _valueChangedFinder(*this, 35213054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 35313054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 35413054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 35512868Sgabeblack@google.com {} 35612868Sgabeblack@google.com sc_in(const char *name, 35712868Sgabeblack@google.com const sc_signal_in_if<sc_dt::sc_logic> &interface) : 35813054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name, interface), 35913054Sgabeblack@google.com _valueChangedFinder(*this, 36013054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 36113054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 36213054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 36312868Sgabeblack@google.com {} 36412868Sgabeblack@google.com explicit sc_in(sc_port_b<sc_signal_in_if<sc_dt::sc_logic> > &parent) : 36513054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(parent), 36613054Sgabeblack@google.com _valueChangedFinder(*this, 36713054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 36813054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 36913054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 37012868Sgabeblack@google.com {} 37112868Sgabeblack@google.com sc_in(const char *name, 37212868Sgabeblack@google.com sc_port_b<sc_signal_in_if<sc_dt::sc_logic> > &parent) : 37313054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name, parent), 37413054Sgabeblack@google.com _valueChangedFinder(*this, 37513054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 37613054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 37713054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 37812868Sgabeblack@google.com {} 37912868Sgabeblack@google.com explicit sc_in(sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &parent) : 38013054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(parent), 38113054Sgabeblack@google.com _valueChangedFinder(*this, 38213054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 38313054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 38413054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 38512868Sgabeblack@google.com {} 38612868Sgabeblack@google.com sc_in(const char *name, 38712868Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &parent) : 38813054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name, parent), 38913054Sgabeblack@google.com _valueChangedFinder(*this, 39013054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 39113054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 39213054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 39312868Sgabeblack@google.com {} 39412868Sgabeblack@google.com 39513383Sgabeblack@google.com using sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>::bind; 39613383Sgabeblack@google.com 39712841Sgabeblack@google.com virtual void 39813054Sgabeblack@google.com bind(const sc_signal_in_if<sc_dt::sc_logic> &i) 39912841Sgabeblack@google.com { 40013054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>::bind( 40113054Sgabeblack@google.com const_cast<sc_signal_in_if<sc_dt::sc_logic> &>(i)); 40212841Sgabeblack@google.com } 40312841Sgabeblack@google.com void 40413054Sgabeblack@google.com operator () (const sc_signal_in_if<sc_dt::sc_logic> &i) { bind(i); } 40513054Sgabeblack@google.com 40613054Sgabeblack@google.com virtual void 40713054Sgabeblack@google.com bind(sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &i) 40812841Sgabeblack@google.com { 40913054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>::bind(i); 41013054Sgabeblack@google.com } 41113054Sgabeblack@google.com void 41213054Sgabeblack@google.com operator () (sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &p) 41313054Sgabeblack@google.com { 41413054Sgabeblack@google.com bind(p); 41512841Sgabeblack@google.com } 41612841Sgabeblack@google.com 41712841Sgabeblack@google.com virtual void 41813054Sgabeblack@google.com bind(sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1> &p) 41912841Sgabeblack@google.com { 42013054Sgabeblack@google.com sc_port_base::bind(p); 42112841Sgabeblack@google.com } 42212841Sgabeblack@google.com void 42313054Sgabeblack@google.com operator () (sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1> &p) 42412841Sgabeblack@google.com { 42513054Sgabeblack@google.com bind(p); 42612841Sgabeblack@google.com } 42712841Sgabeblack@google.com 42813245Sgabeblack@google.com virtual void 42913245Sgabeblack@google.com end_of_elaboration() 43013245Sgabeblack@google.com { 43113245Sgabeblack@google.com for (auto params: traceParamsVec) 43213245Sgabeblack@google.com sc_trace(params->tf, (*this)->read(), params->name); 43313245Sgabeblack@google.com 43413245Sgabeblack@google.com traceParamsVec.clear(); 43513245Sgabeblack@google.com } 43612841Sgabeblack@google.com 43713054Sgabeblack@google.com const sc_dt::sc_logic &read() const { return (*this)->read(); } 43813054Sgabeblack@google.com operator const sc_dt::sc_logic& () const { return (*this)->read(); } 43912841Sgabeblack@google.com 44013054Sgabeblack@google.com const sc_event &default_event() const { return (*this)->default_event(); } 44112841Sgabeblack@google.com const sc_event & 44212841Sgabeblack@google.com value_changed_event() const 44312841Sgabeblack@google.com { 44413054Sgabeblack@google.com return (*this)->value_changed_event(); 44512841Sgabeblack@google.com } 44613054Sgabeblack@google.com const sc_event &posedge_event() const { return (*this)->posedge_event(); } 44713054Sgabeblack@google.com const sc_event &negedge_event() const { return (*this)->negedge_event(); } 44812841Sgabeblack@google.com 44913054Sgabeblack@google.com bool event() const { return (*this)->event(); } 45013054Sgabeblack@google.com bool posedge() const { return (*this)->posedge(); } 45113054Sgabeblack@google.com bool negedge() const { return (*this)->negedge(); } 45212841Sgabeblack@google.com 45313054Sgabeblack@google.com sc_event_finder &value_changed() const { return _valueChangedFinder; } 45413054Sgabeblack@google.com sc_event_finder &pos() const { return _posFinder; } 45513054Sgabeblack@google.com sc_event_finder &neg() const { return _negFinder; } 45612841Sgabeblack@google.com 45712841Sgabeblack@google.com virtual const char *kind() const { return "sc_in"; } 45812841Sgabeblack@google.com 45913245Sgabeblack@google.com void 46013245Sgabeblack@google.com add_trace(sc_trace_file *tf, const std::string &name) const 46113245Sgabeblack@google.com { 46213245Sgabeblack@google.com traceParamsVec.push_back(new sc_trace_params(tf, name)); 46313245Sgabeblack@google.com } 46413245Sgabeblack@google.com 46512841Sgabeblack@google.com private: 46613054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > 46713054Sgabeblack@google.com _valueChangedFinder; 46813054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > _posFinder; 46913054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > _negFinder; 47013054Sgabeblack@google.com 47113245Sgabeblack@google.com mutable sc_trace_params_vec traceParamsVec; 47213245Sgabeblack@google.com 47312841Sgabeblack@google.com // Disabled 47413054Sgabeblack@google.com sc_in(const sc_in<sc_dt::sc_logic> &); 47513054Sgabeblack@google.com sc_in<sc_dt::sc_logic> &operator = (const sc_in<sc_dt::sc_logic> &); 47612841Sgabeblack@google.com}; 47712841Sgabeblack@google.com 47812841Sgabeblack@google.comtemplate <> 47912841Sgabeblack@google.cominline void 48013245Sgabeblack@google.comsc_trace<sc_dt::sc_logic>(sc_trace_file *tf, const sc_in<sc_dt::sc_logic> &i, 48113245Sgabeblack@google.com const std::string &name) 48212841Sgabeblack@google.com{ 48313269Sgabeblack@google.com if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION) 48413269Sgabeblack@google.com i.add_trace(tf, name); 48513269Sgabeblack@google.com else 48613245Sgabeblack@google.com sc_trace(tf, i->read(), name); 48712841Sgabeblack@google.com} 48812841Sgabeblack@google.com 48912841Sgabeblack@google.com} // namespace sc_core 49012841Sgabeblack@google.com 49112841Sgabeblack@google.com#endif //__SYSTEMC_EXT_CHANNEL_SC_IN_HH__ 492