16class observer_event :
public sc_core::sc_module,
public sc_core::sc_event,
public sc_core::sc_stage_callback_if
21 sc_core::sc_event m_update;
22 sc_core::sc_time m_scheduled;
23 sc_core::sc_process_handle m_th;
27 auto now = sc_core::sc_time_stamp();
28 if (
now >= m_scheduled) {
29 sc_core::sc_event::notify();
32 if (sc_core::sc_pending_activity_at_future_time()) {
33 pending =
now + sc_core::sc_time_to_pending_activity();
35 SCP_TRACE(()) <<
"time of future pending activity: " <<
pending.to_seconds() <<
" sec";
37 sc_core::sc_event::notify(m_scheduled -
now);
42 sc_core::sc_register_stage_callback(*
this, sc_core::SC_POST_UPDATE);
48 void future_events_notify_th()
57 observer_event(
const sc_core::sc_module_name&
n = sc_core::sc_gen_unique_name(
"observer_event"))
59 , sc_core::sc_event((std::string(
n) +
"_notifier_event").
c_str())
60 , m_update((std::string(
n) +
"_update_event").
c_str())
61 , m_scheduled(sc_core::SC_ZERO_TIME)
67 m_th = sc_core::sc_get_current_process_handle();
71 m_scheduled = sc_core::sc_time_stamp();
72 m_update.notify(sc_core::SC_ZERO_TIME);
74 void notify(
double delay, sc_core::sc_time_unit
unit)
76 m_scheduled = sc_core::sc_time_stamp() + sc_core::sc_time(delay,
unit);
77 m_update.notify(sc_core::SC_ZERO_TIME);
79 void notify(sc_core::sc_time delay)
81 m_scheduled = sc_core::sc_time_stamp() + delay;
82 m_update.notify(sc_core::SC_ZERO_TIME);
85 void stage_callback(
const sc_core::sc_stage&
stage)
87 if (sc_core::sc_pending_activity_at_future_time()) {
89 sc_core::sc_unregister_stage_callback(*
this, sc_core::SC_POST_UPDATE);