From aaf0c47c972d3811314db93f0fe1ababf4c408f1 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 25 Jun 2018 20:37:58 -0700 Subject: systemc: Implement some basic plumbing in sc_module.hh. Take care of some low hanging fruit as far as wrapper methods and the sc_bind_proxy class. Change-Id: I7f55a37eeaa82338bd608218c0261fbc39e65fc2 Reviewed-on: https://gem5-review.googlesource.com/11612 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/core/sc_module.cc | 211 +++++++++++++++++--------------------- src/systemc/ext/core/sc_module.hh | 21 +++- 2 files changed, 111 insertions(+), 121 deletions(-) diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc index ffcff9ece..89f74c7f2 100644 --- a/src/systemc/core/sc_module.cc +++ b/src/systemc/core/sc_module.cc @@ -31,34 +31,24 @@ #include #include "base/logging.hh" +#include "systemc/core/module.hh" #include "systemc/ext/core/sc_module.hh" +#include "systemc/ext/core/sc_module_name.hh" namespace sc_core { -sc_bind_proxy::sc_bind_proxy(const sc_interface &interface) -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} +sc_bind_proxy::sc_bind_proxy(const sc_interface &_interface) : + _interface(&_interface), _port(nullptr) +{} -sc_bind_proxy::sc_bind_proxy(const sc_port_base &port) -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} +sc_bind_proxy::sc_bind_proxy(const sc_port_base &_port) : + _interface(nullptr), _port(&_port) +{} const sc_bind_proxy SC_BIND_PROXY_NUL(*(const sc_port_base *)nullptr); -sc_module::~sc_module() -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} - -const char * -sc_module::kind() const -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return ""; -} +sc_module::~sc_module() {} const sc_bind_proxy SC_BIND_PROXY_NIL(*(const sc_port_base *)nullptr); @@ -134,36 +124,25 @@ sc_module::operator () (const sc_bind_proxy &p001, const std::vector & sc_module::get_child_objects() const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return *(const std::vector *)nullptr; + return _gem5_module->obj()->get_child_objects(); } const std::vector & sc_module::get_child_events() const { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); - return *(const std::vector *)nullptr; -} - -sc_module::sc_module(const sc_module_name &) -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + return _gem5_module->obj()->get_child_events(); } -sc_module::sc_module() -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} - -sc_module::sc_module(const char *) -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} +sc_module::sc_module() : + sc_object(sc_gem5::currentModule()->name()), + _gem5_module(sc_gem5::currentModule()) +{} -sc_module::sc_module(const std::string &) -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} +sc_module::sc_module(const sc_module_name &) : sc_module() {} +sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) {} +sc_module::sc_module(const std::string &_name) : + sc_module(sc_module_name(_name.c_str())) +{} void sc_module::reset_signal_is(const sc_in &, bool) @@ -228,76 +207,72 @@ sc_module::set_stack_size(size_t) } -void -sc_module::next_trigger() -{ - warn("%s not implemented.\n", __PRETTY_FUNCTION__); -} +void sc_module::next_trigger() { ::sc_core::next_trigger(); } void -sc_module::next_trigger(const sc_event &) +sc_module::next_trigger(const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(e); } void -sc_module::next_trigger(const sc_event_or_list &) +sc_module::next_trigger(const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(eol); } void -sc_module::next_trigger(const sc_event_and_list &) +sc_module::next_trigger(const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(eal); } void -sc_module::next_trigger(const sc_time &) +sc_module::next_trigger(const sc_time &t) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(t); } void -sc_module::next_trigger(double, sc_time_unit) +sc_module::next_trigger(double d, sc_time_unit u) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(d, u); } void -sc_module::next_trigger(const sc_time &, const sc_event &) +sc_module::next_trigger(const sc_time &t, const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(t, e); } void -sc_module::next_trigger(double, sc_time_unit, const sc_event &) +sc_module::next_trigger(double d, sc_time_unit u, const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(d, u, e); } void -sc_module::next_trigger(const sc_time &, const sc_event_or_list &) +sc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(t, eol); } void -sc_module::next_trigger(double, sc_time_unit, const sc_event_or_list &) +sc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(d, u, eol); } void -sc_module::next_trigger(const sc_time &, const sc_event_and_list &) +sc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(t, eal); } void -sc_module::next_trigger(double, sc_time_unit, const sc_event_and_list &) +sc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::next_trigger(d, u, eal); } @@ -312,110 +287,110 @@ sc_module::timed_out() void sc_module::wait() { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(); } void -sc_module::wait(int) +sc_module::wait(int i) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(i); } void -sc_module::wait(const sc_event &) +sc_module::wait(const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(e); } void -sc_module::wait(const sc_event_or_list &) +sc_module::wait(const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(eol); } void -sc_module::wait(const sc_event_and_list &) +sc_module::wait(const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(eal); } void -sc_module::wait(const sc_time &) +sc_module::wait(const sc_time &t) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(t); } void -sc_module::wait(double, sc_time_unit) +sc_module::wait(double d, sc_time_unit u) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(d, u); } void -sc_module::wait(const sc_time &, const sc_event &) +sc_module::wait(const sc_time &t, const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(t, e); } void -sc_module::wait(double, sc_time_unit, const sc_event &) +sc_module::wait(double d, sc_time_unit u, const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(d, u, e); } void -sc_module::wait(const sc_time &, const sc_event_or_list &) +sc_module::wait(const sc_time &t, const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(t, eol); } void -sc_module::wait(double, sc_time_unit, const sc_event_or_list &) +sc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(d, u, eol); } void -sc_module::wait(const sc_time &, const sc_event_and_list &) +sc_module::wait(const sc_time &t, const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(t, eal); } void -sc_module::wait(double, sc_time_unit, const sc_event_and_list &) +sc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::wait(d, u, eal); } void sc_module::halt() { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::halt(); } void -sc_module::at_posedge(const sc_signal_in_if &) +sc_module::at_posedge(const sc_signal_in_if &s) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::at_posedge(s); } void -sc_module::at_posedge(const sc_signal_in_if &) +sc_module::at_posedge(const sc_signal_in_if &s) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::at_posedge(s); } void -sc_module::at_negedge(const sc_signal_in_if &) +sc_module::at_negedge(const sc_signal_in_if &s) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::at_negedge(s); } void -sc_module::at_negedge(const sc_signal_in_if &) +sc_module::at_negedge(const sc_signal_in_if &s) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + ::sc_core::at_negedge(s); } @@ -450,9 +425,9 @@ next_trigger(const sc_time &) } void -next_trigger(double, sc_time_unit) +next_trigger(double d, sc_time_unit u) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + next_trigger(sc_time(d, u)); } void @@ -462,9 +437,9 @@ next_trigger(const sc_time &, const sc_event &) } void -next_trigger(double, sc_time_unit, const sc_event &) +next_trigger(double d, sc_time_unit u, const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + next_trigger(sc_time(d, u), e); } void @@ -474,9 +449,9 @@ next_trigger(const sc_time &, const sc_event_or_list &) } void -next_trigger(double, sc_time_unit, const sc_event_or_list &) +next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + next_trigger(sc_time(d, u), eol); } void @@ -486,9 +461,9 @@ next_trigger(const sc_time &, const sc_event_and_list &) } void -next_trigger(double, sc_time_unit, const sc_event_and_list &) +next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + next_trigger(sc_time(d, u), eal); } bool @@ -536,9 +511,9 @@ wait(const sc_time &) } void -wait(double, sc_time_unit) +wait(double d, sc_time_unit u) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + wait(sc_time(d, u)); } void @@ -548,9 +523,9 @@ wait(const sc_time &, const sc_event &) } void -wait(double, sc_time_unit, const sc_event &) +wait(double d, sc_time_unit u, const sc_event &e) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + wait(sc_time(d, u), e); } void @@ -560,9 +535,9 @@ wait(const sc_time &, const sc_event_or_list &) } void -wait(double, sc_time_unit, const sc_event_or_list &) +wait(double d, sc_time_unit u, const sc_event_or_list &eol) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + wait(sc_time(d, u), eol); } void @@ -572,9 +547,9 @@ wait(const sc_time &, const sc_event_and_list &) } void -wait(double, sc_time_unit, const sc_event_and_list &) +wait(double d, sc_time_unit u, const sc_event_and_list &eal) { - warn("%s not implemented.\n", __PRETTY_FUNCTION__); + wait(sc_time(d, u), eal); } void diff --git a/src/systemc/ext/core/sc_module.hh b/src/systemc/ext/core/sc_module.hh index 82b48ab16..fd4a802b1 100644 --- a/src/systemc/ext/core/sc_module.hh +++ b/src/systemc/ext/core/sc_module.hh @@ -43,6 +43,13 @@ class sc_logic; } // namespace sc_dt +namespace sc_gem5 +{ + +class Module; + +} // namespace sc_gem5 + namespace sc_core { @@ -62,9 +69,15 @@ class sc_module_name; class sc_bind_proxy { + private: + const sc_interface *_interface; + const sc_port_base *_port; + + friend class sc_module; + public: - sc_bind_proxy(const sc_interface &interface); - sc_bind_proxy(const sc_port_base &port); + sc_bind_proxy(const sc_interface &_interface); + sc_bind_proxy(const sc_port_base &_port); }; extern const sc_bind_proxy SC_BIND_PROXY_NIL; @@ -74,7 +87,7 @@ class sc_module : public sc_object public: virtual ~sc_module(); - virtual const char *kind() const; + virtual const char *kind() const { return "sc_module"; } void operator () (const sc_bind_proxy &p001, const sc_bind_proxy &p002 = SC_BIND_PROXY_NIL, @@ -213,6 +226,8 @@ class sc_module : public sc_object virtual void end_of_simulation() {} private: + sc_gem5::Module *_gem5_module; + // Disabled sc_module(const sc_module &) : sc_object() {}; sc_module &operator = (const sc_module &) { return *this; } -- cgit v1.2.3