sc_signal_ports.h

来自「基于4个mips核的noc设计」· C头文件 代码 · 共 1,744 行 · 第 1/3 页

H
1,744
字号
    virtual ~sc_inout();    // interface access shortcut methods    // get the default event    const sc_event& default_event() const	{ return (*this)->default_event(); }    // get the value changed event    const sc_event& value_changed_event() const	{ return (*this)->value_changed_event(); }    // get the positive edge event    const sc_event& posedge_event() const	{ return (*this)->posedge_event(); }    // get the negative edge event    const sc_event& negedge_event() const	{ return (*this)->negedge_event(); }    // read the current value    const data_type& read() const	{ return (*this)->read(); }    operator const data_type& () const	{ return (*this)->read(); }    // use for positive edge sensitivity    sc_event_finder& pos() const    {	return *new sc_event_finder_t<in_if_type>(	    *this, &in_if_type::posedge_event );    }    // use for negative edge sensitivity    sc_event_finder& neg() const    {	return *new sc_event_finder_t<in_if_type>(	    *this, &in_if_type::negedge_event );    }    // was there a value changed event?    bool event() const	{ return (*this)->event(); }    // was there a positive edge event?    bool posedge() const        { return (*this)->posedge(); }    // was there a negative edge event?    bool negedge() const        { return (*this)->negedge(); }    // delayed evaluation    const sc_signal_bool_deval& delayed() const;    // write the new value    this_type& write( const data_type& value_ )	{ (*this)->write( value_ ); return *this; }    this_type& operator = ( const data_type& value_ )	{ (*this)->write( value_ ); return *this; }    this_type& operator = ( const in_if_type& interface_ )	{ (*this)->write( interface_.read() ); return *this; }    this_type& operator = ( const in_port_type& port_ )	{ (*this)->write( port_->read() ); return *this; }    this_type& operator = ( const inout_port_type& port_ )	{ (*this)->write( port_->read() ); return *this; }    this_type& operator = ( const this_type& port_ )	{ (*this)->write( port_->read() ); return *this; }    // set initial value (can also be called when port is not bound yet)    void initialize( const data_type& value_ );    void initialize( const in_if_type& interface_ )	{ initialize( interface_.read() ); }    // called when elaboration is done    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */    virtual void end_of_elaboration();    // (other) event finder method(s)    sc_event_finder& value_changed() const    {	return *new sc_event_finder_t<in_if_type>(	    *this, &in_if_type::value_changed_event );    }    static const char* const kind_string;    virtual const char* kind() const        { return kind_string; }protected:    data_type* m_init_val;public:    // called by sc_trace    void add_trace( sc_trace_file*, const sc_string& ) const;protected:    void remove_traces() const;    mutable sc_trace_params_vec* m_traces;private:    // disabled    sc_inout( const this_type& );#ifdef __GNUC__    // Needed to circumvent a problem in the g++-2.95.2 compiler:    // This unused variable forces the compiler to instantiate    // an object of T template so an implicit conversion from    // read() to a C++ intrinsic data type will work.    static data_type dummy;#endif};// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII// delayed evaluationinlineconst sc_signal_bool_deval&sc_inout<bool>::delayed() const{    const in_if_type* iface = DCAST<const in_if_type*>( get_interface() );    if( iface != 0 ) {	return RCAST<const sc_signal_bool_deval&>( *iface );    } else {	// the tricky part	const sc_port_base* pb = this;	return RCAST<const sc_signal_bool_deval&>( *pb );    }}// ----------------------------------------------------------------------------//  CLASS : sc_inout<sc_logic>////  Specialization of sc_inout<T> for type sc_logic.// ----------------------------------------------------------------------------template <>class sc_inout<sc_logic>: public sc_port<sc_signal_inout_if<sc_logic>,1>{public:    // typedefs    typedef sc_logic                      data_type;    typedef sc_signal_inout_if<data_type> if_type;    typedef sc_port<if_type,1>            base_type;    typedef sc_inout<data_type>           this_type;    typedef sc_signal_in_if<data_type>    in_if_type;    typedef sc_port<in_if_type,1>         in_port_type;    typedef if_type                       inout_if_type;    typedef base_type                     inout_port_type;public:    // constructors    sc_inout()	: base_type(), m_init_val( 0 ), m_traces( 0 )	{}    explicit sc_inout( const char* name_ )	: base_type( name_ ), m_init_val( 0 ), m_traces( 0 )	{}    explicit sc_inout( inout_if_type& interface_ )	: base_type( interface_ ), m_init_val( 0 ), m_traces( 0 )	{}    sc_inout( const char* name_, inout_if_type& interface_ )	: base_type( name_, interface_ ), m_init_val( 0 ), m_traces( 0 )	{}    explicit sc_inout( inout_port_type& parent_ )	: base_type( parent_ ), m_init_val( 0 ), m_traces( 0 )	{}    sc_inout( const char* name_, inout_port_type& parent_ )	: base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 )	{}    sc_inout( this_type& parent_ )	: base_type( parent_ ), m_init_val( 0 ), m_traces( 0 )	{}    sc_inout( const char* name_, this_type& parent_ )	: base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 )	{}    // destructor    virtual ~sc_inout();    // interface access shortcut methods    // get the default event    const sc_event& default_event() const	{ return (*this)->default_event(); }    // get the value changed event    const sc_event& value_changed_event() const	{ return (*this)->value_changed_event(); }    // get the positive edge event    const sc_event& posedge_event() const	{ return (*this)->posedge_event(); }    // get the negative edge event    const sc_event& negedge_event() const	{ return (*this)->negedge_event(); }    // read the current value    const data_type& read() const	{ return (*this)->read(); }    operator const data_type& () const	{ return (*this)->read(); }    // use for positive edge sensitivity    sc_event_finder& pos() const    {	return *new sc_event_finder_t<in_if_type>(	    *this, &in_if_type::posedge_event );    }    // use for negative edge sensitivity    sc_event_finder& neg() const    {	return *new sc_event_finder_t<in_if_type>(	    *this, &in_if_type::negedge_event );    }    // was there a value changed event?    bool event() const	{ return (*this)->event(); }    // was there a positive edge event?    bool posedge() const        { return (*this)->posedge(); }    // was there a negative edge event?    bool negedge() const        { return (*this)->negedge(); }    // delayed evaluation    const sc_signal_logic_deval& delayed() const;    // write the new value    this_type& write( const data_type& value_ )	{ (*this)->write( value_ ); return *this; }    this_type& operator = ( const data_type& value_ )	{ (*this)->write( value_ ); return *this; }    this_type& operator = ( const in_if_type& interface_ )	{ (*this)->write( interface_.read() ); return *this; }    this_type& operator = ( const in_port_type& port_ )	{ (*this)->write( port_->read() ); return *this; }    this_type& operator = ( const inout_port_type& port_ )	{ (*this)->write( port_->read() ); return *this; }    this_type& operator = ( const this_type& port_ )	{ (*this)->write( port_->read() ); return *this; }    // set initial value (can also be called when port is not bound yet)    void initialize( const data_type& value_ );    void initialize( const in_if_type& interface_ )	{ initialize( interface_.read() ); }    // called when elaboration is done    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */    virtual void end_of_elaboration();    // (other) event finder method(s)    sc_event_finder& value_changed() const    {	return *new sc_event_finder_t<in_if_type>(	    *this, &in_if_type::value_changed_event );    }    static const char* const kind_string;    virtual const char* kind() const        { return kind_string; }protected:    data_type* m_init_val;public:    // called by sc_trace    void add_trace( sc_trace_file*, const sc_string& ) const;protected:    void remove_traces() const;    mutable sc_trace_params_vec* m_traces;private:    // disabled    sc_inout( const this_type& );#ifdef __GNUC__    // Needed to circumvent a problem in the g++-2.95.2 compiler:    // This unused variable forces the compiler to instantiate    // an object of T template so an implicit conversion from    // read() to a C++ intrinsic data type will work.    static data_type dummy;#endif};// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII// delayed evaluationinlineconst sc_signal_logic_deval&sc_inout<sc_logic>::delayed() const{    const in_if_type* iface = DCAST<const in_if_type*>( get_interface() );    if( iface != 0 ) {	return RCAST<const sc_signal_logic_deval&>( *iface );    } else {	// the tricky part	const sc_port_base* pb = this;	return RCAST<const sc_signal_logic_deval&>( *pb );    }}// ----------------------------------------------------------------------------//  CLASS : sc_out<T>////  The sc_signal<T> output port class.// ----------------------------------------------------------------------------// sc_out can also read from its port, hence no difference with sc_inout.// For debugging reasons, a class is provided instead of a define.template <class T>class sc_out: public sc_inout<T>{public:    // typedefs    typedef T                                   data_type;    typedef sc_out<data_type>                   this_type;    typedef sc_inout<data_type>                 base_type;    typedef typename base_type::in_if_type      in_if_type;    typedef typename base_type::in_port_type    in_port_type;    typedef typename base_type::inout_if_type   inout_if_type;    typedef typename base_type::inout_port_type inout_port_type;public:    // constructors    sc_out()	: base_type()	{}    explicit sc_out( const char* name_ )	: base_type( name_ )	{}    explicit sc_out( inout_if_type& interface_ )	: base_type( interface_ )	{}    sc_out( const char* name_, inout_if_type& interface_ )	: base_type( name_, interface_ )	{}    explicit sc_out( inout_port_type& parent_ )	: base_type( parent_ )	{}    sc_out( const char* name_, inout_port_type& parent_ )	: base_type( name_, parent_ )	{}    sc_out( this_type& parent_ )	: base_type( parent_ )	{}    sc_out( const char* name_, this_type& parent_ )	: base_type( name_, parent_ )	{}    // destructor (does nothing)    virtual ~sc_out()	{}    // write the new value    this_type& operator = ( const data_type& value_ )	{ (*this)->write( value_ ); return *this; }    this_type& operator = ( const in_if_type& interface_ )	{ (*this)->write( interface_.read() ); return *this; }    this_type& operator = ( const in_port_type& port_ )	{ (*this)->write( port_->read() ); return *this; }    this_type& operator = ( const inout_port_type& port_ )	{ (*this)->write( port_->read() ); return *this; }    this_type& operator = ( const this_type& port_ )	{ (*this)->write( port_->read() ); return *this; }    static const char* const kind_string;    virtual const char* kind() const        { return kind_string; }private:    // disabled    sc_out( const this_type& );};// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIItemplate <class T>const char* const sc_out<T>::kind_string = "sc_out";// ----------------------------------------------------------------------------//  FUNCTION : sc_trace// ----------------------------------------------------------------------------template <class T>inlinevoidsc_trace( sc_trace_file* tf, const sc_in<T>& port, const sc_string& name ){    port.add_trace( tf, name );}template <>inlinevoidsc_trace<bool>( sc_trace_file* tf,                const sc_in<bool>& port,                const sc_string& name ){    port.add_trace( tf, name );}template <>inlinevoidsc_trace<sc_logic>( sc_trace_file* tf,                    const sc_in<sc_logic>& port,                    const sc_string& name ){    port.add_trace( tf, name );}template <class T>inlinevoidsc_trace( sc_trace_file* tf, const sc_inout<T>& port, const sc_string& name ){    port.add_trace( tf, name );}template <>inlinevoidsc_trace<bool>( sc_trace_file* tf,                const sc_inout<bool>& port,                const sc_string& name ){    port.add_trace( tf, name );}template <>inlinevoidsc_trace<sc_logic>( sc_trace_file* tf,                    const sc_inout<sc_logic>& port,                    const sc_string& name ){    port.add_trace( tf, name );}#endif// Taf!

⌨️ 快捷键说明

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