sc_signal.hh revision 13044
112854Sgabeblack@google.com/* 212854Sgabeblack@google.com * Copyright 2018 Google, Inc. 312854Sgabeblack@google.com * 412854Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 512854Sgabeblack@google.com * modification, are permitted provided that the following conditions are 612854Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 712854Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 812854Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 912854Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1012854Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1112854Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1212854Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1312854Sgabeblack@google.com * this software without specific prior written permission. 1412854Sgabeblack@google.com * 1512854Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612854Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712854Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812854Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912854Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012854Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112854Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212854Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312854Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412854Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512854Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612854Sgabeblack@google.com * 2712854Sgabeblack@google.com * Authors: Gabe Black 2812854Sgabeblack@google.com */ 2912854Sgabeblack@google.com 3012854Sgabeblack@google.com#ifndef __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 3112854Sgabeblack@google.com#define __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 3212854Sgabeblack@google.com 3312854Sgabeblack@google.com#include <iostream> 3412854Sgabeblack@google.com#include <string> 3512854Sgabeblack@google.com#include <vector> 3612854Sgabeblack@google.com 3712854Sgabeblack@google.com#include "../core/sc_event.hh" 3812854Sgabeblack@google.com#include "../core/sc_module.hh" // for sc_gen_unique_name 3912854Sgabeblack@google.com#include "../core/sc_prim.hh" 4012854Sgabeblack@google.com#include "../dt/bit/sc_logic.hh" 4112854Sgabeblack@google.com#include "sc_signal_inout_if.hh" 4212854Sgabeblack@google.com#include "warn_unimpl.hh" // for warn_unimpl 4312854Sgabeblack@google.com 4412854Sgabeblack@google.comnamespace sc_core 4512854Sgabeblack@google.com{ 4612854Sgabeblack@google.com 4712854Sgabeblack@google.comclass sc_port_base; 4812854Sgabeblack@google.comclass sc_trace_file; 4912854Sgabeblack@google.com 5012854Sgabeblack@google.com// Nonstandard 5112854Sgabeblack@google.com// Despite having a warning "FOR INTERNAL USE ONLY!" in all caps above this 5212854Sgabeblack@google.com// class definition in the Accellera implementation, it appears in their 5312854Sgabeblack@google.com// examples and test programs, and so we need to have it here as well. 5412854Sgabeblack@google.comstruct sc_trace_params 5512854Sgabeblack@google.com{ 5613325Sgabeblack@google.com sc_trace_file *tf; 5712854Sgabeblack@google.com std::string name; 5812854Sgabeblack@google.com 5912854Sgabeblack@google.com sc_trace_params(sc_trace_file *tf, const std::string &name) : 6012854Sgabeblack@google.com tf(tf), name(name) 6112854Sgabeblack@google.com {} 6212854Sgabeblack@google.com}; 6312854Sgabeblack@google.comtypedef std::vector<sc_trace_params *> sc_trace_params_vec; 6412854Sgabeblack@google.com 6512854Sgabeblack@google.comtemplate <class T, sc_writer_policy WRITER_POLICY=SC_ONE_WRITER> 6612854Sgabeblack@google.comclass sc_signal : public sc_signal_inout_if<T>, 6712854Sgabeblack@google.com public sc_prim_channel 6812854Sgabeblack@google.com{ 6912854Sgabeblack@google.com public: 7012854Sgabeblack@google.com sc_signal() : sc_signal_inout_if<T>(), 7112854Sgabeblack@google.com sc_prim_channel(sc_gen_unique_name("signal")), 7212854Sgabeblack@google.com m_cur_val(T()), m_new_val(T()) 7312854Sgabeblack@google.com {} 7412854Sgabeblack@google.com explicit sc_signal(const char *name) : 7512854Sgabeblack@google.com sc_signal_inout_if<T>(), sc_prim_channel(name), 7612854Sgabeblack@google.com m_cur_val(T()), m_new_val(T()) 7712854Sgabeblack@google.com {} 7812854Sgabeblack@google.com explicit sc_signal(const char *name, const T &initial_value) : 7912854Sgabeblack@google.com sc_signal_inout_if<T>(), sc_prim_channel(name), 8012854Sgabeblack@google.com m_cur_val(initial_value), m_new_val(initial_value) 8112854Sgabeblack@google.com {} 8212854Sgabeblack@google.com virtual ~sc_signal() {} 8312854Sgabeblack@google.com 8412854Sgabeblack@google.com virtual void 8512854Sgabeblack@google.com register_port(sc_port_base &, const char *) 8612854Sgabeblack@google.com { 8712854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 8812854Sgabeblack@google.com } 8912854Sgabeblack@google.com 9012854Sgabeblack@google.com virtual const T &read() const { return m_cur_val; } 9112854Sgabeblack@google.com operator const T&() const { return read(); } 9212854Sgabeblack@google.com 9312854Sgabeblack@google.com virtual sc_writer_policy 9412854Sgabeblack@google.com get_writer_policy() const 9512854Sgabeblack@google.com { 9612854Sgabeblack@google.com return WRITER_POLICY; 9712854Sgabeblack@google.com } 9812854Sgabeblack@google.com virtual void 9912854Sgabeblack@google.com write(const T &t) 10012854Sgabeblack@google.com { 10112854Sgabeblack@google.com m_new_val = t; 10212854Sgabeblack@google.com bool changed = !(m_cur_val == m_new_val); 10312854Sgabeblack@google.com //TODO check whether this write follows the write policy. 10412854Sgabeblack@google.com if (changed) 10512854Sgabeblack@google.com request_update(); 10612854Sgabeblack@google.com } 10712854Sgabeblack@google.com sc_signal<T, WRITER_POLICY> & 10812854Sgabeblack@google.com operator = (const T &t) 10912854Sgabeblack@google.com { 11012854Sgabeblack@google.com write(t); 11112854Sgabeblack@google.com return *this; 11212854Sgabeblack@google.com } 11312854Sgabeblack@google.com sc_signal<T, WRITER_POLICY> & 11412854Sgabeblack@google.com operator = (const sc_signal<T, WRITER_POLICY> &s) 11512854Sgabeblack@google.com { 11612854Sgabeblack@google.com write(s.read()); 11712854Sgabeblack@google.com return *this; 11812854Sgabeblack@google.com } 11912854Sgabeblack@google.com 12012854Sgabeblack@google.com virtual const sc_event & 12112854Sgabeblack@google.com default_event() const 12212854Sgabeblack@google.com { 12312854Sgabeblack@google.com return value_changed_event(); 12412854Sgabeblack@google.com } 12512854Sgabeblack@google.com virtual const sc_event & 12612854Sgabeblack@google.com value_changed_event() const 12712854Sgabeblack@google.com { 12812854Sgabeblack@google.com return _valueChangedEvent; 12912854Sgabeblack@google.com } 13012854Sgabeblack@google.com virtual bool 13112854Sgabeblack@google.com event() const 13212854Sgabeblack@google.com { 13312854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 13412854Sgabeblack@google.com return false; 13512854Sgabeblack@google.com } 13612854Sgabeblack@google.com 13712854Sgabeblack@google.com virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; } 13812854Sgabeblack@google.com virtual void 13912854Sgabeblack@google.com dump(std::ostream &os=std::cout) const 14012854Sgabeblack@google.com { 14112854Sgabeblack@google.com os << " name = " << name() << ::std::endl; 14212854Sgabeblack@google.com os << " value = " << m_cur_val << ::std::endl; 14312854Sgabeblack@google.com os << "new value = " << m_new_val << ::std::endl; 14412854Sgabeblack@google.com } 14512854Sgabeblack@google.com virtual const char *kind() const { return "sc_signal"; } 14612854Sgabeblack@google.com 14712854Sgabeblack@google.com protected: 14812854Sgabeblack@google.com virtual void 14912854Sgabeblack@google.com update() 15012854Sgabeblack@google.com { 15112854Sgabeblack@google.com if (m_new_val == m_cur_val) 15212854Sgabeblack@google.com return; 15312854Sgabeblack@google.com 15412854Sgabeblack@google.com m_cur_val = m_new_val; 15512854Sgabeblack@google.com _valueChangedEvent.notify(SC_ZERO_TIME); 15612854Sgabeblack@google.com } 15712854Sgabeblack@google.com 15812854Sgabeblack@google.com // These members which store the current and future value of the signal 15912854Sgabeblack@google.com // are not specified in the standard but are referred to directly by one 16012854Sgabeblack@google.com // of the tests. 16112854Sgabeblack@google.com T m_cur_val; 16212854Sgabeblack@google.com T m_new_val; 16312854Sgabeblack@google.com 16412854Sgabeblack@google.com private: 16512854Sgabeblack@google.com sc_event _valueChangedEvent; 16612854Sgabeblack@google.com 16712854Sgabeblack@google.com // Disabled 16812854Sgabeblack@google.com sc_signal(const sc_signal<T, WRITER_POLICY> &) : 16912854Sgabeblack@google.com sc_signal_inout_if<T>(), sc_prim_channel("") 17012854Sgabeblack@google.com {} 17112854Sgabeblack@google.com}; 17212854Sgabeblack@google.com 17312854Sgabeblack@google.comtemplate <class T, sc_writer_policy WRITER_POLICY> 17412854Sgabeblack@google.cominline std::ostream & 17512854Sgabeblack@google.comoperator << (std::ostream &os, const sc_signal<T, WRITER_POLICY> &) 17612854Sgabeblack@google.com{ 17712854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 17812854Sgabeblack@google.com return os; 17912854Sgabeblack@google.com} 18012854Sgabeblack@google.com 18112854Sgabeblack@google.comtemplate <sc_writer_policy WRITER_POLICY> 18212854Sgabeblack@google.comclass sc_signal<bool, WRITER_POLICY> : 18312854Sgabeblack@google.com public sc_signal_inout_if<bool>, public sc_prim_channel 18412854Sgabeblack@google.com{ 18512854Sgabeblack@google.com public: 18612854Sgabeblack@google.com sc_signal() : sc_signal_inout_if<bool>(), 18712854Sgabeblack@google.com sc_prim_channel(sc_gen_unique_name("signal")), 18812854Sgabeblack@google.com m_cur_val(bool()), m_new_val(bool()) 18912854Sgabeblack@google.com {} 19012854Sgabeblack@google.com explicit sc_signal(const char *name) : 19112854Sgabeblack@google.com sc_signal_inout_if<bool>(), sc_prim_channel(name), 19212854Sgabeblack@google.com m_cur_val(bool()), m_new_val(bool()) 19312854Sgabeblack@google.com {} 19412854Sgabeblack@google.com explicit sc_signal(const char *name, const bool &initial_value) : 19512854Sgabeblack@google.com sc_signal_inout_if<bool>(), sc_prim_channel(name), 19612854Sgabeblack@google.com m_cur_val(initial_value), m_new_val(initial_value) 19712854Sgabeblack@google.com {} 19812854Sgabeblack@google.com virtual ~sc_signal() {} 19912854Sgabeblack@google.com 20012854Sgabeblack@google.com virtual void 20112854Sgabeblack@google.com register_port(sc_port_base &, const char *) 20212854Sgabeblack@google.com { 20312854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 20412854Sgabeblack@google.com } 20512854Sgabeblack@google.com 20612854Sgabeblack@google.com virtual const bool &read() const { return m_cur_val; } 20712854Sgabeblack@google.com operator const bool &() const { return read(); } 20812854Sgabeblack@google.com 20912854Sgabeblack@google.com virtual sc_writer_policy 21012854Sgabeblack@google.com get_writer_policy() const 21112854Sgabeblack@google.com { 21212854Sgabeblack@google.com return WRITER_POLICY; 21312854Sgabeblack@google.com } 21412854Sgabeblack@google.com virtual void 21512854Sgabeblack@google.com write(const bool &b) 21612854Sgabeblack@google.com { 21712854Sgabeblack@google.com m_new_val = b; 21812854Sgabeblack@google.com bool changed = !(m_cur_val == m_new_val); 21912854Sgabeblack@google.com //TODO check whether this write follows the write policy. 22012854Sgabeblack@google.com if (changed) 22112854Sgabeblack@google.com request_update(); 22212854Sgabeblack@google.com } 22312854Sgabeblack@google.com sc_signal<bool, WRITER_POLICY> & 22412854Sgabeblack@google.com operator = (const bool &b) 22512854Sgabeblack@google.com { 22612854Sgabeblack@google.com write(b); 22712854Sgabeblack@google.com return *this; 22812854Sgabeblack@google.com } 22912854Sgabeblack@google.com sc_signal<bool, WRITER_POLICY> & 23012854Sgabeblack@google.com operator = (const sc_signal<bool, WRITER_POLICY> &s) 23112854Sgabeblack@google.com { 23212854Sgabeblack@google.com write(s.read()); 23312854Sgabeblack@google.com return *this; 23412854Sgabeblack@google.com } 23512854Sgabeblack@google.com 23612854Sgabeblack@google.com virtual const sc_event & 23712854Sgabeblack@google.com default_event() const 23812854Sgabeblack@google.com { 23912854Sgabeblack@google.com return value_changed_event(); 24012854Sgabeblack@google.com } 24112854Sgabeblack@google.com 24212854Sgabeblack@google.com virtual const sc_event & 24312854Sgabeblack@google.com value_changed_event() const 24412854Sgabeblack@google.com { 24512854Sgabeblack@google.com return _valueChangedEvent; 24612854Sgabeblack@google.com } 24712854Sgabeblack@google.com virtual const sc_event & 24812854Sgabeblack@google.com posedge_event() const 24912854Sgabeblack@google.com { 25012854Sgabeblack@google.com return _posedgeEvent; 25112854Sgabeblack@google.com } 25212854Sgabeblack@google.com virtual const sc_event & 25312854Sgabeblack@google.com negedge_event() const 25412854Sgabeblack@google.com { 25512854Sgabeblack@google.com return _negedgeEvent; 25612854Sgabeblack@google.com } 25712854Sgabeblack@google.com 25812854Sgabeblack@google.com virtual bool 25912854Sgabeblack@google.com event() const 26012854Sgabeblack@google.com { 26112854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 26212854Sgabeblack@google.com return false; 26312854Sgabeblack@google.com } 26412854Sgabeblack@google.com virtual bool 26512854Sgabeblack@google.com posedge() const 26612854Sgabeblack@google.com { 26712854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 26812854Sgabeblack@google.com return false; 26912854Sgabeblack@google.com } 27012854Sgabeblack@google.com virtual bool 27112854Sgabeblack@google.com negedge() const 27212854Sgabeblack@google.com { 27312854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 27412854Sgabeblack@google.com return false; 27512854Sgabeblack@google.com } 27612854Sgabeblack@google.com 27712854Sgabeblack@google.com virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; } 27812854Sgabeblack@google.com virtual void 27912854Sgabeblack@google.com dump(std::ostream &os=std::cout) const 28012854Sgabeblack@google.com { 28112854Sgabeblack@google.com os << " name = " << name() << ::std::endl; 28212854Sgabeblack@google.com os << " value = " << m_cur_val << ::std::endl; 28312854Sgabeblack@google.com os << "new value = " << m_new_val << ::std::endl; 28412854Sgabeblack@google.com } 28512854Sgabeblack@google.com virtual const char *kind() const { return "sc_signal"; } 28612854Sgabeblack@google.com 28712854Sgabeblack@google.com protected: 28812854Sgabeblack@google.com virtual void 28912854Sgabeblack@google.com update() 29012854Sgabeblack@google.com { 29112854Sgabeblack@google.com if (m_new_val == m_cur_val) 29212854Sgabeblack@google.com return; 29312854Sgabeblack@google.com 29412854Sgabeblack@google.com m_cur_val = m_new_val; 29512854Sgabeblack@google.com _valueChangedEvent.notify(SC_ZERO_TIME); 29612854Sgabeblack@google.com if (m_cur_val) 29712854Sgabeblack@google.com _posedgeEvent.notify(SC_ZERO_TIME); 29812854Sgabeblack@google.com else 29912854Sgabeblack@google.com _negedgeEvent.notify(SC_ZERO_TIME); 30012854Sgabeblack@google.com } 30112854Sgabeblack@google.com 30212854Sgabeblack@google.com bool m_cur_val; 30312854Sgabeblack@google.com bool m_new_val; 30412854Sgabeblack@google.com 30512854Sgabeblack@google.com private: 30612854Sgabeblack@google.com sc_event _valueChangedEvent; 30712854Sgabeblack@google.com sc_event _posedgeEvent; 30812854Sgabeblack@google.com sc_event _negedgeEvent; 30912854Sgabeblack@google.com 31012854Sgabeblack@google.com // Disabled 31112854Sgabeblack@google.com sc_signal(const sc_signal<bool, WRITER_POLICY> &) : 31212854Sgabeblack@google.com sc_signal_inout_if<bool>(), sc_prim_channel("") 31312854Sgabeblack@google.com {} 31412854Sgabeblack@google.com}; 31512854Sgabeblack@google.com 31612854Sgabeblack@google.comtemplate <sc_writer_policy WRITER_POLICY> 31712854Sgabeblack@google.comclass sc_signal<sc_dt::sc_logic, WRITER_POLICY> : 31812854Sgabeblack@google.com public sc_signal_inout_if<sc_dt::sc_logic>, public sc_prim_channel 31912854Sgabeblack@google.com{ 32012854Sgabeblack@google.com public: 32112854Sgabeblack@google.com sc_signal() : sc_signal_inout_if<sc_dt::sc_logic>(), 32212854Sgabeblack@google.com sc_prim_channel(sc_gen_unique_name("signal")), 32312854Sgabeblack@google.com m_cur_val(sc_dt::sc_logic()), m_new_val(sc_dt::sc_logic()) 32412854Sgabeblack@google.com {} 32512854Sgabeblack@google.com explicit sc_signal(const char *name) : 32612854Sgabeblack@google.com sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel(name), 32712854Sgabeblack@google.com m_cur_val(sc_dt::sc_logic()), m_new_val(sc_dt::sc_logic()) 32812854Sgabeblack@google.com {} 32912854Sgabeblack@google.com explicit sc_signal(const char *name, 33012854Sgabeblack@google.com const sc_dt::sc_logic &initial_value) : 33112854Sgabeblack@google.com sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel(name), 33212854Sgabeblack@google.com m_cur_val(initial_value), m_new_val(initial_value) 33312854Sgabeblack@google.com {} 33412854Sgabeblack@google.com virtual ~sc_signal() {} 33512854Sgabeblack@google.com 33612854Sgabeblack@google.com virtual void 33712854Sgabeblack@google.com register_port(sc_port_base &, const char *) 33812854Sgabeblack@google.com { 33912854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 34012854Sgabeblack@google.com } 34112854Sgabeblack@google.com 34212854Sgabeblack@google.com virtual const sc_dt::sc_logic &read() const { return m_cur_val; } 34312854Sgabeblack@google.com operator const sc_dt::sc_logic &() const { return read(); } 34412854Sgabeblack@google.com 34512854Sgabeblack@google.com virtual sc_writer_policy 34612854Sgabeblack@google.com get_writer_policy() const 34712854Sgabeblack@google.com { 34812854Sgabeblack@google.com return WRITER_POLICY; 34912854Sgabeblack@google.com } 35012854Sgabeblack@google.com virtual void 35112854Sgabeblack@google.com write(const sc_dt::sc_logic &l) 35212854Sgabeblack@google.com { 35312854Sgabeblack@google.com m_new_val = l; 35412854Sgabeblack@google.com bool changed = !(m_cur_val == m_new_val); 35512854Sgabeblack@google.com //TODO check whether this write follows the write policy. 35612854Sgabeblack@google.com if (changed) 35712854Sgabeblack@google.com request_update(); 35812854Sgabeblack@google.com } 35912854Sgabeblack@google.com sc_signal<sc_dt::sc_logic, WRITER_POLICY> & 36012854Sgabeblack@google.com operator = (const sc_dt::sc_logic &l) 36112854Sgabeblack@google.com { 36212854Sgabeblack@google.com write(l); 36312854Sgabeblack@google.com return *this; 36412854Sgabeblack@google.com } 36512854Sgabeblack@google.com sc_signal<sc_dt::sc_logic, WRITER_POLICY> & 36612854Sgabeblack@google.com operator = (const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &s) 36712854Sgabeblack@google.com { 36812854Sgabeblack@google.com write(s.read()); 36912854Sgabeblack@google.com return *this; 37012854Sgabeblack@google.com } 37112854Sgabeblack@google.com 37212854Sgabeblack@google.com virtual const sc_event & 37312854Sgabeblack@google.com default_event() const 37412854Sgabeblack@google.com { 37512854Sgabeblack@google.com return value_changed_event(); 37612854Sgabeblack@google.com } 37712854Sgabeblack@google.com 37812854Sgabeblack@google.com virtual const sc_event & 37912854Sgabeblack@google.com value_changed_event() const 38012854Sgabeblack@google.com { 38112854Sgabeblack@google.com return _valueChangedEvent; 38212854Sgabeblack@google.com } 38312854Sgabeblack@google.com virtual const sc_event & 38412854Sgabeblack@google.com posedge_event() const 38512854Sgabeblack@google.com { 38612854Sgabeblack@google.com return _posedgeEvent; 38712854Sgabeblack@google.com } 38812854Sgabeblack@google.com virtual const sc_event & 38912854Sgabeblack@google.com negedge_event() const 39012854Sgabeblack@google.com { 39112854Sgabeblack@google.com return _negedgeEvent; 39212854Sgabeblack@google.com } 39312854Sgabeblack@google.com 39412854Sgabeblack@google.com virtual bool 39512854Sgabeblack@google.com event() const 39612854Sgabeblack@google.com { 39712854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 39812854Sgabeblack@google.com return false; 39912854Sgabeblack@google.com } 40012854Sgabeblack@google.com virtual bool 40112854Sgabeblack@google.com posedge() const 40212854Sgabeblack@google.com { 40312854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 40412854Sgabeblack@google.com return false; 40512854Sgabeblack@google.com } 40612854Sgabeblack@google.com virtual bool 40712854Sgabeblack@google.com negedge() const 40812854Sgabeblack@google.com { 40912854Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 41012854Sgabeblack@google.com return false; 41112854Sgabeblack@google.com } 41212854Sgabeblack@google.com 41312854Sgabeblack@google.com virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; } 41412854Sgabeblack@google.com virtual void 41512854Sgabeblack@google.com dump(std::ostream &os=std::cout) const 41612854Sgabeblack@google.com { 41712854Sgabeblack@google.com os << " name = " << name() << ::std::endl; 41812854Sgabeblack@google.com os << " value = " << m_cur_val << ::std::endl; 41912854Sgabeblack@google.com os << "new value = " << m_new_val << ::std::endl; 42012854Sgabeblack@google.com } 42112854Sgabeblack@google.com virtual const char *kind() const { return "sc_signal"; } 42212854Sgabeblack@google.com 42312854Sgabeblack@google.com protected: 42412854Sgabeblack@google.com virtual void 42512854Sgabeblack@google.com update() 42612854Sgabeblack@google.com { 42712854Sgabeblack@google.com if (m_new_val == m_cur_val) 42812854Sgabeblack@google.com return; 42912854Sgabeblack@google.com 43012854Sgabeblack@google.com m_cur_val = m_new_val; 43112854Sgabeblack@google.com _valueChangedEvent.notify(SC_ZERO_TIME); 43212854Sgabeblack@google.com if (m_cur_val == sc_dt::SC_LOGIC_1) 43312854Sgabeblack@google.com _posedgeEvent.notify(SC_ZERO_TIME); 43412854Sgabeblack@google.com else if (m_cur_val == sc_dt::SC_LOGIC_0) 43512854Sgabeblack@google.com _negedgeEvent.notify(SC_ZERO_TIME); 43612854Sgabeblack@google.com } 43712854Sgabeblack@google.com 43812854Sgabeblack@google.com sc_dt::sc_logic m_cur_val; 43912854Sgabeblack@google.com sc_dt::sc_logic m_new_val; 44012854Sgabeblack@google.com 44112854Sgabeblack@google.com private: 44212854Sgabeblack@google.com sc_event _valueChangedEvent; 44312854Sgabeblack@google.com sc_event _posedgeEvent; 44412854Sgabeblack@google.com sc_event _negedgeEvent; 44512854Sgabeblack@google.com 44612854Sgabeblack@google.com // Disabled 44712854Sgabeblack@google.com sc_signal(const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &) : 44812854Sgabeblack@google.com sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel("") 44912854Sgabeblack@google.com {} 45012854Sgabeblack@google.com}; 45112854Sgabeblack@google.com 45212854Sgabeblack@google.com} // namespace sc_core 45312854Sgabeblack@google.com 45412854Sgabeblack@google.com#endif //__SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 45512854Sgabeblack@google.com