28 #ifndef __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 29 #define __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 35 #include "../core/sc_event.hh" 36 #include "../core/sc_module.hh" 37 #include "../core/sc_prim.hh" 38 #include "../dt/bit/sc_logic.hh" 57 virtual const char *
kind()
const {
return "sc_signal"; }
98 void _signalPosedge();
99 void _signalNegedge();
123 template <sc_core::sc_writer_policy WRITER_POLICY>
133 std::string iface_type_name, std::string out_name);
150 std::string iface_type_name, std::string out_name);
159 template <
class T, sc_core::sc_writer_policy WRITER_POLICY>
170 m_new_val(initial_value), _checker(this)
177 # if !defined(SC_NO_WRITE_CHECK) 179 _checker.checkPort(port, iface_type_name,
185 virtual const T &
read()
const {
return m_cur_val; }
186 operator const T&()
const {
return read(); }
191 # if !defined(SC_NO_WRITE_CHECK) 193 _checker.checkWriter();
197 bool changed = !(m_cur_val == m_new_val);
199 this->request_update();
205 return ScSignalBase::defaultEvent();
211 return ScSignalBase::valueChangedEvent();
214 virtual void print(std::ostream &
os=std::cout)
const {
os << m_cur_val; }
218 os <<
" name = " << this->
name() << ::std::endl;
219 os <<
" value = " << m_cur_val << ::std::endl;
220 os <<
"new value = " << m_new_val << ::std::endl;
228 return WRITER_POLICY;
241 template <
typename T, sc_core::sc_writer_policy WRITER_POLICY>
254 return ScSignalBaseBinary::posedgeEvent();
259 return ScSignalBaseBinary::negedgeEvent();
262 bool posedge()
const {
return ScSignalBaseBinary::posedge(); }
263 bool negedge()
const {
return ScSignalBaseBinary::negedge(); }
271 template <
class T, sc_writer_policy WRITER_POLICY=SC_ONE_WRITER>
279 sc_gem5::ScSignalBaseT<T, WRITER_POLICY>(name)
282 sc_gem5::ScSignalBaseT<T, WRITER_POLICY>(name, initial_value)
287 operator = (
const T &
t)
295 this->write(s.
read());
303 if (this->m_new_val == this->m_cur_val)
306 this->m_cur_val = this->m_new_val;
307 this->_signalChange();
315 template <
class T, sc_writer_policy WRITER_POLICY>
316 inline std::ostream &
317 operator << (std::ostream &os, const sc_signal<T, WRITER_POLICY> &
s)
323 template <sc_writer_policy WRITER_POLICY>
329 sc_gem5::ScSignalBinary<bool, WRITER_POLICY>(
333 sc_gem5::ScSignalBinary<bool, WRITER_POLICY>(name)
336 sc_gem5::ScSignalBinary<bool, WRITER_POLICY>(name, initial_value)
341 operator = (
const bool &
b)
349 this->write(s.
read());
357 if (this->m_new_val == this->m_cur_val)
360 this->m_cur_val = this->m_new_val;
361 this->_signalChange();
368 this->_signalReset();
370 this->_signalPosedge();
372 this->_signalNegedge();
379 this->_resets.push_back(reset);
387 template <sc_writer_policy WRITER_POLICY>
393 sc_gem5::ScSignalBinary<
sc_dt::sc_logic, WRITER_POLICY>(
397 sc_gem5::ScSignalBinary<
sc_dt::sc_logic, WRITER_POLICY>(name)
401 sc_gem5::ScSignalBinary<
sc_dt::sc_logic, WRITER_POLICY>(
415 this->write(s.
read());
423 if (this->m_new_val == this->m_cur_val)
426 this->m_cur_val = this->m_new_val;
427 this->_signalChange();
436 this->_signalPosedge();
438 this->_signalNegedge();
448 #endif //__SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ sc_signal(const char *name, const T &initial_value)
sc_signal(const char *name, const bool &initial_value)
virtual sc_core::sc_writer_policy get_writer_policy() const
WriteChecker< WRITER_POLICY > _checker
const sc_core::sc_event & negedge_event() const
const std::string & name()
virtual void register_port(sc_core::sc_port_base &port, const char *iface_type_name)
const char * sc_gen_unique_name(const char *seed)
const sc_logic SC_LOGIC_1(Log_1)
const sc_logic SC_LOGIC_0(Log_0)
virtual void write(const T &t)
sc_signal(const char *name)
InternalScEvent _posedgeEvent
ScSignalBinary(const char *_name, const T &initial_value)
ScSignalBasePicker(const char *_name)
virtual const T & read() const
ScSignalBaseT(const char *_name)
sc_core::sc_port_base * _gem5WriterPort
bool _addReset(sc_gem5::Reset *reset) const
virtual bool event() const
InternalScEvent _valueChangedEvent
sc_signal(const char *name, const sc_dt::sc_logic &initial_value)
virtual const char * kind() const
ScSignalBasePicker(const char *_name)
sc_signal(const char *name)
virtual void print(std::ostream &os=std::cout) const
ScSignalBinary(const char *_name)
ScSignalBasePicker(const char *_name)
virtual const sc_core::sc_event & default_event() const
InternalScEvent _negedgeEvent
std::vector< sc_gem5::Reset * > _resets
const sc_core::sc_event & posedge_event() const
virtual void dump(std::ostream &os=std::cout) const
ScSignalBaseT(const char *_name, const T &initial_value)
virtual const sc_core::sc_event & value_changed_event() const
sc_core::sc_port_base * firstPort
sc_signal(const char *name)