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 <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
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()
{
scheduler.requestUpdate(this);
}
+std::set<Channel *> allChannels;
+
} // namespace sc_gem5
#ifndef __SYSTEMC_CORE_CHANNEL_HH__
#define __SYSTEMC_CORE_CHANNEL_HH__
+#include <set>
+
#include "systemc/core/list.hh"
#include "systemc/ext/core/sc_prim.hh"
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();
sc_core::sc_prim_channel *_sc_chan;
};
+extern std::set<Channel *> allChannels;
+
} // namespace sc_gem5
#endif //__SYSTEMC_CORE_CHANNEL_HH__
#include "systemc/core/kernel.hh"
#include "base/logging.hh"
+#include "systemc/core/channel.hh"
#include "systemc/core/module.hh"
#include "systemc/core/scheduler.hh"
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();
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();
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;
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;
{
class sc_port_base;
+class sc_export_base;
} // namespace sc_core
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();
*/
#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
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>
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;
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;
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)
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() {}