Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/12210
Change subject: systemc: Track exports and prim channels, and call their
callbacks.
......................................................................
systemc: Track exports and prim channels, and call their callbacks.
Also call the callbacks on the ports which were already being tracked.
Change-Id: I5ba8ea366e87fc48b58712f35b93c27bccf92cb3
---
M src/systemc/core/channel.cc
M src/systemc/core/channel.hh
M src/systemc/core/kernel.cc
M src/systemc/core/module.hh
M src/systemc/core/sc_export.cc
M src/systemc/ext/core/sc_export.hh
M src/systemc/ext/core/sc_port.hh
M src/systemc/ext/core/sc_prim.hh
8 files changed, 80 insertions(+), 14 deletions(-)
diff --git a/src/systemc/core/channel.cc b/src/systemc/core/channel.cc
index 4a862b8..49d9f6c 100644
--- a/src/systemc/core/channel.cc
+++ b/src/systemc/core/channel.cc
@@ -34,6 +34,16 @@
namespace sc_gem5
{
+Channel::Channel(sc_core::sc_prim_channel *_sc_chan) : _sc_chan(_sc_chan)
+{
+ allChannels.insert(this);
+}
+
+Channel::~Channel()
+{
+ allChannels.erase(this);
+}
+
void
Channel::requestUpdate()
{
@@ -47,4 +57,6 @@
scheduler.requestUpdate(this);
}
+std::set<Channel *> allChannels;
+
} // namespace sc_gem5
diff --git a/src/systemc/core/channel.hh b/src/systemc/core/channel.hh
index 7ce4375..6111e3c 100644
--- a/src/systemc/core/channel.hh
+++ b/src/systemc/core/channel.hh
@@ -30,6 +30,8 @@
#ifndef __SYSTEMC_CORE_CHANNEL_HH__
#define __SYSTEMC_CORE_CHANNEL_HH__
+#include <set>
+
#include "systemc/core/list.hh"
#include "systemc/ext/core/sc_prim.hh"
@@ -39,9 +41,9 @@
class Channel : public ListNode
{
public:
- Channel(sc_core::sc_prim_channel *_sc_chan) : _sc_chan(_sc_chan) {}
+ Channel(sc_core::sc_prim_channel *_sc_chan);
- virtual ~Channel() {}
+ virtual ~Channel();
void requestUpdate();
void asyncRequestUpdate();
@@ -53,6 +55,8 @@
sc_core::sc_prim_channel *_sc_chan;
};
+extern std::set<Channel *> allChannels;
+
} // namespace sc_gem5
#endif //__SYSTEMC_CORE_CHANNEL_HH__
diff --git a/src/systemc/core/kernel.cc b/src/systemc/core/kernel.cc
index 65a4445..84bdfd1 100644
--- a/src/systemc/core/kernel.cc
+++ b/src/systemc/core/kernel.cc
@@ -30,6 +30,7 @@
#include "systemc/core/kernel.hh"
#include "base/logging.hh"
+#include "systemc/core/channel.hh"
#include "systemc/core/module.hh"
#include "systemc/core/scheduler.hh"
@@ -67,8 +68,14 @@
for (auto m: sc_gem5::allModules) {
callbackModule(m);
m->sc_mod()->before_end_of_elaboration();
+ for (auto p: m->ports)
+ p->before_end_of_elaboration();
+ for (auto e: m->exports)
+ e->before_end_of_elaboration();
}
callbackModule(nullptr);
+ for (auto c: sc_gem5::allChannels)
+ c->sc_chan()->before_end_of_elaboration();
if (stopAfterCallbacks)
stopWork();
@@ -82,8 +89,15 @@
p->_gem5Finalize();
status(::sc_core::SC_END_OF_ELABORATION);
- for (auto m: sc_gem5::allModules)
+ for (auto m: sc_gem5::allModules) {
m->sc_mod()->end_of_elaboration();
+ for (auto p: m->ports)
+ p->end_of_elaboration();
+ for (auto e: m->exports)
+ e->end_of_elaboration();
+ }
+ for (auto c: sc_gem5::allChannels)
+ c->sc_chan()->end_of_elaboration();
if (stopAfterCallbacks)
stopWork();
@@ -93,8 +107,15 @@
Kernel::startup()
{
status(::sc_core::SC_START_OF_SIMULATION);
- for (auto m: sc_gem5::allModules)
+ for (auto m: sc_gem5::allModules) {
m->sc_mod()->start_of_simulation();
+ for (auto p: m->ports)
+ p->start_of_simulation();
+ for (auto e: m->exports)
+ e->start_of_simulation();
+ }
+ for (auto c: sc_gem5::allChannels)
+ c->sc_chan()->start_of_simulation();
startComplete = true;
@@ -121,8 +142,15 @@
Kernel::stopWork()
{
status(::sc_core::SC_END_OF_SIMULATION);
- for (auto m: sc_gem5::allModules)
+ for (auto m: sc_gem5::allModules) {
m->sc_mod()->end_of_simulation();
+ for (auto p: m->ports)
+ p->end_of_simulation();
+ for (auto e: m->exports)
+ e->end_of_simulation();
+ }
+ for (auto c: sc_gem5::allChannels)
+ c->sc_chan()->end_of_simulation();
endComplete = true;
diff --git a/src/systemc/core/module.hh b/src/systemc/core/module.hh
index 0a6d9b7..e988b96 100644
--- a/src/systemc/core/module.hh
+++ b/src/systemc/core/module.hh
@@ -44,6 +44,7 @@
{
class sc_port_base;
+class sc_export_base;
} // namespace sc_core
@@ -111,6 +112,7 @@
const char *uniqueName(const char *seed) { return nameGen.gen(seed); }
std::vector<::sc_core::sc_port_base *> ports;
+ std::vector<::sc_core::sc_export_base *> exports;
};
Module *currentModule();
diff --git a/src/systemc/core/sc_export.cc b/src/systemc/core/sc_export.cc
index 8340cf9..383552b 100644
--- a/src/systemc/core/sc_export.cc
+++ b/src/systemc/core/sc_export.cc
@@ -28,12 +28,17 @@
*/
#include "base/logging.hh"
+#include "systemc/core/module.hh"
#include "systemc/ext/core/sc_export.hh"
namespace sc_core
{
-sc_export_base::sc_export_base(const char *n) : sc_object(n) {}
+sc_export_base::sc_export_base(const char *n) : sc_object(n)
+{
+ ::sc_gem5::Module *m = ::sc_gem5::currentModule();
+ m->exports.push_back(this);
+}
sc_export_base::~sc_export_base() {}
} // namespace sc_core
diff --git a/src/systemc/ext/core/sc_export.hh
b/src/systemc/ext/core/sc_export.hh
index f3cf816..f5ce894 100644
--- a/src/systemc/ext/core/sc_export.hh
+++ b/src/systemc/ext/core/sc_export.hh
@@ -46,6 +46,14 @@
virtual sc_interface *get_iterface() = 0;
virtual const sc_interface *get_interface() const = 0;
+
+ protected:
+ friend class sc_gem5::Kernel;
+
+ virtual void before_end_of_elaboration() = 0;
+ virtual void end_of_elaboration() = 0;
+ virtual void start_of_simulation() = 0;
+ virtual void end_of_simulation() = 0;
};
template <class IF>
@@ -74,10 +82,10 @@
const sc_interface *get_interface() const override { return interface;
}
protected:
- virtual void before_end_of_elaboration() {}
- virtual void end_of_elaboration() {}
- virtual void start_of_simulation() {}
- virtual void end_of_simulation() {}
+ void before_end_of_elaboration() {}
+ void end_of_elaboration() {}
+ void start_of_simulation() {}
+ void end_of_simulation() {}
private:
IF *interface;
diff --git a/src/systemc/ext/core/sc_port.hh
b/src/systemc/ext/core/sc_port.hh
index 6031d54..73f5362 100644
--- a/src/systemc/ext/core/sc_port.hh
+++ b/src/systemc/ext/core/sc_port.hh
@@ -75,6 +75,11 @@
virtual int vbind(sc_interface &) = 0;
virtual int vbind(sc_port_base &) = 0;
+ virtual void before_end_of_elaboration() = 0;
+ virtual void end_of_elaboration() = 0;
+ virtual void start_of_simulation() = 0;
+ virtual void end_of_simulation() = 0;
+
private:
friend class ::sc_gem5::PendingSensitivityPort;
friend class ::sc_gem5::Kernel;
@@ -110,10 +115,10 @@
const sc_interface *get_interface() const { return _interfaces.at(0); }
protected:
- virtual void before_end_of_elaboration() {}
- virtual void end_of_elaboration() {}
- virtual void start_of_elaboration() {}
- virtual void end_of_simulation() {}
+ void before_end_of_elaboration() {}
+ void end_of_elaboration() {}
+ void start_of_simulation() {}
+ void end_of_simulation() {}
explicit sc_port_b(int n, sc_port_policy p) :
sc_port_base(sc_gen_unique_name("port"), n, p)
diff --git a/src/systemc/ext/core/sc_prim.hh
b/src/systemc/ext/core/sc_prim.hh
index 1064892..99e2314 100644
--- a/src/systemc/ext/core/sc_prim.hh
+++ b/src/systemc/ext/core/sc_prim.hh
@@ -91,6 +91,8 @@
void wait(const sc_time &, const sc_event_and_list &);
void wait(double, sc_time_unit, const sc_event_and_list &);
+ friend class sc_gem5::Kernel;
+
virtual void before_end_of_elaboration() {}
virtual void end_of_elaboration() {}
virtual void start_of_simulation() {}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12210
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: I5ba8ea366e87fc48b58712f35b93c27bccf92cb3
Gerrit-Change-Number: 12210
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev