sc_signal.hh revision 13288
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_SIGNAL_HH__ 3112841Sgabeblack@google.com#define __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 3212841Sgabeblack@google.com 3312841Sgabeblack@google.com#include <iostream> 3412933Sgabeblack@google.com#include <string> 3512933Sgabeblack@google.com#include <vector> 3612841Sgabeblack@google.com 3713044Sgabeblack@google.com#include "../core/sc_event.hh" 3812841Sgabeblack@google.com#include "../core/sc_module.hh" // for sc_gen_unique_name 3912841Sgabeblack@google.com#include "../core/sc_prim.hh" 4013044Sgabeblack@google.com#include "../dt/bit/sc_logic.hh" 4112841Sgabeblack@google.com#include "sc_signal_inout_if.hh" 4212841Sgabeblack@google.com 4312841Sgabeblack@google.comnamespace sc_core 4412841Sgabeblack@google.com{ 4512841Sgabeblack@google.com 4612841Sgabeblack@google.comclass sc_port_base; 4712841Sgabeblack@google.com 4813277Sgabeblack@google.com} // namespace sc_core 4913277Sgabeblack@google.com 5013277Sgabeblack@google.comnamespace sc_gem5 5113277Sgabeblack@google.com{ 5213277Sgabeblack@google.com 5313277Sgabeblack@google.comclass Process; 5413288Sgabeblack@google.comclass Reset; 5513277Sgabeblack@google.com 5613277Sgabeblack@google.comclass ScSignalBase : public sc_core::sc_prim_channel 5712841Sgabeblack@google.com{ 5812841Sgabeblack@google.com public: 5913277Sgabeblack@google.com virtual const char *kind() const { return "sc_signal"; } 6013277Sgabeblack@google.com 6113277Sgabeblack@google.com protected: 6213277Sgabeblack@google.com ScSignalBase(const char *_name); 6313277Sgabeblack@google.com virtual ~ScSignalBase(); 6413277Sgabeblack@google.com 6513277Sgabeblack@google.com const sc_core::sc_event &defaultEvent() const; 6613277Sgabeblack@google.com const sc_core::sc_event &valueChangedEvent() const; 6713277Sgabeblack@google.com 6813277Sgabeblack@google.com bool event() const; 6913277Sgabeblack@google.com 7013277Sgabeblack@google.com void _signalChange(); 7113277Sgabeblack@google.com 7213277Sgabeblack@google.com virtual sc_core::sc_writer_policy get_writer_policy() const = 0; 7313277Sgabeblack@google.com 7413277Sgabeblack@google.com sc_core::sc_event _valueChangedEvent; 7513277Sgabeblack@google.com uint64_t _changeStamp; 7613277Sgabeblack@google.com sc_core::sc_port_base *_gem5WriterPort; 7713277Sgabeblack@google.com}; 7813277Sgabeblack@google.com 7913277Sgabeblack@google.comclass ScSignalBaseBinary : public ScSignalBase 8013277Sgabeblack@google.com{ 8113277Sgabeblack@google.com protected: 8213277Sgabeblack@google.com ScSignalBaseBinary(const char *_name); 8313277Sgabeblack@google.com 8413288Sgabeblack@google.com mutable std::vector<sc_gem5::Reset *> _resets; 8513288Sgabeblack@google.com void _signalReset(sc_gem5::Reset *reset); 8613288Sgabeblack@google.com void _signalReset(); 8713288Sgabeblack@google.com 8813277Sgabeblack@google.com const sc_core::sc_event &posedgeEvent() const; 8913277Sgabeblack@google.com const sc_core::sc_event &negedgeEvent() const; 9013277Sgabeblack@google.com 9113277Sgabeblack@google.com bool posedge() const; 9213277Sgabeblack@google.com bool negedge() const; 9313277Sgabeblack@google.com 9413277Sgabeblack@google.com sc_core::sc_event _posedgeEvent; 9513277Sgabeblack@google.com sc_core::sc_event _negedgeEvent; 9613277Sgabeblack@google.com 9713277Sgabeblack@google.com uint64_t _posStamp; 9813277Sgabeblack@google.com uint64_t _negStamp; 9913277Sgabeblack@google.com}; 10013277Sgabeblack@google.com 10113277Sgabeblack@google.comtemplate <class T> 10213277Sgabeblack@google.comclass ScSignalBasePicker : public ScSignalBase 10313277Sgabeblack@google.com{ 10413277Sgabeblack@google.com protected: 10513277Sgabeblack@google.com ScSignalBasePicker(const char *_name) : ScSignalBase(_name) {} 10613277Sgabeblack@google.com}; 10713277Sgabeblack@google.com 10813277Sgabeblack@google.comtemplate <> 10913277Sgabeblack@google.comclass ScSignalBasePicker<bool> : public ScSignalBaseBinary 11013277Sgabeblack@google.com{ 11113277Sgabeblack@google.com protected: 11213277Sgabeblack@google.com ScSignalBasePicker(const char *_name) : ScSignalBaseBinary(_name) {} 11313277Sgabeblack@google.com}; 11413277Sgabeblack@google.com 11513277Sgabeblack@google.comtemplate <> 11613277Sgabeblack@google.comclass ScSignalBasePicker<sc_dt::sc_logic> : public ScSignalBaseBinary 11713277Sgabeblack@google.com{ 11813277Sgabeblack@google.com protected: 11913277Sgabeblack@google.com ScSignalBasePicker(const char *_name) : ScSignalBaseBinary(_name) {} 12013277Sgabeblack@google.com}; 12113277Sgabeblack@google.com 12213277Sgabeblack@google.comtemplate <sc_core::sc_writer_policy WRITER_POLICY> 12313277Sgabeblack@google.comclass WriteChecker; 12413277Sgabeblack@google.com 12513277Sgabeblack@google.comtemplate <> 12613277Sgabeblack@google.comclass WriteChecker<sc_core::SC_ONE_WRITER> 12713277Sgabeblack@google.com{ 12813277Sgabeblack@google.com public: 12913277Sgabeblack@google.com WriteChecker(ScSignalBase *_sig); 13013277Sgabeblack@google.com 13113277Sgabeblack@google.com void checkPort(sc_core::sc_port_base &port, 13213277Sgabeblack@google.com std::string iface_type_name, std::string out_name); 13313277Sgabeblack@google.com void checkWriter(); 13413277Sgabeblack@google.com 13513277Sgabeblack@google.com private: 13613277Sgabeblack@google.com ScSignalBase *sig; 13713277Sgabeblack@google.com sc_core::sc_port_base *firstPort; 13813277Sgabeblack@google.com Process *proc; 13913277Sgabeblack@google.com uint64_t writeStamp; 14013277Sgabeblack@google.com}; 14113277Sgabeblack@google.com 14213277Sgabeblack@google.comtemplate <> 14313277Sgabeblack@google.comclass WriteChecker<sc_core::SC_MANY_WRITERS> 14413277Sgabeblack@google.com{ 14513277Sgabeblack@google.com public: 14613277Sgabeblack@google.com WriteChecker(ScSignalBase *_sig); 14713277Sgabeblack@google.com 14813277Sgabeblack@google.com void checkPort(sc_core::sc_port_base &port, 14913277Sgabeblack@google.com std::string iface_type_name, std::string out_name); 15013277Sgabeblack@google.com void checkWriter(); 15113277Sgabeblack@google.com 15213277Sgabeblack@google.com private: 15313277Sgabeblack@google.com ScSignalBase *sig; 15413277Sgabeblack@google.com Process *proc; 15513277Sgabeblack@google.com uint64_t writeStamp; 15613277Sgabeblack@google.com}; 15713277Sgabeblack@google.com 15813277Sgabeblack@google.comtemplate <class T, sc_core::sc_writer_policy WRITER_POLICY> 15913277Sgabeblack@google.comclass ScSignalBaseT : 16013277Sgabeblack@google.com public ScSignalBasePicker<T>, public sc_core::sc_signal_inout_if<T> 16113277Sgabeblack@google.com{ 16213277Sgabeblack@google.com public: 16313277Sgabeblack@google.com ScSignalBaseT(const char *_name) : 16413277Sgabeblack@google.com ScSignalBasePicker<T>(_name), m_cur_val(T()), m_new_val(T()), 16513277Sgabeblack@google.com _checker(this) 16612841Sgabeblack@google.com {} 16713277Sgabeblack@google.com ScSignalBaseT(const char *_name, const T &initial_value) : 16813277Sgabeblack@google.com ScSignalBasePicker<T>(_name), m_cur_val(initial_value), 16913277Sgabeblack@google.com m_new_val(initial_value), _checker(this) 17012841Sgabeblack@google.com {} 17113277Sgabeblack@google.com virtual ~ScSignalBaseT() {} 17212841Sgabeblack@google.com 17312841Sgabeblack@google.com virtual void 17413277Sgabeblack@google.com register_port(sc_core::sc_port_base &port, const char *iface_type_name) 17512841Sgabeblack@google.com { 17613277Sgabeblack@google.com# if !defined(SC_NO_WRITE_CHECK) 17713277Sgabeblack@google.com { 17813277Sgabeblack@google.com _checker.checkPort(port, iface_type_name, 17913277Sgabeblack@google.com typeid(sc_core::sc_signal_inout_if<T>).name()); 18013274Sgabeblack@google.com } 18113277Sgabeblack@google.com# endif 18212841Sgabeblack@google.com } 18312841Sgabeblack@google.com 18413044Sgabeblack@google.com virtual const T &read() const { return m_cur_val; } 18513044Sgabeblack@google.com operator const T&() const { return read(); } 18612841Sgabeblack@google.com 18712841Sgabeblack@google.com virtual void 18813044Sgabeblack@google.com write(const T &t) 18912841Sgabeblack@google.com { 19013277Sgabeblack@google.com# if !defined(SC_NO_WRITE_CHECK) 19113277Sgabeblack@google.com { 19213277Sgabeblack@google.com _checker.checkWriter(); 19313277Sgabeblack@google.com } 19413277Sgabeblack@google.com# endif 19513044Sgabeblack@google.com m_new_val = t; 19613044Sgabeblack@google.com bool changed = !(m_cur_val == m_new_val); 19713044Sgabeblack@google.com if (changed) 19813277Sgabeblack@google.com this->request_update(); 19912841Sgabeblack@google.com } 20012841Sgabeblack@google.com 20113277Sgabeblack@google.com virtual const sc_core::sc_event & 20212841Sgabeblack@google.com default_event() const 20312841Sgabeblack@google.com { 20413277Sgabeblack@google.com return ScSignalBase::defaultEvent(); 20512841Sgabeblack@google.com } 20613277Sgabeblack@google.com 20713277Sgabeblack@google.com virtual const sc_core::sc_event & 20812841Sgabeblack@google.com value_changed_event() const 20912841Sgabeblack@google.com { 21013277Sgabeblack@google.com return ScSignalBase::valueChangedEvent(); 21112841Sgabeblack@google.com } 21212841Sgabeblack@google.com 21313044Sgabeblack@google.com virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; } 21412841Sgabeblack@google.com virtual void 21513044Sgabeblack@google.com dump(std::ostream &os=std::cout) const 21612841Sgabeblack@google.com { 21713277Sgabeblack@google.com os << " name = " << this->name() << ::std::endl; 21813044Sgabeblack@google.com os << " value = " << m_cur_val << ::std::endl; 21913044Sgabeblack@google.com os << "new value = " << m_new_val << ::std::endl; 22012841Sgabeblack@google.com } 22113277Sgabeblack@google.com 22213277Sgabeblack@google.com virtual bool event() const { return ScSignalBase::event(); } 22313277Sgabeblack@google.com 22413277Sgabeblack@google.com virtual sc_core::sc_writer_policy 22513277Sgabeblack@google.com get_writer_policy() const 22613277Sgabeblack@google.com { 22713277Sgabeblack@google.com return WRITER_POLICY; 22813277Sgabeblack@google.com } 22912841Sgabeblack@google.com 23012841Sgabeblack@google.com protected: 23112945Sgabeblack@google.com // These members which store the current and future value of the signal 23212945Sgabeblack@google.com // are not specified in the standard but are referred to directly by one 23312945Sgabeblack@google.com // of the tests. 23412945Sgabeblack@google.com T m_cur_val; 23512945Sgabeblack@google.com T m_new_val; 23612945Sgabeblack@google.com 23713277Sgabeblack@google.com WriteChecker<WRITER_POLICY> _checker; 23813277Sgabeblack@google.com}; 23913277Sgabeblack@google.com 24013277Sgabeblack@google.comtemplate <typename T, sc_core::sc_writer_policy WRITER_POLICY> 24113277Sgabeblack@google.comclass ScSignalBinary : public ScSignalBaseT<T, WRITER_POLICY> 24213277Sgabeblack@google.com{ 24313277Sgabeblack@google.com public: 24413277Sgabeblack@google.com ScSignalBinary(const char *_name) : ScSignalBaseT<T, WRITER_POLICY>(_name) 24513277Sgabeblack@google.com {} 24613277Sgabeblack@google.com ScSignalBinary(const char *_name, const T& initial_value) : 24713277Sgabeblack@google.com ScSignalBaseT<T, WRITER_POLICY>(_name, initial_value) 24813277Sgabeblack@google.com {} 24913277Sgabeblack@google.com 25013277Sgabeblack@google.com const sc_core::sc_event & 25113277Sgabeblack@google.com posedge_event() const 25213277Sgabeblack@google.com { 25313277Sgabeblack@google.com return ScSignalBaseBinary::posedgeEvent(); 25413277Sgabeblack@google.com } 25513277Sgabeblack@google.com const sc_core::sc_event & 25613277Sgabeblack@google.com negedge_event() const 25713277Sgabeblack@google.com { 25813277Sgabeblack@google.com return ScSignalBaseBinary::negedgeEvent(); 25913277Sgabeblack@google.com } 26013277Sgabeblack@google.com 26113277Sgabeblack@google.com bool posedge() const { return ScSignalBaseBinary::posedge(); } 26213277Sgabeblack@google.com bool negedge() const { return ScSignalBaseBinary::negedge(); } 26313277Sgabeblack@google.com}; 26413277Sgabeblack@google.com 26513277Sgabeblack@google.com} // namespace sc_gem5 26613277Sgabeblack@google.com 26713277Sgabeblack@google.comnamespace sc_core 26813277Sgabeblack@google.com{ 26913277Sgabeblack@google.com 27013277Sgabeblack@google.comtemplate <class T, sc_writer_policy WRITER_POLICY=SC_ONE_WRITER> 27113277Sgabeblack@google.comclass sc_signal : public sc_gem5::ScSignalBaseT<T, WRITER_POLICY> 27213277Sgabeblack@google.com{ 27313277Sgabeblack@google.com public: 27413277Sgabeblack@google.com sc_signal() : sc_gem5::ScSignalBaseT<T, WRITER_POLICY>( 27513277Sgabeblack@google.com sc_gen_unique_name("signal")) 27613277Sgabeblack@google.com {} 27713277Sgabeblack@google.com explicit sc_signal(const char *name) : 27813277Sgabeblack@google.com sc_gem5::ScSignalBaseT<T, WRITER_POLICY>(name) 27913277Sgabeblack@google.com {} 28013277Sgabeblack@google.com explicit sc_signal(const char *name, const T &initial_value) : 28113277Sgabeblack@google.com sc_gem5::ScSignalBaseT<T, WRITER_POLICY>(name, initial_value) 28213277Sgabeblack@google.com {} 28313277Sgabeblack@google.com virtual ~sc_signal() {} 28413277Sgabeblack@google.com 28513277Sgabeblack@google.com sc_signal<T, WRITER_POLICY> & 28613277Sgabeblack@google.com operator = (const T &t) 28713277Sgabeblack@google.com { 28813277Sgabeblack@google.com this->write(t); 28913277Sgabeblack@google.com return *this; 29013277Sgabeblack@google.com } 29113277Sgabeblack@google.com sc_signal<T, WRITER_POLICY> & 29213277Sgabeblack@google.com operator = (const sc_signal<T, WRITER_POLICY> &s) 29313277Sgabeblack@google.com { 29413277Sgabeblack@google.com this->write(s.read()); 29513277Sgabeblack@google.com return *this; 29613277Sgabeblack@google.com } 29713277Sgabeblack@google.com 29813277Sgabeblack@google.com protected: 29913277Sgabeblack@google.com virtual void 30013277Sgabeblack@google.com update() 30113277Sgabeblack@google.com { 30213277Sgabeblack@google.com if (this->m_new_val == this->m_cur_val) 30313277Sgabeblack@google.com return; 30413277Sgabeblack@google.com 30513277Sgabeblack@google.com this->m_cur_val = this->m_new_val; 30613277Sgabeblack@google.com this->_signalChange(); 30713277Sgabeblack@google.com } 30813277Sgabeblack@google.com 30912841Sgabeblack@google.com private: 31012841Sgabeblack@google.com // Disabled 31113277Sgabeblack@google.com sc_signal(const sc_signal<T, WRITER_POLICY> &); 31212841Sgabeblack@google.com}; 31312841Sgabeblack@google.com 31412841Sgabeblack@google.comtemplate <class T, sc_writer_policy WRITER_POLICY> 31512841Sgabeblack@google.cominline std::ostream & 31613142Sgabeblack@google.comoperator << (std::ostream &os, const sc_signal<T, WRITER_POLICY> &s) 31712841Sgabeblack@google.com{ 31813142Sgabeblack@google.com os << s.read(); 31912841Sgabeblack@google.com return os; 32012841Sgabeblack@google.com} 32112841Sgabeblack@google.com 32212841Sgabeblack@google.comtemplate <sc_writer_policy WRITER_POLICY> 32312841Sgabeblack@google.comclass sc_signal<bool, WRITER_POLICY> : 32413277Sgabeblack@google.com public sc_gem5::ScSignalBinary<bool, WRITER_POLICY> 32512841Sgabeblack@google.com{ 32612841Sgabeblack@google.com public: 32713277Sgabeblack@google.com sc_signal() : 32813277Sgabeblack@google.com sc_gem5::ScSignalBinary<bool, WRITER_POLICY>( 32913277Sgabeblack@google.com sc_gen_unique_name("signal")) 33013044Sgabeblack@google.com {} 33113044Sgabeblack@google.com explicit sc_signal(const char *name) : 33213277Sgabeblack@google.com sc_gem5::ScSignalBinary<bool, WRITER_POLICY>(name) 33313044Sgabeblack@google.com {} 33412912Sgabeblack@google.com explicit sc_signal(const char *name, const bool &initial_value) : 33513277Sgabeblack@google.com sc_gem5::ScSignalBinary<bool, WRITER_POLICY>(name, initial_value) 33613044Sgabeblack@google.com {} 33713044Sgabeblack@google.com virtual ~sc_signal() {} 33812841Sgabeblack@google.com 33912841Sgabeblack@google.com sc_signal<bool, WRITER_POLICY> & 34013044Sgabeblack@google.com operator = (const bool &b) 34112841Sgabeblack@google.com { 34213277Sgabeblack@google.com this->write(b); 34312841Sgabeblack@google.com return *this; 34412841Sgabeblack@google.com } 34512841Sgabeblack@google.com sc_signal<bool, WRITER_POLICY> & 34613044Sgabeblack@google.com operator = (const sc_signal<bool, WRITER_POLICY> &s) 34712841Sgabeblack@google.com { 34813277Sgabeblack@google.com this->write(s.read()); 34912841Sgabeblack@google.com return *this; 35012841Sgabeblack@google.com } 35112841Sgabeblack@google.com 35212841Sgabeblack@google.com protected: 35312841Sgabeblack@google.com virtual void 35412841Sgabeblack@google.com update() 35512841Sgabeblack@google.com { 35613277Sgabeblack@google.com if (this->m_new_val == this->m_cur_val) 35713044Sgabeblack@google.com return; 35813044Sgabeblack@google.com 35913277Sgabeblack@google.com this->m_cur_val = this->m_new_val; 36013288Sgabeblack@google.com this->_signalReset(); 36113277Sgabeblack@google.com this->_signalChange(); 36213277Sgabeblack@google.com if (this->m_cur_val) { 36313277Sgabeblack@google.com this->_posStamp = ::sc_gem5::getChangeStamp(); 36413277Sgabeblack@google.com this->_posedgeEvent.notify(SC_ZERO_TIME); 36513141Sgabeblack@google.com } else { 36613277Sgabeblack@google.com this->_negStamp = ::sc_gem5::getChangeStamp(); 36713277Sgabeblack@google.com this->_negedgeEvent.notify(SC_ZERO_TIME); 36813141Sgabeblack@google.com } 36912841Sgabeblack@google.com } 37012841Sgabeblack@google.com 37112841Sgabeblack@google.com private: 37213288Sgabeblack@google.com bool 37313288Sgabeblack@google.com _addReset(sc_gem5::Reset *reset) const 37413288Sgabeblack@google.com { 37513288Sgabeblack@google.com this->_resets.push_back(reset); 37613288Sgabeblack@google.com return true; 37713288Sgabeblack@google.com } 37813288Sgabeblack@google.com 37912841Sgabeblack@google.com // Disabled 38013277Sgabeblack@google.com sc_signal(const sc_signal<bool, WRITER_POLICY> &); 38112841Sgabeblack@google.com}; 38212841Sgabeblack@google.com 38312841Sgabeblack@google.comtemplate <sc_writer_policy WRITER_POLICY> 38412841Sgabeblack@google.comclass sc_signal<sc_dt::sc_logic, WRITER_POLICY> : 38513277Sgabeblack@google.com public sc_gem5::ScSignalBinary<sc_dt::sc_logic, WRITER_POLICY> 38612841Sgabeblack@google.com{ 38712841Sgabeblack@google.com public: 38813277Sgabeblack@google.com sc_signal() : 38913277Sgabeblack@google.com sc_gem5::ScSignalBinary<sc_dt::sc_logic, WRITER_POLICY>( 39013277Sgabeblack@google.com sc_gen_unique_name("signal")) 39113044Sgabeblack@google.com {} 39213044Sgabeblack@google.com explicit sc_signal(const char *name) : 39313277Sgabeblack@google.com sc_gem5::ScSignalBinary<sc_dt::sc_logic, WRITER_POLICY>(name) 39413044Sgabeblack@google.com {} 39512912Sgabeblack@google.com explicit sc_signal(const char *name, 39612912Sgabeblack@google.com const sc_dt::sc_logic &initial_value) : 39713277Sgabeblack@google.com sc_gem5::ScSignalBinary<sc_dt::sc_logic, WRITER_POLICY>( 39813277Sgabeblack@google.com name, initial_value) 39913044Sgabeblack@google.com {} 40013044Sgabeblack@google.com virtual ~sc_signal() {} 40112841Sgabeblack@google.com 40212841Sgabeblack@google.com sc_signal<sc_dt::sc_logic, WRITER_POLICY> & 40313044Sgabeblack@google.com operator = (const sc_dt::sc_logic &l) 40412841Sgabeblack@google.com { 40513277Sgabeblack@google.com this->write(l); 40612841Sgabeblack@google.com return *this; 40712841Sgabeblack@google.com } 40812841Sgabeblack@google.com sc_signal<sc_dt::sc_logic, WRITER_POLICY> & 40913044Sgabeblack@google.com operator = (const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &s) 41012841Sgabeblack@google.com { 41113277Sgabeblack@google.com this->write(s.read()); 41212841Sgabeblack@google.com return *this; 41312841Sgabeblack@google.com } 41412841Sgabeblack@google.com 41512841Sgabeblack@google.com protected: 41612841Sgabeblack@google.com virtual void 41712841Sgabeblack@google.com update() 41812841Sgabeblack@google.com { 41913277Sgabeblack@google.com if (this->m_new_val == this->m_cur_val) 42013044Sgabeblack@google.com return; 42113044Sgabeblack@google.com 42213277Sgabeblack@google.com this->m_cur_val = this->m_new_val; 42313277Sgabeblack@google.com this->_signalChange(); 42413277Sgabeblack@google.com if (this->m_cur_val == sc_dt::SC_LOGIC_1) { 42513277Sgabeblack@google.com this->_posStamp = ::sc_gem5::getChangeStamp(); 42613277Sgabeblack@google.com this->_posedgeEvent.notify(SC_ZERO_TIME); 42713277Sgabeblack@google.com } else if (this->m_cur_val == sc_dt::SC_LOGIC_0) { 42813277Sgabeblack@google.com this->_negStamp = ::sc_gem5::getChangeStamp(); 42913277Sgabeblack@google.com this->_negedgeEvent.notify(SC_ZERO_TIME); 43013205Sgabeblack@google.com } 43113205Sgabeblack@google.com } 43213205Sgabeblack@google.com 43312841Sgabeblack@google.com private: 43412841Sgabeblack@google.com // Disabled 43513277Sgabeblack@google.com sc_signal(const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &); 43612841Sgabeblack@google.com}; 43712841Sgabeblack@google.com 43812841Sgabeblack@google.com} // namespace sc_core 43912841Sgabeblack@google.com 44012841Sgabeblack@google.com#endif //__SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 441