44 #if ! defined( SC_DISABLE_VIRTUAL_BIND ) 45 # define SC_VIRTUAL_ virtual 50 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN) 52 #pragma warning(disable: 4251) // DLL import for std::vector 57 class sc_event_finder;
104 virtual const char*
kind()
const 105 {
return "sc_port_base"; }
125 void bind( this_type& parent_ );
134 virtual int interface_count()
const = 0;
136 const char* if_typename()
const 137 {
return get_interface_type().name(); }
141 virtual void before_end_of_elaboration();
144 virtual void end_of_elaboration();
147 virtual void start_of_simulation();
150 virtual void end_of_simulation();
153 void report_error(
const char*
id,
const char* add_msg = 0)
const;
159 void add_static_event(
161 void add_static_event(
173 void insert_parent(
int );
176 void construction_done();
179 void complete_binding();
180 void elaboration_done();
183 void start_simulation();
186 void simulation_done();
197 this_type& operator = (
const this_type& );
218 {
return static_cast<int>(m_port_vec.size()); }
229 void complete_binding();
232 bool construction_done();
235 void elaboration_done();
238 void start_simulation();
241 void simulation_done();
247 int m_construction_done;
248 std::vector<sc_port_base*> m_port_vec;
287 { base_type::bind( interface_ ); }
289 void operator () ( IF& interface_ )
290 { this->bind( interface_ ); }
296 { base_type::bind( parent_ ); }
298 void operator () ( port_type& parent_ )
299 { this->bind( parent_ ); }
305 {
return static_cast<int>(m_interface_vec.size()); }
310 const IF* operator -> ()
const;
314 inline const IF* get_interface(
int iface_i )
const;
315 inline IF* get_interface(
int iface_i );
316 IF* operator [] (
int index_ )
317 {
return get_interface( index_ ); }
318 const IF* operator [] (
int index_ )
const 319 {
return get_interface( index_ ); }
325 {
return m_interface; }
328 {
return m_interface; }
339 base_type( max_size_, policy ), m_interface( 0 ), m_interface_vec()
344 base_type( name_, max_size_, policy ), m_interface( 0 ),
366 virtual int interface_count()
const;
371 this_type& operator = (
const this_type& );
376 std::vector<IF*> m_interface_vec;
390 template <
class IF,
int N = 1, sc_port_policy P=SC_ONE_OR_MORE_BOUND>
408 : base_type( name_, N, P )
416 : base_type( name_, N, P )
423 sc_port(
const char* name_, base_type& parent_ )
424 : base_type( name_, N, P )
431 sc_port(
const char* name_, this_type& parent_ )
432 : base_type( name_, N, P )
441 virtual const char*
kind()
const 442 {
return "sc_port"; }
448 this_type& operator = (
const this_type& );
467 if( m_interface == 0 ) {
468 report_error( SC_ID_GET_IF_,
"port is not bound" );
480 return const_cast<sc_port_b&
>(*this).operator->();
498 else if( index_ < 0 || index_ >= size() ) {
499 report_error( SC_ID_GET_IF_,
"index out of range" );
502 return m_interface_vec[index_];
522 IF* iface =
dynamic_cast<IF*
>( &interface_ );
527 base_type::bind( *iface );
541 base_type::bind( *parent );
553 IF* iface =
dynamic_cast<IF*
>( interface_ );
559 for (
int i = 0; i < if_n; i++ )
561 if ( iface == m_interface_vec[i] )
563 report_error( SC_ID_BIND_IF_TO_PORT_,
564 "interface already bound to port" );
571 m_interface_vec.push_back( iface );
572 m_interface = m_interface_vec[0];
596 if ( m_bind_info == 0 )
599 for (
int if_i = 0; if_i < if_n; if_i++ )
601 IF* iface_p = m_interface_vec[if_i];
603 add_static_event( handle_p, iface_p->default_event() );
617 if ( m_bind_info == 0 )
620 for (
int if_i = 0; if_i < if_n; if_i++ )
622 IF* iface_p = m_interface_vec[if_i];
624 add_static_event( handle_p, iface_p->default_event() );
645 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN) SC_VIRTUAL_ void bind(IF &interface_)
sc_port_b(const char *name_, int max_size_, sc_port_policy policy=SC_ONE_OR_MORE_BOUND)
Static sensitivity class for negative edge events.
sc_port_b< IF > this_type
Process base class support.
Abstract base class of all SystemC `simulation' objects.
sc_bind_info * m_bind_info
virtual void make_sensitive(sc_thread_handle, sc_event_finder *=0) const
const IF * get_interface(int iface_i) const
sc_port(const char *name_)
Generic port class and base class for other port classes.
virtual const char * kind() const
Abstract base class for class sc_port_b.
sc_port_b(int max_size_, sc_port_policy policy=SC_ONE_OR_MORE_BOUND)
virtual int vbind(sc_interface &)
Static sensitivity class for positive edge events.
Abstract base class for class sc_port.
SC_VIRTUAL_ void bind(port_type &parent_)
Abstract base class of all interface classes.
Base class for all structural entities.
Static sensitivity class for events.
Abstract base class of all interface classes.
Wrapper around std::typeinfo to allow usage in containers.
Abstract base class of all SystemC `simulation' objects.
SC_API void sc_warn_port_constructor()
sc_port(const char *name_, base_type &parent_)
sc_port(const char *name_, IF &interface_)
virtual sc_type_index get_interface_type() const
class SC_API sc_port_base
virtual const char * kind() const
sc_port(const char *name_, this_type &parent_)
Report ids for the communication code.
virtual const sc_interface * get_interface() const
class sc_thread_process * sc_thread_handle
class sc_method_process * sc_method_handle
virtual void make_sensitive(sc_thread_handle, sc_event_finder *=0) const
virtual sc_interface * get_interface()
SC_NORETURN_ SC_API void sc_abort()
Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21.
sc_port(this_type &parent_)
sc_port(base_type &parent_)