sensitivity.cc (13262:ef4b783f84f7) sensitivity.cc (13288:f1c04129f709)
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include "systemc/core/sensitivity.hh"
31
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include "systemc/core/sensitivity.hh"
31
32#include "base/logging.hh"
32#include "systemc/core/event.hh"
33#include "systemc/core/port.hh"
34#include "systemc/core/process.hh"
35#include "systemc/core/scheduler.hh"
36#include "systemc/ext/channel/sc_in.hh"
37#include "systemc/ext/channel/sc_inout.hh"
38#include "systemc/ext/channel/sc_out.hh"
39#include "systemc/ext/core/sc_export.hh"

--- 52 unchanged lines hidden (view full) ---

92}
93
94void
95StaticSensitivity::delFromEvent(const ::sc_core::sc_event *e)
96{
97 Event::getFromScEvent(e)->delSensitivity(this);
98}
99
33#include "systemc/core/event.hh"
34#include "systemc/core/port.hh"
35#include "systemc/core/process.hh"
36#include "systemc/core/scheduler.hh"
37#include "systemc/ext/channel/sc_in.hh"
38#include "systemc/ext/channel/sc_inout.hh"
39#include "systemc/ext/channel/sc_out.hh"
40#include "systemc/ext/core/sc_export.hh"

--- 52 unchanged lines hidden (view full) ---

93}
94
95void
96StaticSensitivity::delFromEvent(const ::sc_core::sc_event *e)
97{
98 Event::getFromScEvent(e)->delSensitivity(this);
99}
100
100void
101ResetSensitivity::addToEvent(const ::sc_core::sc_event *e)
102{
103 Event::getFromScEvent(e)->addSensitivity(this);
104}
105
101
106void
107ResetSensitivity::delFromEvent(const ::sc_core::sc_event *e)
108{
109 Event::getFromScEvent(e)->delSensitivity(this);
110}
111
112
113/*
114 * Static sensitivities.
115 */
116
117void
118newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
119{
120 auto s = new StaticSensitivityEvent(p, e);

--- 124 unchanged lines hidden (view full) ---

245
246 // This sensitivity is satisfied if all events have triggered.
247 if (events.empty())
248 satisfy();
249
250 return true;
251}
252
102/*
103 * Static sensitivities.
104 */
105
106void
107newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
108{
109 auto s = new StaticSensitivityEvent(p, e);

--- 124 unchanged lines hidden (view full) ---

234
235 // This sensitivity is satisfied if all events have triggered.
236 if (events.empty())
237 satisfy();
238
239 return true;
240}
241
253/*
254 * Reset sensitivities.
255 */
256
257void
258newResetSensitivitySignal(
259 Process *p, const sc_core::sc_signal_in_if<bool> *signal,
260 bool val, bool sync)
261{
262 auto s = new ResetSensitivitySignal(p, signal, val, sync);
263 s->addToEvent(s->event);
264 p->addReset(s);
265}
266
267void
268newResetSensitivityPort(Process *p, const sc_core::sc_in<bool> *port,
269 bool val, bool sync)
270{
271 auto s = new ResetSensitivityPort(p, port, val, sync);
272 Port::fromPort(port)->sensitive(s);
273 p->addReset(s);
274}
275void
276newResetSensitivityPort(Process *p, const sc_core::sc_inout<bool> *port,
277 bool val, bool sync)
278{
279 auto s = new ResetSensitivityPort(p, port, val, sync);
280 Port::fromPort(port)->sensitive(s);
281 p->addReset(s);
282}
283void
284newResetSensitivityPort(Process *p, const sc_core::sc_out<bool> *port,
285 bool val, bool sync)
286{
287 auto s = new ResetSensitivityPort(p, port, val, sync);
288 Port::fromPort(port)->sensitive(s);
289 p->addReset(s);
290}
291
292ResetSensitivitySignal::ResetSensitivitySignal(
293 Process *p, const sc_core::sc_signal_in_if<bool> *signal,
294 bool _val, bool _sync) :
295 Sensitivity(p), ResetSensitivity(p, _val, _sync),
296 SensitivityEvent(p, signal ? &signal->value_changed_event() : nullptr),
297 _signal(signal)
298{
299 if (signal && signal->read() == val())
300 process->signalReset(true, sync());
301}
302
303bool
304ResetSensitivitySignal::notify(Event *e)
305{
306 process->signalReset(_signal->read() == val(), sync());
307 return true;
308}
309
310void
311ResetSensitivityPort::setSignal(const ::sc_core::sc_signal_in_if<bool> *signal)
312{
313 _signal = signal;
314 event = &_signal->value_changed_event();
315 addToEvent(event);
316 if (signal->read() == val())
317 process->signalReset(true, sync());
318}
319
320} // namespace sc_gem5
242} // namespace sc_gem5