From: Gabe Black Date: Tue, 14 Aug 2018 01:14:35 +0000 (-0700) Subject: systemc: Implement sc_event_finder. X-Git-Tag: v19.0.0.0~1768 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=148713bd8ba40c854724d5a6b066a7f46007c63f;p=gem5.git systemc: Implement sc_event_finder. Change-Id: I22aa0a34eabf13593986a92289155257fa26c7de Reviewed-on: https://gem5-review.googlesource.com/12082 Reviewed-by: Gabe Black Maintainer: Gabe Black --- 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 #include #include +#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 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 *>(&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(if_p) : + dynamic_cast(_port->get_interface()); + return (const_cast(iface)->*_method)(); } + + private: + const sc_port_b *_port; + const sc_event &(IF::*_method)() const; }; class sc_event_and_list