sc_in.hh revision 13269
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 22812841Sgabeblack@google.com virtual void 22913054Sgabeblack@google.com bind(const sc_signal_in_if<bool> &i) 23012841Sgabeblack@google.com { 23113054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>::bind( 23213054Sgabeblack@google.com const_cast<sc_signal_in_if<bool> &>(i)); 23313054Sgabeblack@google.com } 23413054Sgabeblack@google.com void operator () (const sc_signal_in_if<bool> &i) { bind(i); } 23513054Sgabeblack@google.com 23613054Sgabeblack@google.com virtual void 23713054Sgabeblack@google.com bind(sc_port<sc_signal_in_if<bool>, 1> &p) 23813054Sgabeblack@google.com { 23913054Sgabeblack@google.com sc_port<sc_signal_in_if<bool>, 1>::bind(p); 24012841Sgabeblack@google.com } 24112841Sgabeblack@google.com void 24213054Sgabeblack@google.com operator () (sc_port<sc_signal_in_if<bool>, 1> &p) 24312841Sgabeblack@google.com { 24413054Sgabeblack@google.com bind(p); 24512841Sgabeblack@google.com } 24612841Sgabeblack@google.com 24712841Sgabeblack@google.com virtual void 24813054Sgabeblack@google.com bind(sc_port<sc_signal_inout_if<bool>, 1> &p) 24912841Sgabeblack@google.com { 25013054Sgabeblack@google.com sc_port_base::bind(p); 25112841Sgabeblack@google.com } 25212841Sgabeblack@google.com void 25313054Sgabeblack@google.com operator () (sc_port<sc_signal_inout_if<bool>, 1> &p) 25412841Sgabeblack@google.com { 25513054Sgabeblack@google.com bind(p); 25612841Sgabeblack@google.com } 25712841Sgabeblack@google.com 25813245Sgabeblack@google.com virtual void 25913245Sgabeblack@google.com end_of_elaboration() 26013245Sgabeblack@google.com { 26113245Sgabeblack@google.com for (auto params: traceParamsVec) 26213245Sgabeblack@google.com sc_trace(params->tf, (*this)->read(), params->name); 26313245Sgabeblack@google.com 26413245Sgabeblack@google.com traceParamsVec.clear(); 26513245Sgabeblack@google.com } 26612841Sgabeblack@google.com 26713054Sgabeblack@google.com const bool &read() const { return (*this)->read(); } 26813054Sgabeblack@google.com operator const bool& () const { return (*this)->read(); } 26912841Sgabeblack@google.com 27013054Sgabeblack@google.com const sc_event &default_event() const { return (*this)->default_event(); } 27112841Sgabeblack@google.com const sc_event & 27212841Sgabeblack@google.com value_changed_event() const 27312841Sgabeblack@google.com { 27413054Sgabeblack@google.com return (*this)->value_changed_event(); 27512841Sgabeblack@google.com } 27612841Sgabeblack@google.com const sc_event & 27712841Sgabeblack@google.com posedge_event() const 27812841Sgabeblack@google.com { 27913054Sgabeblack@google.com return (*this)->posedge_event(); 28012841Sgabeblack@google.com } 28112841Sgabeblack@google.com const sc_event & 28212841Sgabeblack@google.com negedge_event() const 28312841Sgabeblack@google.com { 28413054Sgabeblack@google.com return (*this)->negedge_event(); 28512841Sgabeblack@google.com } 28612841Sgabeblack@google.com 28713054Sgabeblack@google.com bool event() const { return (*this)->event(); } 28813054Sgabeblack@google.com bool posedge() const { return (*this)->posedge(); } 28913054Sgabeblack@google.com bool negedge() const { return (*this)->negedge(); } 29012841Sgabeblack@google.com 29113054Sgabeblack@google.com sc_event_finder &value_changed() const { return _valueChangedFinder; } 29213054Sgabeblack@google.com sc_event_finder &pos() const { return _posFinder; } 29313054Sgabeblack@google.com sc_event_finder &neg() const { return _negFinder; } 29412841Sgabeblack@google.com 29512841Sgabeblack@google.com virtual const char *kind() const { return "sc_in"; } 29612841Sgabeblack@google.com 29713245Sgabeblack@google.com void 29813245Sgabeblack@google.com add_trace(sc_trace_file *tf, const std::string &name) const 29913245Sgabeblack@google.com { 30013245Sgabeblack@google.com traceParamsVec.push_back(new sc_trace_params(tf, name)); 30113245Sgabeblack@google.com } 30213245Sgabeblack@google.com 30312841Sgabeblack@google.com private: 30413054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<bool> > _valueChangedFinder; 30513054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<bool> > _posFinder; 30613054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<bool> > _negFinder; 30713054Sgabeblack@google.com 30813245Sgabeblack@google.com mutable sc_trace_params_vec traceParamsVec; 30913245Sgabeblack@google.com 31012841Sgabeblack@google.com // Disabled 31113054Sgabeblack@google.com sc_in(const sc_in<bool> &); 31213054Sgabeblack@google.com sc_in<bool> &operator = (const sc_in<bool> &); 31312841Sgabeblack@google.com}; 31412841Sgabeblack@google.com 31512841Sgabeblack@google.comtemplate <> 31612841Sgabeblack@google.cominline void 31713245Sgabeblack@google.comsc_trace<bool>(sc_trace_file *tf, const sc_in<bool> &i, 31813245Sgabeblack@google.com const std::string &name) 31912841Sgabeblack@google.com{ 32013269Sgabeblack@google.com if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION) 32113269Sgabeblack@google.com i.add_trace(tf, name); 32213269Sgabeblack@google.com else 32313245Sgabeblack@google.com sc_trace(tf, i->read(), name); 32412841Sgabeblack@google.com} 32512841Sgabeblack@google.com 32612841Sgabeblack@google.comtemplate <> 32712841Sgabeblack@google.comclass sc_in<sc_dt::sc_logic> : 32812841Sgabeblack@google.com public sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> 32912841Sgabeblack@google.com{ 33012841Sgabeblack@google.com public: 33113054Sgabeblack@google.com sc_in() : sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(), 33213054Sgabeblack@google.com _valueChangedFinder(*this, 33313054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 33413054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 33513054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 33613054Sgabeblack@google.com {} 33712841Sgabeblack@google.com explicit sc_in(const char *name) : 33813054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name), 33913054Sgabeblack@google.com _valueChangedFinder(*this, 34013054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 34113054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 34213054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 34312841Sgabeblack@google.com {} 34412841Sgabeblack@google.com virtual ~sc_in() {} 34512841Sgabeblack@google.com 34612868Sgabeblack@google.com // Deprecated binding constructors. 34712868Sgabeblack@google.com explicit sc_in(const sc_signal_in_if<sc_dt::sc_logic> &interface) : 34813054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(interface), 34913054Sgabeblack@google.com _valueChangedFinder(*this, 35013054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 35113054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 35213054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 35312868Sgabeblack@google.com {} 35412868Sgabeblack@google.com sc_in(const char *name, 35512868Sgabeblack@google.com const sc_signal_in_if<sc_dt::sc_logic> &interface) : 35613054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name, interface), 35713054Sgabeblack@google.com _valueChangedFinder(*this, 35813054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 35913054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 36013054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 36112868Sgabeblack@google.com {} 36212868Sgabeblack@google.com explicit sc_in(sc_port_b<sc_signal_in_if<sc_dt::sc_logic> > &parent) : 36313054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(parent), 36413054Sgabeblack@google.com _valueChangedFinder(*this, 36513054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 36613054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 36713054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 36812868Sgabeblack@google.com {} 36912868Sgabeblack@google.com sc_in(const char *name, 37012868Sgabeblack@google.com sc_port_b<sc_signal_in_if<sc_dt::sc_logic> > &parent) : 37113054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name, parent), 37213054Sgabeblack@google.com _valueChangedFinder(*this, 37313054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 37413054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 37513054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 37612868Sgabeblack@google.com {} 37712868Sgabeblack@google.com explicit sc_in(sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &parent) : 37813054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(parent), 37913054Sgabeblack@google.com _valueChangedFinder(*this, 38013054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 38113054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 38213054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 38312868Sgabeblack@google.com {} 38412868Sgabeblack@google.com sc_in(const char *name, 38512868Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &parent) : 38613054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>(name, parent), 38713054Sgabeblack@google.com _valueChangedFinder(*this, 38813054Sgabeblack@google.com &sc_signal_in_if<sc_dt::sc_logic>::value_changed_event), 38913054Sgabeblack@google.com _posFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::posedge_event), 39013054Sgabeblack@google.com _negFinder(*this, &sc_signal_in_if<sc_dt::sc_logic>::negedge_event) 39112868Sgabeblack@google.com {} 39212868Sgabeblack@google.com 39312841Sgabeblack@google.com virtual void 39413054Sgabeblack@google.com bind(const sc_signal_in_if<sc_dt::sc_logic> &i) 39512841Sgabeblack@google.com { 39613054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>::bind( 39713054Sgabeblack@google.com const_cast<sc_signal_in_if<sc_dt::sc_logic> &>(i)); 39812841Sgabeblack@google.com } 39912841Sgabeblack@google.com void 40013054Sgabeblack@google.com operator () (const sc_signal_in_if<sc_dt::sc_logic> &i) { bind(i); } 40113054Sgabeblack@google.com 40213054Sgabeblack@google.com virtual void 40313054Sgabeblack@google.com bind(sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &i) 40412841Sgabeblack@google.com { 40513054Sgabeblack@google.com sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1>::bind(i); 40613054Sgabeblack@google.com } 40713054Sgabeblack@google.com void 40813054Sgabeblack@google.com operator () (sc_port<sc_signal_in_if<sc_dt::sc_logic>, 1> &p) 40913054Sgabeblack@google.com { 41013054Sgabeblack@google.com bind(p); 41112841Sgabeblack@google.com } 41212841Sgabeblack@google.com 41312841Sgabeblack@google.com virtual void 41413054Sgabeblack@google.com bind(sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1> &p) 41512841Sgabeblack@google.com { 41613054Sgabeblack@google.com sc_port_base::bind(p); 41712841Sgabeblack@google.com } 41812841Sgabeblack@google.com void 41913054Sgabeblack@google.com operator () (sc_port<sc_signal_inout_if<sc_dt::sc_logic>, 1> &p) 42012841Sgabeblack@google.com { 42113054Sgabeblack@google.com bind(p); 42212841Sgabeblack@google.com } 42312841Sgabeblack@google.com 42413245Sgabeblack@google.com virtual void 42513245Sgabeblack@google.com end_of_elaboration() 42613245Sgabeblack@google.com { 42713245Sgabeblack@google.com for (auto params: traceParamsVec) 42813245Sgabeblack@google.com sc_trace(params->tf, (*this)->read(), params->name); 42913245Sgabeblack@google.com 43013245Sgabeblack@google.com traceParamsVec.clear(); 43113245Sgabeblack@google.com } 43212841Sgabeblack@google.com 43313054Sgabeblack@google.com const sc_dt::sc_logic &read() const { return (*this)->read(); } 43413054Sgabeblack@google.com operator const sc_dt::sc_logic& () const { return (*this)->read(); } 43512841Sgabeblack@google.com 43613054Sgabeblack@google.com const sc_event &default_event() const { return (*this)->default_event(); } 43712841Sgabeblack@google.com const sc_event & 43812841Sgabeblack@google.com value_changed_event() const 43912841Sgabeblack@google.com { 44013054Sgabeblack@google.com return (*this)->value_changed_event(); 44112841Sgabeblack@google.com } 44213054Sgabeblack@google.com const sc_event &posedge_event() const { return (*this)->posedge_event(); } 44313054Sgabeblack@google.com const sc_event &negedge_event() const { return (*this)->negedge_event(); } 44412841Sgabeblack@google.com 44513054Sgabeblack@google.com bool event() const { return (*this)->event(); } 44613054Sgabeblack@google.com bool posedge() const { return (*this)->posedge(); } 44713054Sgabeblack@google.com bool negedge() const { return (*this)->negedge(); } 44812841Sgabeblack@google.com 44913054Sgabeblack@google.com sc_event_finder &value_changed() const { return _valueChangedFinder; } 45013054Sgabeblack@google.com sc_event_finder &pos() const { return _posFinder; } 45113054Sgabeblack@google.com sc_event_finder &neg() const { return _negFinder; } 45212841Sgabeblack@google.com 45312841Sgabeblack@google.com virtual const char *kind() const { return "sc_in"; } 45412841Sgabeblack@google.com 45513245Sgabeblack@google.com void 45613245Sgabeblack@google.com add_trace(sc_trace_file *tf, const std::string &name) const 45713245Sgabeblack@google.com { 45813245Sgabeblack@google.com traceParamsVec.push_back(new sc_trace_params(tf, name)); 45913245Sgabeblack@google.com } 46013245Sgabeblack@google.com 46112841Sgabeblack@google.com private: 46213054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > 46313054Sgabeblack@google.com _valueChangedFinder; 46413054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > _posFinder; 46513054Sgabeblack@google.com mutable sc_event_finder_t<sc_signal_in_if<sc_dt::sc_logic> > _negFinder; 46613054Sgabeblack@google.com 46713245Sgabeblack@google.com mutable sc_trace_params_vec traceParamsVec; 46813245Sgabeblack@google.com 46912841Sgabeblack@google.com // Disabled 47013054Sgabeblack@google.com sc_in(const sc_in<sc_dt::sc_logic> &); 47113054Sgabeblack@google.com sc_in<sc_dt::sc_logic> &operator = (const sc_in<sc_dt::sc_logic> &); 47212841Sgabeblack@google.com}; 47312841Sgabeblack@google.com 47412841Sgabeblack@google.comtemplate <> 47512841Sgabeblack@google.cominline void 47613245Sgabeblack@google.comsc_trace<sc_dt::sc_logic>(sc_trace_file *tf, const sc_in<sc_dt::sc_logic> &i, 47713245Sgabeblack@google.com const std::string &name) 47812841Sgabeblack@google.com{ 47913269Sgabeblack@google.com if (::sc_core::sc_get_status() < ::sc_core::SC_START_OF_SIMULATION) 48013269Sgabeblack@google.com i.add_trace(tf, name); 48113269Sgabeblack@google.com else 48213245Sgabeblack@google.com sc_trace(tf, i->read(), name); 48312841Sgabeblack@google.com} 48412841Sgabeblack@google.com 48512841Sgabeblack@google.com} // namespace sc_core 48612841Sgabeblack@google.com 48712841Sgabeblack@google.com#endif //__SYSTEMC_EXT_CHANNEL_SC_IN_HH__ 488