event_finder.hh revision 13525
113521Sgabeblack@google.com/***************************************************************************** 213521Sgabeblack@google.com 313521Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 413521Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 513521Sgabeblack@google.com with this work for additional information regarding copyright ownership. 613521Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 713521Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 813521Sgabeblack@google.com License. You may obtain a copy of the License at 913521Sgabeblack@google.com 1013521Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1113521Sgabeblack@google.com 1213521Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1313521Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1413521Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1513521Sgabeblack@google.com implied. See the License for the specific language governing 1613521Sgabeblack@google.com permissions and limitations under the License. 1713521Sgabeblack@google.com 1813521Sgabeblack@google.com *****************************************************************************/ 1913521Sgabeblack@google.com 2013521Sgabeblack@google.com#ifndef __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_HH__ 2113521Sgabeblack@google.com#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_HH__ 2213521Sgabeblack@google.com 2313525Sgabeblack@google.com#include <sstream> 2413525Sgabeblack@google.com 2513521Sgabeblack@google.com#include "tlm_core/1/req_rsp/interfaces/tag.hh" 2613521Sgabeblack@google.com 2713521Sgabeblack@google.comnamespace tlm 2813521Sgabeblack@google.com{ 2913521Sgabeblack@google.com 3013521Sgabeblack@google.comtemplate <class IF, class T> 3113521Sgabeblack@google.comclass tlm_event_finder_t : public sc_core::sc_event_finder 3213521Sgabeblack@google.com{ 3313521Sgabeblack@google.com public: 3413521Sgabeblack@google.com tlm_event_finder_t(const sc_core::sc_port_base &port_, 3513521Sgabeblack@google.com const sc_core::sc_event &(IF::*event_method_)( 3613521Sgabeblack@google.com tlm_tag<T> *) const) : 3713521Sgabeblack@google.com sc_core::sc_event_finder(port_), m_event_method(event_method_) 3813521Sgabeblack@google.com {} 3913521Sgabeblack@google.com 4013521Sgabeblack@google.com virtual ~tlm_event_finder_t() {} 4113521Sgabeblack@google.com 4213521Sgabeblack@google.com virtual const sc_core::sc_event & 4313521Sgabeblack@google.com find_event(sc_core::sc_interface *if_p=nullptr) const; 4413521Sgabeblack@google.com 4513521Sgabeblack@google.com private: 4613521Sgabeblack@google.com const sc_core::sc_event &(IF::*m_event_method)(tlm_tag<T> *) const; 4713521Sgabeblack@google.com 4813521Sgabeblack@google.com private: 4913521Sgabeblack@google.com // disabled 5013521Sgabeblack@google.com tlm_event_finder_t(); 5113521Sgabeblack@google.com tlm_event_finder_t(const tlm_event_finder_t<IF, T> &); 5213521Sgabeblack@google.com tlm_event_finder_t<IF, T> &operator = (const tlm_event_finder_t<IF, T> &); 5313521Sgabeblack@google.com}; 5413521Sgabeblack@google.com 5513521Sgabeblack@google.comtemplate <class IF, class T> 5613521Sgabeblack@google.cominline const sc_core::sc_event & 5713521Sgabeblack@google.comtlm_event_finder_t<IF, T>::find_event(sc_core::sc_interface *if_p) const 5813521Sgabeblack@google.com{ 5913521Sgabeblack@google.com const IF *iface = if_p ? dynamic_cast<const IF *>(if_p) : 6013521Sgabeblack@google.com dynamic_cast<const IF *>(port()->_gem5Interface(0)); 6113521Sgabeblack@google.com if (iface == nullptr) { 6213525Sgabeblack@google.com std::ostringstream out; 6313525Sgabeblack@google.com out << "port is not bound: port '" << port()->name() << 6413525Sgabeblack@google.com "' (" << port()->kind() << ")"; 6513525Sgabeblack@google.com SC_REPORT_ERROR(sc_core::SC_ID_FIND_EVENT_, out.str().c_str()); 6613525Sgabeblack@google.com static sc_core::sc_event none; 6713522Sgabeblack@google.com return none; 6813521Sgabeblack@google.com } 6913521Sgabeblack@google.com return (const_cast<IF *>(iface)->*m_event_method)(nullptr); 7013521Sgabeblack@google.com} 7113521Sgabeblack@google.com 7213521Sgabeblack@google.com} // namespace tlm 7313521Sgabeblack@google.com 7413521Sgabeblack@google.com#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_HH__ */ 75