Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/12608
Change subject: systemc: Implement the deprecated "timed_out" function.
......................................................................
systemc: Implement the deprecated "timed_out" function.
This function requires some slightly annoying bookkeeping since it
doesn't just report whether the current process is running as a result
of a timeout, it reports whether it's running as a result of a timeout
*and* it could have been running from some other sensitivity instead.
Pure timeouts don't count as timeouts which makes it harder to handle
in a general way.
Change-Id: I533d97fe66d20d7b83aba80f2ef45a8944668070
---
M src/systemc/core/process.cc
M src/systemc/core/process.hh
M src/systemc/core/sc_module.cc
M src/systemc/core/sc_prim.cc
4 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/src/systemc/core/process.cc b/src/systemc/core/process.cc
index cc2eff5..e4d213b 100644
--- a/src/systemc/core/process.cc
+++ b/src/systemc/core/process.cc
@@ -88,7 +88,7 @@
e->delSensitivity(this);
count++;
if (count == list->events.size())
- process->satisfySensitivity(this);
+ satisfy();
}
SensitivityEventOrList::SensitivityEventOrList(
@@ -113,7 +113,7 @@
SensitivityEventAndList::notifyWork(e);
} else {
// There's no inciting event, so this must be a timeout.
- SensitivityTimeout::notifyWork(e);
+ satisfy(true);
}
}
@@ -400,10 +400,10 @@
Process::Process(const char *name, ProcessFuncWrapper *func, bool
internal) :
::sc_core::sc_process_b(name), excWrapper(nullptr), func(func),
- _internal(internal), _needsStart(true), _isUnwinding(false),
- _terminated(false), _suspended(false), _disabled(false),
_syncReset(false),
- refCount(0), stackSize(::Fiber::DefaultStackSize),
- dynamicSensitivity(nullptr)
+ _internal(internal), _timedOut(false), _needsStart(true),
+ _isUnwinding(false), _terminated(false), _suspended(false),
+ _disabled(false), _syncReset(false), refCount(0),
+ stackSize(::Fiber::DefaultStackSize), dynamicSensitivity(nullptr)
{
_dynamic =
(::sc_core::sc_get_status() >
diff --git a/src/systemc/core/process.hh b/src/systemc/core/process.hh
index 4b43e1b..1ea5997 100644
--- a/src/systemc/core/process.hh
+++ b/src/systemc/core/process.hh
@@ -64,7 +64,9 @@
Sensitivity(Process *p) : process(p) {}
virtual ~Sensitivity() {}
- virtual void notifyWork(Event *e);
+ void satisfy(bool timedOut=false);
+
+ virtual void notifyWork(Event *e) { satisfy(); }
void notify(Event *e);
void notify() { notify(nullptr); }
@@ -130,6 +132,8 @@
Process *p, ::sc_core::sc_time t, const ::sc_core::sc_event
*e) :
Sensitivity(p), SensitivityTimeout(p, t), SensitivityEvent(p, e)
{}
+
+ void notifyWork(Event *e) override { satisfy(e == nullptr); }
};
class SensitivityTimeoutAndEventAndList :
@@ -156,6 +160,8 @@
Sensitivity(p), SensitivityTimeout(p, t),
SensitivityEventOrList(p, eol)
{}
+
+ void notifyWork(Event *e) override { satisfy(e == nullptr); }
};
typedef std::vector<Sensitivity *> Sensitivities;
@@ -338,6 +344,8 @@
bool hasStaticSensitivities() { return !staticSensitivities.empty(); }
bool internal() { return _internal; }
+ bool timedOut() { return _timedOut; }
+ void timedOut(bool to) { _timedOut = to; }
protected:
Process(const char *name, ProcessFuncWrapper *func, bool
internal=false);
@@ -360,6 +368,9 @@
bool _internal;
+ // Needed to support the deprecated "timed_out" function.
+ bool _timedOut;
+
bool _needsStart;
bool _dynamic;
bool _isUnwinding;
@@ -386,8 +397,9 @@
};
inline void
-Sensitivity::notifyWork(Event *e)
+Sensitivity::satisfy(bool timedOut)
{
+ process->timedOut(timedOut);
process->satisfySensitivity(this);
}
diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index 2ba0fa2..3cceff1 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -361,8 +361,7 @@
bool
sc_module::timed_out()
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return false;
+ return ::sc_core::timed_out();
}
@@ -561,8 +560,11 @@
bool
timed_out()
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return false;
+ ::sc_gem5::Process *p = sc_gem5::scheduler.current();
+ if (!p)
+ return false;
+ else
+ return p->timedOut();
}
diff --git a/src/systemc/core/sc_prim.cc b/src/systemc/core/sc_prim.cc
index 170abb5..0f44101 100644
--- a/src/systemc/core/sc_prim.cc
+++ b/src/systemc/core/sc_prim.cc
@@ -141,8 +141,7 @@
bool
sc_prim_channel::timed_out()
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return false;
+ return ::sc_core::timed_out();
}
void
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12608
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I533d97fe66d20d7b83aba80f2ef45a8944668070
Gerrit-Change-Number: 12608
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev