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();
199 {
return m_port_vec.size(); }
210 void complete_binding();
213 bool construction_done();
216 void elaboration_done();
219 void start_simulation();
222 void simulation_done();
228 int m_construction_done;
229 std::vector<sc_port_base*> m_port_vec;
271 { this->
bind( interface_ ); }
280 { this->
bind( parent_ ); }
286 {
return m_interface_vec.size(); }
306 {
return m_interface; }
309 {
return m_interface; }
317 base_type( max_size_, policy ), m_interface( 0 ), m_interface_vec()
322 base_type( name_, max_size_, policy ), m_interface( 0 ),
347 virtual const char* if_typename()
const;
348 virtual int interface_count();
358 std::vector<IF*> m_interface_vec;
372 template <
class IF,
int N = 1, sc_port_policy P=SC_ONE_OR_MORE_BOUND>
423 virtual const char*
kind()
const
424 {
return "sc_port"; }
430 this_type& operator = (
const this_type& );
449 if( m_interface == 0 ) {
450 report_error( SC_ID_GET_IF_,
"port is not bound" );
460 if( m_interface == 0 ) {
461 report_error( SC_ID_GET_IF_,
"port is not bound" );
481 else if( index_ < 0 || index_ >= size() ) {
482 report_error( SC_ID_GET_IF_,
"index out of range" );
484 return m_interface_vec[index_];
495 else if( index_ < 0 || index_ >= size() ) {
496 report_error( SC_ID_GET_IF_,
"index out of range" );
498 return m_interface_vec[index_];
509 IF* iface = DCAST<IF*>( &interface_ );
514 base_type::bind( *iface );
523 this_type* parent = DCAST<this_type*>( &parent_ );
528 base_type::bind( *parent );
540 IF* iface = DCAST<IF*>( interface_ );
541 assert( iface != 0 );
545 int size = m_interface_vec.size();
546 for (
int i = 0; i < size; i++ )
548 if ( iface == m_interface_vec[i] )
550 report_error( SC_ID_BIND_IF_TO_PORT_,
551 "interface already bound to port" );
557 m_interface_vec.push_back( iface );
558 m_interface = m_interface_vec[0];
564 sc_port_b<IF>::if_typename()
const
566 return typeid( IF ).name();
572 sc_port_b<IF>::interface_count()
574 return m_interface_vec.size();
582 if ( m_bind_info == 0 )
584 int if_n = m_interface_vec.size();
585 for (
int if_i = 0; if_i < if_n; if_i++ )
587 IF* iface_p = m_interface_vec[if_i];
588 assert( iface_p != 0 );
589 add_static_event( handle_p, iface_p->default_event() );
603 if ( m_bind_info == 0 )
605 int if_n = m_interface_vec.size();
606 for (
int if_i = 0; if_i < if_n; if_i++ )
608 IF* iface_p = m_interface_vec[if_i];
609 assert( iface_p != 0 );
610 add_static_event( handle_p, iface_p->default_event() );
virtual sc_interface * get_interface()=0
virtual const char * kind() const
virtual void start_of_simulation()
virtual void before_end_of_elaboration()
virtual sc_interface * get_interface()
sc_bind_info * m_bind_info
virtual void end_of_elaboration()
virtual int interface_count()=0
void operator()(IF &interface_)
sc_port(this_type &parent_)
void report_error(const char *id, const char *add_msg=0) const
SC_VIRTUAL_ void bind(IF &interface_)
class sc_thread_process * sc_thread_handle
virtual int vbind(sc_interface &)=0
sc_port_b< IF > this_type
SC_VIRTUAL_ void bind(port_type &parent_)
sc_port_b(const char *name_, int max_size_, sc_port_policy policy=SC_ONE_OR_MORE_BOUND)
sc_port(const char *name_, this_type &parent_)
void add_static_event(sc_method_handle process_p, const sc_event &event) const
sc_port_b(int max_size_, sc_port_policy policy=SC_ONE_OR_MORE_BOUND)
void sc_warn_port_constructor()
sc_port(const char *name_, base_type &parent_)
sc_port(const char *name_, IF &interface_)
virtual const sc_interface * get_interface() const
virtual const char * if_typename() const =0
virtual void make_sensitive(sc_thread_handle, sc_event_finder *=0) const
virtual const char * kind() const
sc_port(base_type &parent_)
virtual void add_interface(sc_interface *)=0
virtual void make_sensitive(sc_thread_handle, sc_event_finder *=0) const
void insert(sc_port_base *)
IF * operator[](int index_)
class sc_method_process * sc_method_handle
virtual void end_of_simulation()
sc_port(const char *name_)
void bind(sc_interface &interface_)
virtual int vbind(sc_interface &)