Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/11612

Change subject: systemc: Implement some basic plumbing in sc_module.hh.
......................................................................

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
---
M src/systemc/core/sc_module.cc
M src/systemc/ext/core/sc_module.hh
2 files changed, 112 insertions(+), 122 deletions(-)



diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index ffcff9e..89f74c7 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -31,34 +31,24 @@
 #include <vector>

 #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 @@
 const std::vector<sc_object *> &
 sc_module::get_child_objects() const
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-    return *(const std::vector<sc_object *> *)nullptr;
+    return _gem5_module->obj()->get_child_objects();
 }

 const std::vector<sc_event *> &
 sc_module::get_child_events() const
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-    return *(const std::vector<sc_event *> *)nullptr;
+    return _gem5_module->obj()->get_child_events();
 }

-sc_module::sc_module(const sc_module_name &)
-{
-    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()
-{
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
-
-sc_module::sc_module(const char *)
-{
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
-
-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> &, bool)
@@ -228,76 +207,72 @@
 }


+void sc_module::next_trigger() { ::sc_core::next_trigger(); }
+
 void
-sc_module::next_trigger()
+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 &)
+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_or_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_event_and_list &)
+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(const sc_time &)
+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(double, sc_time_unit)
+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(const sc_time &, 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(double, sc_time_unit, const sc_event &)
+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(const sc_time &, 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(double, sc_time_unit, const sc_event_or_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(const sc_time &, 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__);
-}
-
-void
-sc_module::next_trigger(double, sc_time_unit, const sc_event_and_list &)
-{
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+    ::sc_core::next_trigger(d, u, eal);
 }


@@ -312,110 +287,110 @@
 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<bool> &)
+sc_module::at_posedge(const sc_signal_in_if<bool> &s)
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+    ::sc_core::at_posedge(s);
 }

 void
-sc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &)
+sc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+    ::sc_core::at_posedge(s);
 }

 void
-sc_module::at_negedge(const sc_signal_in_if<bool> &)
+sc_module::at_negedge(const sc_signal_in_if<bool> &s)
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+    ::sc_core::at_negedge(s);
 }

 void
-sc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &)
+sc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+    ::sc_core::at_negedge(s);
 }


@@ -450,9 +425,9 @@
 }

 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 @@
 }

 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 @@
 }

 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 @@
 }

 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 @@
 }

 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 @@
 }

 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 @@
 }

 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 @@
 }

 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 82b48ab..fd4a802 100644
--- a/src/systemc/ext/core/sc_module.hh
+++ b/src/systemc/ext/core/sc_module.hh
@@ -43,6 +43,13 @@

 } // namespace sc_dt

+namespace sc_gem5
+{
+
+class Module;
+
+} // namespace sc_gem5
+
 namespace sc_core
 {

@@ -62,9 +69,15 @@

 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 @@
   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 @@
     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; }

--
To view, visit https://gem5-review.googlesource.com/11612
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: I7f55a37eeaa82338bd608218c0261fbc39e65fc2
Gerrit-Change-Number: 11612
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

Reply via email to