38 #if ! defined( SC_DISABLE_VIRTUAL_BIND )
39 # define SC_VIRTUAL_ virtual
46 class sc_event_finder;
92 virtual const char*
kind()
const
93 {
return "sc_port_base"; }
134 void report_error(
const char*
id,
const char* add_msg = 0)
const;
154 void insert_parent(
int );
157 void construction_done();
160 void complete_binding();
161 void elaboration_done();
164 void start_simulation();
167 void simulation_done();
200 {
return m_port_vec.size(); }
211 void complete_binding();
214 bool construction_done();
217 void elaboration_done();
220 void start_simulation();
223 void simulation_done();
229 int m_construction_done;
230 std::vector<sc_port_base*> m_port_vec;
272 { this->
bind( interface_ ); }
281 { this->
bind( parent_ ); }
287 {
return m_interface_vec.size(); }
307 {
return m_interface; }
310 {
return m_interface; }
318 base_type( max_size_, policy ), m_interface( 0 ), m_interface_vec()
323 base_type( name_, max_size_, policy ), m_interface( 0 ),
348 virtual const char* if_typename()
const;
349 virtual int interface_count();
359 std::vector<IF*> m_interface_vec;
374 template <
class IF,
int N = 1, sc_port_policy P=SC_ONE_OR_MORE_BOUND>
425 virtual const char*
kind()
const
426 {
return "sc_port"; }
432 this_type& operator = (
const this_type& );
451 if( m_interface == 0 ) {
452 report_error( SC_ID_GET_IF_,
"port is not bound" );
462 if( m_interface == 0 ) {
463 report_error( SC_ID_GET_IF_,
"port is not bound" );
483 else if( index_ < 0 || index_ >= size() ) {
484 report_error( SC_ID_GET_IF_,
"index out of range" );
486 return m_interface_vec[index_];
497 else if( index_ < 0 || index_ >= size() ) {
498 report_error( SC_ID_GET_IF_,
"index out of range" );
500 return m_interface_vec[index_];
511 IF* iface = DCAST<IF*>( &interface_ );
516 base_type::bind( *iface );
525 this_type* parent = DCAST<this_type*>( &parent_ );
530 base_type::bind( *parent );
542 IF* iface = DCAST<IF*>( interface_ );
543 assert( iface != 0 );
547 int size = m_interface_vec.size();
548 for (
int i = 0; i < size; i++ )
550 if ( iface == m_interface_vec[i] )
552 report_error( SC_ID_BIND_IF_TO_PORT_,
553 "interface already bound to port" );
559 m_interface_vec.push_back( iface );
560 m_interface = m_interface_vec[0];
566 sc_port_b<IF>::if_typename()
const
568 return typeid( IF ).name();
574 sc_port_b<IF>::interface_count()
576 return m_interface_vec.size();
584 if ( m_bind_info == 0 )
586 int if_n = m_interface_vec.size();
587 for (
int if_i = 0; if_i < if_n; if_i++ )
589 IF* iface_p = m_interface_vec[if_i];
590 assert( iface_p != 0 );
591 add_static_event( handle_p, iface_p->default_event() );
605 if ( m_bind_info == 0 )
607 int if_n = m_interface_vec.size();
608 for (
int if_i = 0; if_i < if_n; if_i++ )
610 IF* iface_p = m_interface_vec[if_i];
611 assert( iface_p != 0 );
612 add_static_event( handle_p, iface_p->default_event() );
virtual void add_interface(sc_interface *)=0
virtual void start_of_simulation()
sc_port(const char *name_, IF &interface_)
virtual void end_of_simulation()
virtual const char * kind() const
virtual void make_sensitive(sc_thread_handle, sc_event_finder *=0) const
Abstract base class for class sc_port.
sc_port(base_type &parent_)
virtual void end_of_elaboration()
void report_error(const char *id, const char *add_msg=0) const
virtual sc_interface * get_interface()=0
SC_VIRTUAL_ void bind(port_type &parent_)
Generic port class and base class for other port classes.
virtual void make_sensitive(sc_thread_handle, sc_event_finder *=0) const
virtual int interface_count()=0
class sc_method_process * sc_method_handle
sc_port_b< IF > this_type
virtual void before_end_of_elaboration()
virtual const char * kind() const
sc_port(this_type &parent_)
void sc_warn_port_constructor()
SC_VIRTUAL_ void bind(IF &interface_)
sc_port(const char *name_, this_type &parent_)
class sc_thread_process * sc_thread_handle
virtual const char * if_typename() const =0
sc_port(const char *name_, base_type &parent_)
void add_static_event(sc_method_handle process_p, const sc_event &event) const
sc_port_b(const char *name_, int max_size_, sc_port_policy policy=SC_ONE_OR_MORE_BOUND)
sc_port_b(int max_size_, sc_port_policy policy=SC_ONE_OR_MORE_BOUND)
virtual int vbind(sc_interface &)
void operator()(IF &interface_)
Abstract base class of all interface classes.
virtual sc_interface * get_interface()
Base class for all structural entities.
virtual int vbind(sc_interface &)=0
Abstract base class for class sc_port_b.
void bind(sc_interface &interface_)
void insert(sc_port_base *)
sc_port(const char *name_)
virtual const sc_interface * get_interface() const
Abstract base class of all SystemC `simulation' objects.
sc_bind_info * m_bind_info
IF * operator[](int index_)