Gabe Black has submitted this change and it was merged. (
https://gem5-review.googlesource.com/c/public/gem5/+/12079 )
Change subject: systemc: Implement sc_export.
......................................................................
systemc: Implement sc_export.
This change ignores the rule that sc_exports all have to be bound
exactly once and only by the end of elaboration. If it's bound more
than once, then the earlier binding will be overwritten, and if it's
not bound at all then it will act like a null pointer. To accomodate
doing those checks in the future, the sc_export_base constructor and
destructor are in the .cc file even though they do very little so that
they can be extended to track a list of all exports which exist.
Change-Id: Ie9a3416b8fa87bca55bc9f87f3238c4de3c2e729
Reviewed-on: https://gem5-review.googlesource.com/12079
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/sc_export.cc
M src/systemc/ext/core/sc_export.hh
2 files changed, 22 insertions(+), 37 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
diff --git a/src/systemc/core/sc_export.cc b/src/systemc/core/sc_export.cc
index 387b8a7..8340cf9 100644
--- a/src/systemc/core/sc_export.cc
+++ b/src/systemc/core/sc_export.cc
@@ -33,10 +33,7 @@
namespace sc_core
{
-void
-sc_export_base::warn_unimpl(const char *func) const
-{
- warn("%s not implemented.\n", func);
-}
+sc_export_base::sc_export_base(const char *n) : sc_object(n) {}
+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 421e063..f3cf816 100644
--- a/src/systemc/ext/core/sc_export.hh
+++ b/src/systemc/ext/core/sc_export.hh
@@ -30,6 +30,7 @@
#ifndef __SYSTEMC_EXT_CORE_SC_EXPORT_HH__
#define __SYSTEMC_EXT_CORE_SC_EXPORT_HH__
+#include "sc_module.hh" // for sc_gen_unique_name
#include "sc_object.hh"
namespace sc_core
@@ -40,7 +41,8 @@
class sc_export_base : public sc_object
{
public:
- void warn_unimpl(const char *func) const;
+ sc_export_base(const char *n);
+ ~sc_export_base();
virtual sc_interface *get_iterface() = 0;
virtual const sc_interface *get_interface() const = 0;
@@ -50,42 +52,26 @@
class sc_export : public sc_export_base
{
public:
- sc_export() { warn_unimpl(__PRETTY_FUNCTION__); }
- explicit sc_export(const char *) { warn_unimpl(__PRETTY_FUNCTION__); }
- virtual ~sc_export() { warn_unimpl(__PRETTY_FUNCTION__); };
+ sc_export() :
+ sc_export_base(sc_gen_unique_name("export")), interface(nullptr)
+ {}
+ explicit sc_export(const char *n) :
+ sc_export_base(n), interface(nullptr)
+ {}
+ virtual ~sc_export() {}
virtual const char *kind() const { return "sc_export"; }
- void operator () (IF &) { warn_unimpl(__PRETTY_FUNCTION__); };
- virtual void bind(IF &) { warn_unimpl(__PRETTY_FUNCTION__); };
- operator IF & () { warn_unimpl(__PRETTY_FUNCTION__); };
- operator const IF & () const { warn_unimpl(__PRETTY_FUNCTION__); };
+ void operator () (IF &i) { bind(i); }
+ virtual void bind(IF &i) { interface = &i; }
+ operator IF & () { return *interface; }
+ operator const IF & () const { return *interface; }
- IF *
- operator -> ()
- {
- warn_unimpl(__PRETTY_FUNCTION__);
- return nullptr;
- }
- const IF *
- operator -> () const
- {
- warn_unimpl(__PRETTY_FUNCTION__);
- return nullptr;
- }
+ IF *operator -> () { return interface; }
+ const IF *operator -> () const { return interface; }
- sc_interface *
- get_iterface() override
- {
- warn_unimpl(__PRETTY_FUNCTION__);
- return nullptr;
- }
- const sc_interface *
- get_interface() const override
- {
- warn_unimpl(__PRETTY_FUNCTION__);
- return nullptr;
- }
+ sc_interface *get_iterface() override { return interface; }
+ const sc_interface *get_interface() const override { return interface;
}
protected:
virtual void before_end_of_elaboration() {}
@@ -94,6 +80,8 @@
virtual void end_of_simulation() {}
private:
+ IF *interface;
+
// Disabled
sc_export(const sc_export<IF> &);
sc_export<IF> &operator = (const sc_export<IF> &);
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12079
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: Ie9a3416b8fa87bca55bc9f87f3238c4de3c2e729
Gerrit-Change-Number: 12079
Gerrit-PatchSet: 9
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev