From f9298649bb4d1f20b244a6e0930bb82be5ec7397 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 15 Aug 2018 23:35:38 -0700 Subject: 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 Reviewed-on: https://gem5-review.googlesource.com/12210 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/core/channel.cc | 12 ++++++++++++ src/systemc/core/channel.hh | 8 ++++++-- src/systemc/core/kernel.cc | 34 +++++++++++++++++++++++++++++++--- src/systemc/core/module.hh | 2 ++ src/systemc/core/sc_export.cc | 7 ++++++- 5 files changed, 57 insertions(+), 6 deletions(-) (limited to 'src/systemc/core') diff --git a/src/systemc/core/channel.cc b/src/systemc/core/channel.cc index 4a862b8aa..49d9f6cb7 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 @@ Channel::asyncRequestUpdate() scheduler.requestUpdate(this); } +std::set allChannels; + } // namespace sc_gem5 diff --git a/src/systemc/core/channel.hh b/src/systemc/core/channel.hh index 7ce437572..6111e3c16 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 + #include "systemc/core/list.hh" #include "systemc/ext/core/sc_prim.hh" @@ -39,9 +41,9 @@ namespace sc_gem5 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 @@ class Channel : public ListNode sc_core::sc_prim_channel *_sc_chan; }; +extern std::set allChannels; + } // namespace sc_gem5 #endif //__SYSTEMC_CORE_CHANNEL_HH__ diff --git a/src/systemc/core/kernel.cc b/src/systemc/core/kernel.cc index 65a444536..84bdfd13f 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 @@ Kernel::init() 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 @@ Kernel::regStats() 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 @@ void 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 @@ void 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 0a6d9b7bb..e988b9667 100644 --- a/src/systemc/core/module.hh +++ b/src/systemc/core/module.hh @@ -44,6 +44,7 @@ namespace sc_core { class sc_port_base; +class sc_export_base; } // namespace sc_core @@ -111,6 +112,7 @@ class Module 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 8340cf9c6..383552b1a 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 -- cgit v1.2.3