@@ -79,14 +79,14 @@ class sc_sync_windowed : public sc_core::sc_module,
79
79
struct window {
80
80
sc_core::sc_time from;
81
81
sc_core::sc_time to;
82
- bool operator ==(window other) {
82
+ bool operator ==(const window & other) const {
83
83
return other.to == to && other.from == from;
84
84
}
85
85
};
86
86
87
- const struct window zero_window = {sc_core::SC_ZERO_TIME,
87
+ static inline const struct window zero_window = {sc_core::SC_ZERO_TIME,
88
88
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,
90
90
sc_core::sc_max_time ()};
91
91
92
92
private:
@@ -98,7 +98,6 @@ class sc_sync_windowed : public sc_core::sc_module,
98
98
99
99
void do_other_async_set_window_fn (window w) {
100
100
if (m_other_async_set_window_fn) {
101
- auto now = sc_core::sc_time_stamp ();
102
101
m_other_async_set_window_fn (w);
103
102
}
104
103
}
@@ -109,6 +108,8 @@ class sc_sync_windowed : public sc_core::sc_module,
109
108
auto now = sc_core::sc_time_stamp ();
110
109
auto to = m_window.to ;
111
110
111
+ /* The step helper has to handle both suspend and resume (because of
112
+ * SystemC) */
112
113
if (now >= to) {
113
114
sc_core::sc_unsuspend_all (); // such that pending activity is valid if
114
115
// it's needed below.
@@ -122,17 +123,12 @@ class sc_sync_windowed : public sc_core::sc_module,
122
123
sc_core::sc_suspend_all ();
123
124
124
125
} 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 */
125
128
sc_core::sc_unsuspend_all ();
126
129
if (!policy.keep_alive ())
127
130
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()});
136
132
137
133
/* Re-notify event - maybe presumably moved */
138
134
m_step_ev.notify (to - now);
@@ -162,6 +158,9 @@ class sc_sync_windowed : public sc_core::sc_module,
162
158
}
163
159
/* let stepper handle suspend/resume, must time notify */
164
160
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());
165
164
}
166
165
167
166
public:
@@ -171,7 +170,7 @@ class sc_sync_windowed : public sc_core::sc_module,
171
170
* Input: window - Window to set for sync. Sweep till the 'from' and step to
172
171
* the 'to'.
173
172
*/
174
- void async_set_window (window w) {
173
+ void async_set_window (const window & w) {
175
174
/* Only accept updated windows so we dont re-send redundant updates
176
175
* safe at this point to compair against m_window as we took the lock
177
176
*/
@@ -192,9 +191,7 @@ class sc_sync_windowed : public sc_core::sc_module,
192
191
" m_other_async_set_window_fn was already registered or other "
193
192
" sc_sync_windowed was already bound!" );
194
193
}
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);
198
195
}
199
196
void register_sync_cb (std::function<void (const window &)> fn) {
200
197
if (m_other_async_set_window_fn) {
@@ -216,7 +213,7 @@ class sc_sync_windowed : public sc_core::sc_module,
216
213
dont_initialize ();
217
214
sensitive << m_step_ev << m_update_ev;
218
215
219
- m_step_ev.notify (sc_core::SC_ZERO_TIME );
216
+ m_step_ev.notify (policy. quantum () );
220
217
221
218
this ->sc_core ::sc_prim_channel::async_attach_suspending ();
222
219
}
0 commit comments