sensitivity.cc (13208:6703cb024823) sensitivity.cc (13260:4d18f1d20093)
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

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

28 */
29
30#include "systemc/core/sensitivity.hh"
31
32#include "systemc/core/event.hh"
33#include "systemc/core/port.hh"
34#include "systemc/core/process.hh"
35#include "systemc/core/scheduler.hh"
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

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

28 */
29
30#include "systemc/core/sensitivity.hh"
31
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"
36#include "systemc/ext/core/sc_export.hh"
37#include "systemc/ext/core/sc_interface.hh"
38#include "systemc/ext/core/sc_port.hh"
39
40namespace sc_gem5
41{
42
43/*

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

88}
89
90void
91StaticSensitivity::delFromEvent(const ::sc_core::sc_event *e)
92{
93 Event::getFromScEvent(e)->delSensitivity(this);
94}
95
39#include "systemc/ext/core/sc_export.hh"
40#include "systemc/ext/core/sc_interface.hh"
41#include "systemc/ext/core/sc_port.hh"
42
43namespace sc_gem5
44{
45
46/*

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

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

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

223
224 // This sensitivity is satisfied if all events have triggered.
225 if (events.empty())
226 satisfy();
227
228 return true;
229}
230
112/*
113 * Static sensitivities.
114 */
115
116void
117newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
118{
119 auto s = new StaticSensitivityEvent(p, e);

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

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