@@ -79,14 +79,14 @@ class sc_sync_windowed : public sc_core::sc_module,
7979 struct window {
8080 sc_core::sc_time from;
8181 sc_core::sc_time to;
82- bool operator ==(window other) {
82+ bool operator ==(const window & other) const {
8383 return other.to == to && other.from == from;
8484 }
8585 };
8686
87- const struct window zero_window = {sc_core::SC_ZERO_TIME,
87+ static inline const struct window zero_window = {sc_core::SC_ZERO_TIME,
8888 sc_core::SC_ZERO_TIME};
89- const struct window open_window = {sc_core::SC_ZERO_TIME,
89+ static inline const struct window open_window = {sc_core::SC_ZERO_TIME,
9090 sc_core::sc_max_time ()};
9191
9292private:
@@ -98,7 +98,6 @@ class sc_sync_windowed : public sc_core::sc_module,
9898
9999 void do_other_async_set_window_fn (window w) {
100100 if (m_other_async_set_window_fn) {
101- auto now = sc_core::sc_time_stamp ();
102101 m_other_async_set_window_fn (w);
103102 }
104103 }
@@ -109,6 +108,8 @@ class sc_sync_windowed : public sc_core::sc_module,
109108 auto now = sc_core::sc_time_stamp ();
110109 auto to = m_window.to ;
111110
111+ /* The step helper has to handle both suspend and resume (because of
112+ * SystemC) */
112113 if (now >= to) {
113114 sc_core::sc_unsuspend_all (); // such that pending activity is valid if
114115 // it's needed below.
@@ -122,17 +123,12 @@ class sc_sync_windowed : public sc_core::sc_module,
122123 sc_core::sc_suspend_all ();
123124
124125 } else {
126+ /* the only way to get here is if we have a 'new' window from the other
127+ * side. we are here just to unsuspend */
125128 sc_core::sc_unsuspend_all ();
126129 if (!policy.keep_alive ())
127130 async_detach_suspending ();
128-
129- // We are about to advance to the next event, so may as well set that as
130- // the window now
131- do_other_async_set_window_fn (
132- {now + (sc_core::sc_pending_activity ()
133- ? sc_core::sc_time_to_pending_activity ()
134- : sc_core::SC_ZERO_TIME),
135- now + policy.quantum ()});
131+ // do_other_async_set_window_fn({now, now + policy.quantum()});
136132
137133 /* Re-notify event - maybe presumably moved */
138134 m_step_ev.notify (to - now);
@@ -162,6 +158,9 @@ class sc_sync_windowed : public sc_core::sc_module,
162158 }
163159 /* let stepper handle suspend/resume, must time notify */
164160 m_update_ev.notify (sc_core::SC_ZERO_TIME);
161+ // std::ostringstream s;
162+ // s << "Got Window: " << m_window.from << " - " << m_window.to;
163+ // SC_REPORT_INFO(sc_core::sc_module::name(), s.str().c_str());
165164 }
166165
167166public:
@@ -171,7 +170,7 @@ class sc_sync_windowed : public sc_core::sc_module,
171170 * Input: window - Window to set for sync. Sweep till the 'from' and step to
172171 * the 'to'.
173172 */
174- void async_set_window (window w) {
173+ void async_set_window (const window & w) {
175174 /* Only accept updated windows so we dont re-send redundant updates
176175 * safe at this point to compair against m_window as we took the lock
177176 */
@@ -192,9 +191,7 @@ class sc_sync_windowed : public sc_core::sc_module,
192191 " m_other_async_set_window_fn was already registered or other "
193192 " sc_sync_windowed was already bound!" );
194193 }
195- m_other_async_set_window_fn = [other](const window &w) {
196- other->async_set_window (w);
197- };
194+ m_other_async_set_window_fn = std::bind (&sc_sync_windowed::async_set_window, other, std::placeholders::_1);
198195 }
199196 void register_sync_cb (std::function<void (const window &)> fn) {
200197 if (m_other_async_set_window_fn) {
@@ -216,7 +213,7 @@ class sc_sync_windowed : public sc_core::sc_module,
216213 dont_initialize ();
217214 sensitive << m_step_ev << m_update_ev;
218215
219- m_step_ev.notify (sc_core::SC_ZERO_TIME );
216+ m_step_ev.notify (policy. quantum () );
220217
221218 this ->sc_core ::sc_prim_channel::async_attach_suspending ();
222219 }
0 commit comments