1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 sc_event_finder.h -- 23 24 Original Author: Martin Janssen, Synopsys, Inc. 25 Stan Y. Liao, Synopsys, Inc., 2001-05-21 26 27 CHANGE LOG IS AT THE END OF THE FILE 28 *****************************************************************************/ 29 30#ifndef SC_EVENT_FINDER 31#define SC_EVENT_FINDER 32 33 34#include "sysc/communication/sc_port.h" 35 36namespace sc_core { 37 38// ---------------------------------------------------------------------------- 39// CLASS : sc_event_finder 40// 41// Event finder base class. 42// ---------------------------------------------------------------------------- 43 44class sc_event_finder 45{ 46 friend class sc_simcontext; 47 48public: 49 50 const sc_port_base& port() const 51 { return m_port; } 52 53 // destructor (does nothing) 54 virtual ~sc_event_finder(); 55 56 virtual const sc_event& find_event( sc_interface* if_p = 0 ) const = 0; 57 58protected: 59 60 // constructor 61 sc_event_finder( const sc_port_base& ); 62 63 // error reporting 64 void report_error( const char* id, const char* add_msg = 0 ) const; 65 66 67private: 68 const sc_port_base& m_port; // port providing the event. 69 70private: 71 72 // disabled 73 sc_event_finder(); 74 sc_event_finder( const sc_event_finder& ); 75 sc_event_finder& operator = ( const sc_event_finder& ); 76}; 77 78 79// ---------------------------------------------------------------------------- 80// CLASS : sc_event_finder_t<IF> 81// 82// Interface specific event finder class. 83// ---------------------------------------------------------------------------- 84 85template <class IF> 86class sc_event_finder_t 87: public sc_event_finder 88{ 89public: 90 91 // constructor 92 93 sc_event_finder_t( const sc_port_base& port_, 94 const sc_event& (IF::*event_method_) () const ) 95 : sc_event_finder( port_ ), m_event_method( event_method_ ) 96 {} 97 98 // destructor (does nothing) 99 100 virtual ~sc_event_finder_t() 101 {} 102 103 virtual const sc_event& find_event( sc_interface* if_p = 0 ) const; 104 105private: 106 107 const sc_event& (IF::*m_event_method) () const; 108 109private: 110 111 // disabled 112 sc_event_finder_t(); 113 sc_event_finder_t( const sc_event_finder_t<IF>& ); 114 sc_event_finder_t<IF>& operator = ( const sc_event_finder_t<IF>& ); 115}; 116 117 118// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 119 120template <class IF> 121inline 122const sc_event& 123sc_event_finder_t<IF>::find_event( sc_interface* if_p ) const 124{ 125 const IF* iface = ( if_p ) ? DCAST<const IF*>( if_p ) : 126 DCAST<const IF*>( port().get_interface() ); 127 if( iface == 0 ) { 128 report_error( SC_ID_FIND_EVENT_, "port is not bound" ); 129 } 130 return (CCAST<IF*>( iface )->*m_event_method) (); 131} 132 133} // namespace sc_core 134 135//$Log: sc_event_finder.h,v $ 136//Revision 1.3 2011/08/26 20:45:39 acg 137// Andy Goodrich: moved the modification log to the end of the file to 138// eliminate source line number skew when check-ins are done. 139// 140//Revision 1.2 2011/02/18 20:23:45 acg 141// Andy Goodrich: Copyright update. 142// 143//Revision 1.1.1.1 2006/12/15 20:20:04 acg 144//SystemC 2.3 145// 146//Revision 1.4 2006/02/02 23:42:37 acg 147// Andy Goodrich: implemented a much better fix to the sc_event_finder 148// proliferation problem. This new version allocates only a single event 149// finder for each port for each type of event, e.g., pos(), neg(), and 150// value_change(). The event finder persists as long as the port does, 151// which is what the LRM dictates. Because only a single instance is 152// allocated for each event type per port there is not a potential 153// explosion of storage as was true in the 2.0.1/2.1 versions. 154// 155//Revision 1.3 2006/02/02 20:43:09 acg 156// Andy Goodrich: Added an existence linked list to sc_event_finder so that 157// the dynamically allocated instances can be freed after port binding 158// completes. This replaces the individual deletions in ~sc_bind_ef, as these 159// caused an exception if an sc_event_finder instance was used more than 160// once, due to a double freeing of the instance. 161// 162//Revision 1.2 2006/01/03 23:18:26 acg 163//Changed copyright to include 2006. 164// 165//Revision 1.1.1.1 2005/12/19 23:16:43 acg 166//First check in of SystemC 2.1 into its own archive. 167// 168//Revision 1.10 2005/09/15 23:01:51 acg 169//Added std:: prefix to appropriate methods and types to get around 170//issues with the Edison Front End. 171// 172//Revision 1.9 2005/06/10 22:43:55 acg 173//Added CVS change log annotation. 174// 175 176#endif 177 178// Taf! 179