⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sc_port.h

📁 system C源码 一种替代verilog的语言
💻 H
📖 第 1 页 / 共 2 页
字号:
    IF* operator [] ( int index_ )        { return get_interface( index_ ); }    const IF* operator [] ( int index_ ) const        { return get_interface( index_ ); }    // get the first interface without checking for nil    virtual sc_interface* get_interface()        { return m_interface; }    virtual const sc_interface* get_interface() const        { return m_interface; }protected:    // constructors    explicit sc_port_b( int max_size_, 	    sc_port_policy policy=SC_ONE_OR_MORE_BOUND )	: base_type( max_size_, policy ), m_interface( 0 )	{}    sc_port_b( const char* name_, int max_size_,                sc_port_policy policy=SC_ONE_OR_MORE_BOUND )	: base_type( name_, max_size_, policy ), m_interface( 0 )	{}    // destructor (does nothing)    virtual ~sc_port_b()	{}    // called by pbind (for internal use only)    virtual int vbind( sc_interface& );    virtual int vbind( sc_port_base& );protected:    // called by the sc_sensitive* classes    virtual void make_sensitive( sc_thread_handle, sc_event_finder* = 0 ) const;    virtual void make_sensitive( sc_method_handle, sc_event_finder* = 0 ) const;private:    // called by complete_binding (for internal use only)    virtual void add_interface( sc_interface* );    virtual const char* if_typename() const;	virtual int interface_count();    // disabled    sc_port_b();    sc_port_b( const this_type& );    this_type& operator = ( const this_type& );private:    IF*              m_interface;	// first interface in interface vec    std::vector<IF*> m_interface_vec;};// ----------------------------------------------------------------------------//  CLASS : sc_port////  Generic port class and base class for other port classes.//  N is the maximum number of channels (with interface IF) that can be bound//  to this port. N <= 0 means no maximum.// ----------------------------------------------------------------------------extern void sc_warn_port_constructor();template <class IF, int N = 1, sc_port_policy P=SC_ONE_OR_MORE_BOUND>class sc_port: public sc_port_b<IF>{    // typdefs    typedef sc_port_b<IF> base_type;    typedef sc_port<IF,N,P> this_type;public:    // constructors    sc_port()	: base_type( N, P )	{}    explicit sc_port( const char* name_ )	: base_type( name_, N, P )	{}    explicit sc_port( IF& interface_ )	: base_type( N, P )	{ sc_warn_port_constructor(); base_type::bind( interface_ ); }    sc_port( const char* name_, IF& interface_ )	: base_type( name_, N, P )	{ sc_warn_port_constructor(); base_type::bind( interface_ ); }    explicit sc_port( base_type& parent_ )	: base_type( N, P )	{ sc_warn_port_constructor(); base_type::bind( parent_ ); }    sc_port( const char* name_, base_type& parent_ )	: base_type( name_, N, P )	{ sc_warn_port_constructor(); base_type::bind( parent_ ); }    sc_port( this_type& parent_ )	: base_type( N, P )	{ sc_warn_port_constructor(); base_type::bind( parent_ ); }    sc_port( const char* name_, this_type& parent_ )	: base_type( name_, N, P )	{ sc_warn_port_constructor(); base_type::bind( parent_ ); }    // destructor (does nothing)    virtual ~sc_port()	{}    virtual const char* kind() const        { return "sc_port"; }private:    // disabled    sc_port( const this_type& );    this_type& operator = ( const this_type& );};// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII// ----------------------------------------------------------------------------//  CLASS : sc_port_b////  Abstract base class for class sc_port.// ----------------------------------------------------------------------------// allow to call methods provided by the first interfacetemplate <class IF>inlineIF*sc_port_b<IF>::operator -> (){    if( m_interface == 0 ) {	report_error( SC_ID_GET_IF_, "port is not bound" );    }    return m_interface;}template <class IF>inlineconst IF*sc_port_b<IF>::operator -> () const{    if( m_interface == 0 ) {	report_error( SC_ID_GET_IF_, "port is not bound" );    }    return m_interface;}// allow to call methods provided by interface at index//// note that we special-case index of zero, since the method may be// called before binding has occurred, and we need to return a zero// in that case not an error.template <class IF>inlineIF*sc_port_b<IF>::get_interface( int index_ ){    if ( index_ == 0 ) {    	return m_interface;    }    else if( index_ < 0 || index_ >= size() ) {	report_error( SC_ID_GET_IF_, "index out of range" );    }    return m_interface_vec[index_];}template <class IF>inlineconst IF*sc_port_b<IF>::get_interface( int index_ ) const{    if ( index_ == 0 ) {    	return m_interface;    }    else if( index_ < 0 || index_ >= size() ) {	report_error( SC_ID_GET_IF_, "index out of range" );    }    return m_interface_vec[index_];}// called by pbind (for internal use only)template <class IF>inlineintsc_port_b<IF>::vbind( sc_interface& interface_ ){    IF* iface = DCAST<IF*>( &interface_ );    if( iface == 0 ) {	// type mismatch	return 2;    }    base_type::bind( *iface );    return 0;}template <class IF>inlineintsc_port_b<IF>::vbind( sc_port_base& parent_ ){    this_type* parent = DCAST<this_type*>( &parent_ );    if( parent == 0 ) {	// type mismatch	return 2;    }    base_type::bind( *parent );    return 0;}// called by complete_binding (for internal use only)template <class IF>inlinevoidsc_port_b<IF>::add_interface( sc_interface* interface_ ){    IF* iface = DCAST<IF*>( interface_ );    assert( iface != 0 );    // make sure that the interface is not already bound:    int size = m_interface_vec.size();    for ( int i = 0; i < size; i++ )    {    	if ( iface == m_interface_vec[i] )	{	    report_error( SC_ID_BIND_IF_TO_PORT_, 	    	"interface already bound to port" );	}    }    // "bind" the interface and make sure our short cut for 0 is set up.    m_interface_vec.push_back( iface );    m_interface = m_interface_vec[0]; }template <class IF>inlineconst char*sc_port_b<IF>::if_typename() const{    return typeid( IF ).name();}template <class IF>inlineintsc_port_b<IF>::interface_count(){	return m_interface_vec.size();}template <class IF>voidsc_port_b<IF>::make_sensitive( sc_thread_handle handle_p,                  sc_event_finder* event_finder_ ) const{    if ( m_bind_info == 0 )    {        int if_n = m_interface_vec.size();        for ( int if_i = 0; if_i < if_n; if_i++ )	{	    IF* iface_p = m_interface_vec[if_i];	    assert( iface_p != 0 );	    add_static_event( handle_p, iface_p->default_event() );	}    }    else    {        sc_port_base::make_sensitive( handle_p, event_finder_ );    }}template <class IF>voidsc_port_b<IF>::make_sensitive( sc_method_handle handle_p,                  sc_event_finder* event_finder_ ) const{    if ( m_bind_info == 0 )    {        int if_n = m_interface_vec.size();        for ( int if_i = 0; if_i < if_n; if_i++ )	{	    IF* iface_p = m_interface_vec[if_i];	    assert( iface_p != 0 );	    add_static_event( handle_p, iface_p->default_event() );	}    }    else    {        sc_port_base::make_sensitive( handle_p, event_finder_ );    }}// ----------------------------------------------------------------------------//  CLASS : sc_port////  Generic port class and base class for other port classes.//  N is the maximum number of channels (with interface IF) that can be bound//  to this port. N <= 0 means no maximum.// ----------------------------------------------------------------------------} // namespace sc_core#endif// Taf!

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -