event_finder.hh revision 13522
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 2313521Sgabeblack@google.com#include "tlm_core/1/req_rsp/interfaces/tag.hh" 2413521Sgabeblack@google.com 2513521Sgabeblack@google.comnamespace tlm 2613521Sgabeblack@google.com{ 2713521Sgabeblack@google.com 2813521Sgabeblack@google.comtemplate <class IF, class T> 2913521Sgabeblack@google.comclass tlm_event_finder_t : public sc_core::sc_event_finder 3013521Sgabeblack@google.com{ 3113521Sgabeblack@google.com public: 3213521Sgabeblack@google.com tlm_event_finder_t(const sc_core::sc_port_base &port_, 3313521Sgabeblack@google.com const sc_core::sc_event &(IF::*event_method_)( 3413521Sgabeblack@google.com tlm_tag<T> *) const) : 3513521Sgabeblack@google.com sc_core::sc_event_finder(port_), m_event_method(event_method_) 3613521Sgabeblack@google.com {} 3713521Sgabeblack@google.com 3813521Sgabeblack@google.com virtual ~tlm_event_finder_t() {} 3913521Sgabeblack@google.com 4013521Sgabeblack@google.com virtual const sc_core::sc_event & 4113521Sgabeblack@google.com find_event(sc_core::sc_interface *if_p=nullptr) const; 4213521Sgabeblack@google.com 4313521Sgabeblack@google.com private: 4413521Sgabeblack@google.com const sc_core::sc_event &(IF::*m_event_method)(tlm_tag<T> *) const; 4513521Sgabeblack@google.com 4613521Sgabeblack@google.com private: 4713521Sgabeblack@google.com // disabled 4813521Sgabeblack@google.com tlm_event_finder_t(); 4913521Sgabeblack@google.com tlm_event_finder_t(const tlm_event_finder_t<IF, T> &); 5013521Sgabeblack@google.com tlm_event_finder_t<IF, T> &operator = (const tlm_event_finder_t<IF, T> &); 5113521Sgabeblack@google.com}; 5213521Sgabeblack@google.com 5313521Sgabeblack@google.comtemplate <class IF, class T> 5413521Sgabeblack@google.cominline const sc_core::sc_event & 5513521Sgabeblack@google.comtlm_event_finder_t<IF, T>::find_event(sc_core::sc_interface *if_p) const 5613521Sgabeblack@google.com{ 5713521Sgabeblack@google.com const IF *iface = if_p ? dynamic_cast<const IF *>(if_p) : 5813521Sgabeblack@google.com dynamic_cast<const IF *>(port()->_gem5Interface(0)); 5913522Sgabeblack@google.com static sc_core::sc_event none; 6013521Sgabeblack@google.com if (iface == nullptr) { 6113521Sgabeblack@google.com report_error(sc_core::SC_ID_FIND_EVENT_, "port is not bound"); 6213522Sgabeblack@google.com return none; 6313521Sgabeblack@google.com } 6413521Sgabeblack@google.com return (const_cast<IF *>(iface)->*m_event_method)(nullptr); 6513521Sgabeblack@google.com} 6613521Sgabeblack@google.com 6713521Sgabeblack@google.com} // namespace tlm 6813521Sgabeblack@google.com 6913521Sgabeblack@google.com#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_HH__ */ 70