event_finder.hh revision 13521
12SN/A/*****************************************************************************
210905Sandreas.sandberg@arm.com
310905Sandreas.sandberg@arm.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
410905Sandreas.sandberg@arm.com  more contributor license agreements.  See the NOTICE file distributed
510905Sandreas.sandberg@arm.com  with this work for additional information regarding copyright ownership.
610905Sandreas.sandberg@arm.com  Accellera licenses this file to you under the Apache License, Version 2.0
710905Sandreas.sandberg@arm.com  (the "License"); you may not use this file except in compliance with the
810905Sandreas.sandberg@arm.com  License.  You may obtain a copy of the License at
910905Sandreas.sandberg@arm.com
1010905Sandreas.sandberg@arm.com    http://www.apache.org/licenses/LICENSE-2.0
1110905Sandreas.sandberg@arm.com
1210905Sandreas.sandberg@arm.com  Unless required by applicable law or agreed to in writing, software
1310905Sandreas.sandberg@arm.com  distributed under the License is distributed on an "AS IS" BASIS,
141762SN/A  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152SN/A  implied.  See the License for the specific language governing
162SN/A  permissions and limitations under the License.
172SN/A
182SN/A *****************************************************************************/
192SN/A
202SN/A#ifndef __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_HH__
212SN/A#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_HH__
222SN/A
232SN/A#include "tlm_core/1/req_rsp/interfaces/tag.hh"
242SN/A
252SN/Anamespace tlm
262SN/A{
272SN/A
282SN/Atemplate <class IF, class T>
292SN/Aclass tlm_event_finder_t : public sc_core::sc_event_finder
302SN/A{
312SN/A  public:
322SN/A    tlm_event_finder_t(const sc_core::sc_port_base &port_,
332SN/A                       const sc_core::sc_event &(IF::*event_method_)(
342SN/A                           tlm_tag<T> *) const) :
352SN/A        sc_core::sc_event_finder(port_), m_event_method(event_method_)
362SN/A    {}
372SN/A
382SN/A    virtual ~tlm_event_finder_t() {}
392665Ssaidi@eecs.umich.edu
402760Sbinkertn@umich.edu    virtual const sc_core::sc_event &
412760Sbinkertn@umich.edu        find_event(sc_core::sc_interface *if_p=nullptr) const;
422665Ssaidi@eecs.umich.edu
4310905Sandreas.sandberg@arm.com  private:
442SN/A    const sc_core::sc_event &(IF::*m_event_method)(tlm_tag<T> *) const;
452SN/A
462SN/A  private:
472SN/A    // disabled
482SN/A    tlm_event_finder_t();
492SN/A    tlm_event_finder_t(const tlm_event_finder_t<IF, T> &);
502SN/A    tlm_event_finder_t<IF, T> &operator = (const tlm_event_finder_t<IF, T> &);
512SN/A};
522SN/A
532SN/Atemplate <class IF, class T>
548229Snate@binkert.orginline const sc_core::sc_event &
552SN/Atlm_event_finder_t<IF, T>::find_event(sc_core::sc_interface *if_p) const
568229Snate@binkert.org{
5710905Sandreas.sandberg@arm.com    const IF *iface = if_p ? dynamic_cast<const IF *>(if_p) :
584841Ssaidi@eecs.umich.edu        dynamic_cast<const IF *>(port()->_gem5Interface(0));
592SN/A    if (iface == nullptr) {
6010459SAndreas.Sandberg@ARM.com        report_error(sc_core::SC_ID_FIND_EVENT_, "port is not bound");
616214Snate@binkert.org        return sc_core::sc_event::none;
622SN/A    }
632738Sstever@eecs.umich.edu    return (const_cast<IF *>(iface)->*m_event_method)(nullptr);
64395SN/A}
6510905Sandreas.sandberg@arm.com
664000Ssaidi@eecs.umich.edu} // namespace tlm
6711067Sandreas.sandberg@arm.com
689983Sstever@gmail.com#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_HH__ */
692SN/A