sc_signal.hh revision 13142
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#include "warn_unimpl.hh" // for warn_unimpl 4312841Sgabeblack@google.com 4412841Sgabeblack@google.comnamespace sc_core 4512841Sgabeblack@google.com{ 4612841Sgabeblack@google.com 4712841Sgabeblack@google.comclass sc_port_base; 4812933Sgabeblack@google.comclass sc_trace_file; 4912933Sgabeblack@google.com 5012933Sgabeblack@google.com// Nonstandard 5112933Sgabeblack@google.com// Despite having a warning "FOR INTERNAL USE ONLY!" in all caps above this 5212933Sgabeblack@google.com// class definition in the Accellera implementation, it appears in their 5312933Sgabeblack@google.com// examples and test programs, and so we need to have it here as well. 5412933Sgabeblack@google.comstruct sc_trace_params 5512933Sgabeblack@google.com{ 5612933Sgabeblack@google.com sc_trace_file *tf; 5712933Sgabeblack@google.com std::string name; 5812933Sgabeblack@google.com 5912933Sgabeblack@google.com sc_trace_params(sc_trace_file *tf, const std::string &name) : 6012933Sgabeblack@google.com tf(tf), name(name) 6112933Sgabeblack@google.com {} 6212933Sgabeblack@google.com}; 6312933Sgabeblack@google.comtypedef std::vector<sc_trace_params *> sc_trace_params_vec; 6412841Sgabeblack@google.com 6512841Sgabeblack@google.comtemplate <class T, sc_writer_policy WRITER_POLICY=SC_ONE_WRITER> 6612841Sgabeblack@google.comclass sc_signal : public sc_signal_inout_if<T>, 6712841Sgabeblack@google.com public sc_prim_channel 6812841Sgabeblack@google.com{ 6912841Sgabeblack@google.com public: 7012841Sgabeblack@google.com sc_signal() : sc_signal_inout_if<T>(), 7113044Sgabeblack@google.com sc_prim_channel(sc_gen_unique_name("signal")), 7213141Sgabeblack@google.com m_cur_val(T()), m_new_val(T()), _changeStamp(~0ULL) 7312841Sgabeblack@google.com {} 7413044Sgabeblack@google.com explicit sc_signal(const char *name) : 7513044Sgabeblack@google.com sc_signal_inout_if<T>(), sc_prim_channel(name), 7613141Sgabeblack@google.com m_cur_val(T()), m_new_val(T()), _changeStamp(~0ULL) 7712841Sgabeblack@google.com {} 7812912Sgabeblack@google.com explicit sc_signal(const char *name, const T &initial_value) : 7913044Sgabeblack@google.com sc_signal_inout_if<T>(), sc_prim_channel(name), 8013141Sgabeblack@google.com m_cur_val(initial_value), m_new_val(initial_value), _changeStamp(~0ULL) 8113044Sgabeblack@google.com {} 8212841Sgabeblack@google.com virtual ~sc_signal() {} 8312841Sgabeblack@google.com 8412841Sgabeblack@google.com virtual void 8512841Sgabeblack@google.com register_port(sc_port_base &, const char *) 8612841Sgabeblack@google.com { 8712841Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 8812841Sgabeblack@google.com } 8912841Sgabeblack@google.com 9013044Sgabeblack@google.com virtual const T &read() const { return m_cur_val; } 9113044Sgabeblack@google.com operator const T&() const { return read(); } 9212841Sgabeblack@google.com 9312841Sgabeblack@google.com virtual sc_writer_policy 9412841Sgabeblack@google.com get_writer_policy() const 9512841Sgabeblack@google.com { 9612841Sgabeblack@google.com return WRITER_POLICY; 9712841Sgabeblack@google.com } 9812841Sgabeblack@google.com virtual void 9913044Sgabeblack@google.com write(const T &t) 10012841Sgabeblack@google.com { 10113044Sgabeblack@google.com m_new_val = t; 10213044Sgabeblack@google.com bool changed = !(m_cur_val == m_new_val); 10313044Sgabeblack@google.com //TODO check whether this write follows the write policy. 10413044Sgabeblack@google.com if (changed) 10513044Sgabeblack@google.com request_update(); 10612841Sgabeblack@google.com } 10712841Sgabeblack@google.com sc_signal<T, WRITER_POLICY> & 10813044Sgabeblack@google.com operator = (const T &t) 10912841Sgabeblack@google.com { 11013044Sgabeblack@google.com write(t); 11112841Sgabeblack@google.com return *this; 11212841Sgabeblack@google.com } 11312841Sgabeblack@google.com sc_signal<T, WRITER_POLICY> & 11413044Sgabeblack@google.com operator = (const sc_signal<T, WRITER_POLICY> &s) 11512841Sgabeblack@google.com { 11613044Sgabeblack@google.com write(s.read()); 11712841Sgabeblack@google.com return *this; 11812841Sgabeblack@google.com } 11912841Sgabeblack@google.com 12012841Sgabeblack@google.com virtual const sc_event & 12112841Sgabeblack@google.com default_event() const 12212841Sgabeblack@google.com { 12313044Sgabeblack@google.com return value_changed_event(); 12412841Sgabeblack@google.com } 12512841Sgabeblack@google.com virtual const sc_event & 12612841Sgabeblack@google.com value_changed_event() const 12712841Sgabeblack@google.com { 12813044Sgabeblack@google.com return _valueChangedEvent; 12912841Sgabeblack@google.com } 13012841Sgabeblack@google.com virtual bool 13112841Sgabeblack@google.com event() const 13212841Sgabeblack@google.com { 13313141Sgabeblack@google.com return _changeStamp == ::sc_gem5::getChangeStamp(); 13412841Sgabeblack@google.com } 13512841Sgabeblack@google.com 13613044Sgabeblack@google.com virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; } 13712841Sgabeblack@google.com virtual void 13813044Sgabeblack@google.com dump(std::ostream &os=std::cout) const 13912841Sgabeblack@google.com { 14013044Sgabeblack@google.com os << " name = " << name() << ::std::endl; 14113044Sgabeblack@google.com os << " value = " << m_cur_val << ::std::endl; 14213044Sgabeblack@google.com os << "new value = " << m_new_val << ::std::endl; 14312841Sgabeblack@google.com } 14412841Sgabeblack@google.com virtual const char *kind() const { return "sc_signal"; } 14512841Sgabeblack@google.com 14612841Sgabeblack@google.com protected: 14712841Sgabeblack@google.com virtual void 14812841Sgabeblack@google.com update() 14912841Sgabeblack@google.com { 15013044Sgabeblack@google.com if (m_new_val == m_cur_val) 15113044Sgabeblack@google.com return; 15213044Sgabeblack@google.com 15313044Sgabeblack@google.com m_cur_val = m_new_val; 15413141Sgabeblack@google.com _changeStamp = ::sc_gem5::getChangeStamp(); 15513044Sgabeblack@google.com _valueChangedEvent.notify(SC_ZERO_TIME); 15612841Sgabeblack@google.com } 15712841Sgabeblack@google.com 15812945Sgabeblack@google.com // These members which store the current and future value of the signal 15912945Sgabeblack@google.com // are not specified in the standard but are referred to directly by one 16012945Sgabeblack@google.com // of the tests. 16112945Sgabeblack@google.com T m_cur_val; 16212945Sgabeblack@google.com T m_new_val; 16312945Sgabeblack@google.com 16412841Sgabeblack@google.com private: 16513044Sgabeblack@google.com sc_event _valueChangedEvent; 16613141Sgabeblack@google.com uint64_t _changeStamp; 16713044Sgabeblack@google.com 16812841Sgabeblack@google.com // Disabled 16912841Sgabeblack@google.com sc_signal(const sc_signal<T, WRITER_POLICY> &) : 17012841Sgabeblack@google.com sc_signal_inout_if<T>(), sc_prim_channel("") 17112841Sgabeblack@google.com {} 17212841Sgabeblack@google.com}; 17312841Sgabeblack@google.com 17412841Sgabeblack@google.comtemplate <class T, sc_writer_policy WRITER_POLICY> 17512841Sgabeblack@google.cominline std::ostream & 17613142Sgabeblack@google.comoperator << (std::ostream &os, const sc_signal<T, WRITER_POLICY> &s) 17712841Sgabeblack@google.com{ 17813142Sgabeblack@google.com os << s.read(); 17912841Sgabeblack@google.com return os; 18012841Sgabeblack@google.com} 18112841Sgabeblack@google.com 18212841Sgabeblack@google.comtemplate <sc_writer_policy WRITER_POLICY> 18312841Sgabeblack@google.comclass sc_signal<bool, WRITER_POLICY> : 18412841Sgabeblack@google.com public sc_signal_inout_if<bool>, public sc_prim_channel 18512841Sgabeblack@google.com{ 18612841Sgabeblack@google.com public: 18713044Sgabeblack@google.com sc_signal() : sc_signal_inout_if<bool>(), 18813044Sgabeblack@google.com sc_prim_channel(sc_gen_unique_name("signal")), 18913141Sgabeblack@google.com m_cur_val(bool()), m_new_val(bool()), 19013141Sgabeblack@google.com _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL) 19113044Sgabeblack@google.com {} 19213044Sgabeblack@google.com explicit sc_signal(const char *name) : 19313044Sgabeblack@google.com sc_signal_inout_if<bool>(), sc_prim_channel(name), 19413141Sgabeblack@google.com m_cur_val(bool()), m_new_val(bool()), 19513141Sgabeblack@google.com _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL) 19613044Sgabeblack@google.com {} 19712912Sgabeblack@google.com explicit sc_signal(const char *name, const bool &initial_value) : 19813044Sgabeblack@google.com sc_signal_inout_if<bool>(), sc_prim_channel(name), 19913141Sgabeblack@google.com m_cur_val(initial_value), m_new_val(initial_value), 20013141Sgabeblack@google.com _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL) 20113044Sgabeblack@google.com {} 20213044Sgabeblack@google.com virtual ~sc_signal() {} 20312841Sgabeblack@google.com 20412841Sgabeblack@google.com virtual void 20512841Sgabeblack@google.com register_port(sc_port_base &, const char *) 20612841Sgabeblack@google.com { 20712841Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 20812841Sgabeblack@google.com } 20912841Sgabeblack@google.com 21013044Sgabeblack@google.com virtual const bool &read() const { return m_cur_val; } 21113044Sgabeblack@google.com operator const bool &() const { return read(); } 21212841Sgabeblack@google.com 21312841Sgabeblack@google.com virtual sc_writer_policy 21412841Sgabeblack@google.com get_writer_policy() const 21512841Sgabeblack@google.com { 21612841Sgabeblack@google.com return WRITER_POLICY; 21712841Sgabeblack@google.com } 21812841Sgabeblack@google.com virtual void 21913044Sgabeblack@google.com write(const bool &b) 22012841Sgabeblack@google.com { 22113044Sgabeblack@google.com m_new_val = b; 22213044Sgabeblack@google.com bool changed = !(m_cur_val == m_new_val); 22313044Sgabeblack@google.com //TODO check whether this write follows the write policy. 22413044Sgabeblack@google.com if (changed) 22513044Sgabeblack@google.com request_update(); 22612841Sgabeblack@google.com } 22712841Sgabeblack@google.com sc_signal<bool, WRITER_POLICY> & 22813044Sgabeblack@google.com operator = (const bool &b) 22912841Sgabeblack@google.com { 23013044Sgabeblack@google.com write(b); 23112841Sgabeblack@google.com return *this; 23212841Sgabeblack@google.com } 23312841Sgabeblack@google.com sc_signal<bool, WRITER_POLICY> & 23413044Sgabeblack@google.com operator = (const sc_signal<bool, WRITER_POLICY> &s) 23512841Sgabeblack@google.com { 23613044Sgabeblack@google.com write(s.read()); 23712841Sgabeblack@google.com return *this; 23812841Sgabeblack@google.com } 23912841Sgabeblack@google.com 24012841Sgabeblack@google.com virtual const sc_event & 24112841Sgabeblack@google.com default_event() const 24212841Sgabeblack@google.com { 24313044Sgabeblack@google.com return value_changed_event(); 24412841Sgabeblack@google.com } 24512841Sgabeblack@google.com 24612841Sgabeblack@google.com virtual const sc_event & 24712841Sgabeblack@google.com value_changed_event() const 24812841Sgabeblack@google.com { 24913044Sgabeblack@google.com return _valueChangedEvent; 25012841Sgabeblack@google.com } 25112841Sgabeblack@google.com virtual const sc_event & 25212841Sgabeblack@google.com posedge_event() const 25312841Sgabeblack@google.com { 25413044Sgabeblack@google.com return _posedgeEvent; 25512841Sgabeblack@google.com } 25612841Sgabeblack@google.com virtual const sc_event & 25712841Sgabeblack@google.com negedge_event() const 25812841Sgabeblack@google.com { 25913044Sgabeblack@google.com return _negedgeEvent; 26012841Sgabeblack@google.com } 26112841Sgabeblack@google.com 26212841Sgabeblack@google.com virtual bool 26312841Sgabeblack@google.com event() const 26412841Sgabeblack@google.com { 26513141Sgabeblack@google.com return _changeStamp == ::sc_gem5::getChangeStamp(); 26612841Sgabeblack@google.com } 26712841Sgabeblack@google.com virtual bool 26812841Sgabeblack@google.com posedge() const 26912841Sgabeblack@google.com { 27013141Sgabeblack@google.com return _posStamp == ::sc_gem5::getChangeStamp(); 27112841Sgabeblack@google.com } 27212841Sgabeblack@google.com virtual bool 27312841Sgabeblack@google.com negedge() const 27412841Sgabeblack@google.com { 27513141Sgabeblack@google.com return _negStamp == ::sc_gem5::getChangeStamp(); 27612841Sgabeblack@google.com } 27712841Sgabeblack@google.com 27813044Sgabeblack@google.com virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; } 27912841Sgabeblack@google.com virtual void 28013044Sgabeblack@google.com dump(std::ostream &os=std::cout) const 28112841Sgabeblack@google.com { 28213044Sgabeblack@google.com os << " name = " << name() << ::std::endl; 28313044Sgabeblack@google.com os << " value = " << m_cur_val << ::std::endl; 28413044Sgabeblack@google.com os << "new value = " << m_new_val << ::std::endl; 28512841Sgabeblack@google.com } 28612841Sgabeblack@google.com virtual const char *kind() const { return "sc_signal"; } 28712841Sgabeblack@google.com 28812841Sgabeblack@google.com protected: 28912841Sgabeblack@google.com virtual void 29012841Sgabeblack@google.com update() 29112841Sgabeblack@google.com { 29213044Sgabeblack@google.com if (m_new_val == m_cur_val) 29313044Sgabeblack@google.com return; 29413044Sgabeblack@google.com 29513044Sgabeblack@google.com m_cur_val = m_new_val; 29613141Sgabeblack@google.com uint64_t change_stamp = ::sc_gem5::getChangeStamp(); 29713141Sgabeblack@google.com _changeStamp = change_stamp; 29813044Sgabeblack@google.com _valueChangedEvent.notify(SC_ZERO_TIME); 29913141Sgabeblack@google.com if (m_cur_val) { 30013141Sgabeblack@google.com _posStamp = change_stamp; 30113044Sgabeblack@google.com _posedgeEvent.notify(SC_ZERO_TIME); 30213141Sgabeblack@google.com } else { 30313141Sgabeblack@google.com _negStamp = change_stamp; 30413044Sgabeblack@google.com _negedgeEvent.notify(SC_ZERO_TIME); 30513141Sgabeblack@google.com } 30612841Sgabeblack@google.com } 30712841Sgabeblack@google.com 30813044Sgabeblack@google.com bool m_cur_val; 30913044Sgabeblack@google.com bool m_new_val; 31013044Sgabeblack@google.com 31112841Sgabeblack@google.com private: 31213044Sgabeblack@google.com sc_event _valueChangedEvent; 31313044Sgabeblack@google.com sc_event _posedgeEvent; 31413044Sgabeblack@google.com sc_event _negedgeEvent; 31513044Sgabeblack@google.com 31613141Sgabeblack@google.com uint64_t _changeStamp; 31713141Sgabeblack@google.com uint64_t _posStamp; 31813141Sgabeblack@google.com uint64_t _negStamp; 31913141Sgabeblack@google.com 32012841Sgabeblack@google.com // Disabled 32112841Sgabeblack@google.com sc_signal(const sc_signal<bool, WRITER_POLICY> &) : 32212841Sgabeblack@google.com sc_signal_inout_if<bool>(), sc_prim_channel("") 32312841Sgabeblack@google.com {} 32412841Sgabeblack@google.com}; 32512841Sgabeblack@google.com 32612841Sgabeblack@google.comtemplate <sc_writer_policy WRITER_POLICY> 32712841Sgabeblack@google.comclass sc_signal<sc_dt::sc_logic, WRITER_POLICY> : 32812841Sgabeblack@google.com public sc_signal_inout_if<sc_dt::sc_logic>, public sc_prim_channel 32912841Sgabeblack@google.com{ 33012841Sgabeblack@google.com public: 33113044Sgabeblack@google.com sc_signal() : sc_signal_inout_if<sc_dt::sc_logic>(), 33213044Sgabeblack@google.com sc_prim_channel(sc_gen_unique_name("signal")), 33313141Sgabeblack@google.com m_cur_val(sc_dt::sc_logic()), m_new_val(sc_dt::sc_logic()), 33413141Sgabeblack@google.com _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL) 33513044Sgabeblack@google.com {} 33613044Sgabeblack@google.com explicit sc_signal(const char *name) : 33713044Sgabeblack@google.com sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel(name), 33813141Sgabeblack@google.com m_cur_val(sc_dt::sc_logic()), m_new_val(sc_dt::sc_logic()), 33913141Sgabeblack@google.com _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL) 34013044Sgabeblack@google.com {} 34112912Sgabeblack@google.com explicit sc_signal(const char *name, 34212912Sgabeblack@google.com const sc_dt::sc_logic &initial_value) : 34313044Sgabeblack@google.com sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel(name), 34413141Sgabeblack@google.com m_cur_val(initial_value), m_new_val(initial_value), 34513141Sgabeblack@google.com _changeStamp(~0ULL), _posStamp(~0ULL), _negStamp(~0ULL) 34613044Sgabeblack@google.com {} 34713044Sgabeblack@google.com virtual ~sc_signal() {} 34812841Sgabeblack@google.com 34912841Sgabeblack@google.com virtual void 35012841Sgabeblack@google.com register_port(sc_port_base &, const char *) 35112841Sgabeblack@google.com { 35212841Sgabeblack@google.com sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 35312841Sgabeblack@google.com } 35412841Sgabeblack@google.com 35513044Sgabeblack@google.com virtual const sc_dt::sc_logic &read() const { return m_cur_val; } 35613044Sgabeblack@google.com operator const sc_dt::sc_logic &() const { return read(); } 35712841Sgabeblack@google.com 35812841Sgabeblack@google.com virtual sc_writer_policy 35912841Sgabeblack@google.com get_writer_policy() const 36012841Sgabeblack@google.com { 36112841Sgabeblack@google.com return WRITER_POLICY; 36212841Sgabeblack@google.com } 36312841Sgabeblack@google.com virtual void 36413044Sgabeblack@google.com write(const sc_dt::sc_logic &l) 36512841Sgabeblack@google.com { 36613044Sgabeblack@google.com m_new_val = l; 36713044Sgabeblack@google.com bool changed = !(m_cur_val == m_new_val); 36813044Sgabeblack@google.com //TODO check whether this write follows the write policy. 36913044Sgabeblack@google.com if (changed) 37013044Sgabeblack@google.com request_update(); 37112841Sgabeblack@google.com } 37212841Sgabeblack@google.com sc_signal<sc_dt::sc_logic, WRITER_POLICY> & 37313044Sgabeblack@google.com operator = (const sc_dt::sc_logic &l) 37412841Sgabeblack@google.com { 37513044Sgabeblack@google.com write(l); 37612841Sgabeblack@google.com return *this; 37712841Sgabeblack@google.com } 37812841Sgabeblack@google.com sc_signal<sc_dt::sc_logic, WRITER_POLICY> & 37913044Sgabeblack@google.com operator = (const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &s) 38012841Sgabeblack@google.com { 38113044Sgabeblack@google.com write(s.read()); 38212841Sgabeblack@google.com return *this; 38312841Sgabeblack@google.com } 38412841Sgabeblack@google.com 38512841Sgabeblack@google.com virtual const sc_event & 38612841Sgabeblack@google.com default_event() const 38712841Sgabeblack@google.com { 38813044Sgabeblack@google.com return value_changed_event(); 38912841Sgabeblack@google.com } 39012841Sgabeblack@google.com 39112841Sgabeblack@google.com virtual const sc_event & 39212841Sgabeblack@google.com value_changed_event() const 39312841Sgabeblack@google.com { 39413044Sgabeblack@google.com return _valueChangedEvent; 39512841Sgabeblack@google.com } 39612841Sgabeblack@google.com virtual const sc_event & 39712841Sgabeblack@google.com posedge_event() const 39812841Sgabeblack@google.com { 39913044Sgabeblack@google.com return _posedgeEvent; 40012841Sgabeblack@google.com } 40112841Sgabeblack@google.com virtual const sc_event & 40212841Sgabeblack@google.com negedge_event() const 40312841Sgabeblack@google.com { 40413044Sgabeblack@google.com return _negedgeEvent; 40512841Sgabeblack@google.com } 40612841Sgabeblack@google.com 40712841Sgabeblack@google.com virtual bool 40812841Sgabeblack@google.com event() const 40912841Sgabeblack@google.com { 41013141Sgabeblack@google.com return _changeStamp == ::sc_gem5::getChangeStamp(); 41112841Sgabeblack@google.com } 41212841Sgabeblack@google.com virtual bool 41312841Sgabeblack@google.com posedge() const 41412841Sgabeblack@google.com { 41513141Sgabeblack@google.com return _posStamp == ::sc_gem5::getChangeStamp(); 41612841Sgabeblack@google.com } 41712841Sgabeblack@google.com virtual bool 41812841Sgabeblack@google.com negedge() const 41912841Sgabeblack@google.com { 42013141Sgabeblack@google.com return _negStamp == ::sc_gem5::getChangeStamp(); 42112841Sgabeblack@google.com } 42212841Sgabeblack@google.com 42313044Sgabeblack@google.com virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; } 42412841Sgabeblack@google.com virtual void 42513044Sgabeblack@google.com dump(std::ostream &os=std::cout) const 42612841Sgabeblack@google.com { 42713044Sgabeblack@google.com os << " name = " << name() << ::std::endl; 42813044Sgabeblack@google.com os << " value = " << m_cur_val << ::std::endl; 42913044Sgabeblack@google.com os << "new value = " << m_new_val << ::std::endl; 43012841Sgabeblack@google.com } 43112841Sgabeblack@google.com virtual const char *kind() const { return "sc_signal"; } 43212841Sgabeblack@google.com 43312841Sgabeblack@google.com protected: 43412841Sgabeblack@google.com virtual void 43512841Sgabeblack@google.com update() 43612841Sgabeblack@google.com { 43713044Sgabeblack@google.com if (m_new_val == m_cur_val) 43813044Sgabeblack@google.com return; 43913044Sgabeblack@google.com 44013044Sgabeblack@google.com m_cur_val = m_new_val; 44113044Sgabeblack@google.com _valueChangedEvent.notify(SC_ZERO_TIME); 44213044Sgabeblack@google.com if (m_cur_val == sc_dt::SC_LOGIC_1) 44313044Sgabeblack@google.com _posedgeEvent.notify(SC_ZERO_TIME); 44413044Sgabeblack@google.com else if (m_cur_val == sc_dt::SC_LOGIC_0) 44513044Sgabeblack@google.com _negedgeEvent.notify(SC_ZERO_TIME); 44612841Sgabeblack@google.com } 44712841Sgabeblack@google.com 44813044Sgabeblack@google.com sc_dt::sc_logic m_cur_val; 44913044Sgabeblack@google.com sc_dt::sc_logic m_new_val; 45013044Sgabeblack@google.com 45112841Sgabeblack@google.com private: 45213044Sgabeblack@google.com sc_event _valueChangedEvent; 45313044Sgabeblack@google.com sc_event _posedgeEvent; 45413044Sgabeblack@google.com sc_event _negedgeEvent; 45513044Sgabeblack@google.com 45613141Sgabeblack@google.com uint64_t _changeStamp; 45713141Sgabeblack@google.com uint64_t _posStamp; 45813141Sgabeblack@google.com uint64_t _negStamp; 45913141Sgabeblack@google.com 46012841Sgabeblack@google.com // Disabled 46112841Sgabeblack@google.com sc_signal(const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &) : 46212841Sgabeblack@google.com sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel("") 46312841Sgabeblack@google.com {} 46412841Sgabeblack@google.com}; 46512841Sgabeblack@google.com 46612841Sgabeblack@google.com} // namespace sc_core 46712841Sgabeblack@google.com 46812841Sgabeblack@google.com#endif //__SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 469