summaryrefslogtreecommitdiff
path: root/src/systemc/ext/core
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-08-13 18:14:35 -0700
committerGabe Black <gabeblack@google.com>2018-09-20 01:45:22 +0000
commit148713bd8ba40c854724d5a6b066a7f46007c63f (patch)
tree30eb71a3504fb389266b3ffc10ab7dc367472929 /src/systemc/ext/core
parent68c292841318646835249667251180729186b242 (diff)
downloadgem5-148713bd8ba40c854724d5a6b066a7f46007c63f.tar.xz
systemc: Implement sc_event_finder.
Change-Id: I22aa0a34eabf13593986a92289155257fa26c7de Reviewed-on: https://gem5-review.googlesource.com/12082 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/ext/core')
-rw-r--r--src/systemc/ext/core/sc_event.hh22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/systemc/ext/core/sc_event.hh b/src/systemc/ext/core/sc_event.hh
index c2154967d..f8a32f343 100644
--- a/src/systemc/ext/core/sc_event.hh
+++ b/src/systemc/ext/core/sc_event.hh
@@ -30,9 +30,11 @@
#ifndef __SYSTEMC_EXT_CORE_SC_EVENT_HH__
#define __SYSTEMC_EXT_CORE_SC_EVENT_HH__
+#include <cassert>
#include <set>
#include <vector>
+#include "sc_port.hh"
#include "sc_time.hh"
namespace sc_gem5
@@ -58,6 +60,7 @@ class sc_event_finder
{
protected:
void warn_unimpl(const char *func) const;
+ virtual ~sc_event_finder() {}
public:
// Should be "implementation defined" but used in the tests.
@@ -68,18 +71,27 @@ template <class IF>
class sc_event_finder_t : public sc_event_finder
{
public:
- sc_event_finder_t(const sc_port_base &,
- const sc_event & (IF::*event_method)() const)
+ sc_event_finder_t(const sc_port_base &p,
+ const sc_event & (IF::*_method)() const) :
+ _method(_method)
{
- warn_unimpl(__PRETTY_FUNCTION__);
+ _port = dynamic_cast<const sc_port_b<IF> *>(&p);
+ assert(_port);
}
+ virtual ~sc_event_finder_t() {}
+
const sc_event &
find_event(sc_interface *if_p=NULL) const override
{
- warn_unimpl(__PRETTY_FUNCTION__);
- return *(const sc_event *)nullptr;
+ const IF *iface = if_p ? dynamic_cast<const IF *>(if_p) :
+ dynamic_cast<const IF *>(_port->get_interface());
+ return (const_cast<IF *>(iface)->*_method)();
}
+
+ private:
+ const sc_port_b<IF> *_port;
+ const sc_event &(IF::*_method)() const;
};
class sc_event_and_list