📄 scx_signal_int.h
字号:
return 2; } // constructors public: sc_in() : base_type(), m_traces( 0 ) {} explicit sc_in( const char* name_ ) : base_type( name_ ), m_traces( 0 ) {} explicit sc_in( const in_if_type& interface_ ) : base_type( CCAST<in_if_type&>( interface_ ) ), m_traces( 0 ) {} sc_in( const char* name_, const in_if_type& interface_ ) : base_type( name_, CCAST<in_if_type&>( interface_ ) ), m_traces( 0 ) {} explicit sc_in( in_port_type& parent_ ) : base_type( parent_ ), m_traces( 0 ) {} sc_in( const char* name_, in_port_type& parent_ ) : base_type( name_, parent_ ), m_traces( 0 ) {} explicit sc_in( inout_port_type& parent_ ) : base_type(), m_traces( 0 ) { sc_port_base::bind( parent_ ); } sc_in( const char* name_, inout_port_type& parent_ ) : base_type( name_ ), m_traces( 0 ) { sc_port_base::bind( parent_ ); } sc_in( this_type& parent_ ) : base_type( parent_ ), m_traces( 0 ) {} sc_in( const char* name_, this_type& parent_ ) : base_type( name_, parent_ ), m_traces( 0 ) {} // destructor virtual inline ~sc_in() { remove_traces(); } // bit and part selection sc_dt::sc_int_bitref_r operator [] ( int i ) const { return (*this)->read()[i]; } sc_dt::sc_int_bitref_r bit( int i ) const { return (*this)->read()[i]; } sc_dt::sc_int_subref_r operator () ( int left, int right ) const { return (*this)->read()(left,right); } sc_dt::sc_int_subref_r range( int left, int right ) const { return (*this)->read()(left,right); } // interface access shortcut methods // get the default event const sc_event& default_event() const { return (*this)->value_changed_event(); } // get the value changed event const sc_event& value_changed_event() const { return (*this)->value_changed_event(); } // read the current value const sc_dt::sc_int<W>& read() const { return (*this)->read(); } operator sc_dt::int64 () const { return (sc_dt::int64)(*this)->read(); } // was there a value changed event? bool event() const { return (*this)->event(); } // (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 ); } // reduction methods: inline bool and_reduce() const { return (*this)->read().and_reduce(); } inline bool nand_reduce() const { return (*this)->read().nand_reduce(); } inline bool nor_reduce() const { return (*this)->read().nor_reduce(); } inline bool or_reduce() const { return (*this)->read().or_reduce(); } inline bool xnor_reduce() const { return (*this)->read().xnor_reduce(); } inline bool xor_reduce() const { return (*this)->read().xor_reduce(); } // called when elaboration is done /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */ /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */ virtual inline void end_of_elaboration() { if( m_traces != 0 ) { for( unsigned int i = 0; i < m_traces->size(); ++ i ) { sc_trace_params* p = (*m_traces)[i]; sc_trace( p->tf, read(), p->name ); } remove_traces(); } } virtual inline const char* kind() const { return "sc_in"; } // called by sc_trace void add_trace( sc_trace_file* tf_, const std::string& name_ ) const { if( tf_ != 0 ) { if( m_traces == 0 ) { m_traces = new sc_trace_params_vec; } m_traces->push_back( new sc_trace_params( tf_, name_ ) ); } } // concatenation methods virtual inline int concat_length(bool* xz_present_p) const { return (*this)->read().concat_length( xz_present_p ); } virtual inline sc_dt::uint64 concat_get_uint64() const { return (*this)->read().concat_get_uint64(); } virtual inline bool concat_get_ctrl( sc_dt::sc_digit* dst_p, int low_i ) const { return (*this)->read().concat_get_ctrl(dst_p, low_i); } virtual inline bool concat_get_data( sc_dt::sc_digit* dst_p, int low_i ) const { return (*this)->read().concat_get_data(dst_p, low_i); } protected: void remove_traces() const { if( m_traces != 0 ) { for( unsigned int i = m_traces->size() - 1; i >= 0; -- i ) { delete (*m_traces)[i]; } delete m_traces; m_traces = 0; } } mutable sc_trace_params_vec* m_traces; private: // disabled sc_in( const sc_in<sc_dt::sc_int<W> >& ); sc_in<sc_dt::sc_int<W> >& operator = ( const sc_in<sc_dt::sc_int<W> >& );#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};SC_TEMPLATEinline std::ostream& operator << (std::ostream& os, const sc_in<sc_dt::sc_int<W> >& a){ a.read().print( os ); return os;}//==============================================================================// CLASS sc_inout<sc_dt::sc_int<W> >//// This class implements an input/output port whose target acts like an // sc_dt::sc_int<W> data value. It is derived from the sc_int_in. This class is a // specialization of the generic sc_inout class to implement tailored support // for the sc_dt::sc_int<W> class.//==============================================================================SC_TEMPLATEclass sc_inout<sc_dt::sc_int<W> > : public sc_port<sc_signal_inout_if<sc_dt::sc_int<W> >, 1>, public sc_dt::sc_value_base{ public: // typedefs typedef sc_dt::sc_int<W> data_type; typedef sc_signal_inout_if<sc_dt::sc_int<W> > if_type; typedef sc_port<if_type,1> base_type; typedef sc_inout<sc_dt::sc_int<W> > this_type; typedef if_type inout_if_type; typedef base_type inout_port_type; public: // bind methods and operators: void bind( const inout_if_type& interface_ ) { sc_port_base::bind( CCAST<inout_if_type&>( interface_) ); } void operator () ( const inout_if_type& interface_ ) { sc_port_base::bind( CCAST<inout_if_type&>( interface_) ); } void bind( inout_port_type& parent_ ) { sc_port_base::bind(parent_); } void operator () ( inout_port_type& parent_ ) { sc_port_base::bind(parent_); } protected: // called by pbind (for internal use only) virtual inline int vbind( sc_interface& interface_ ) { return sc_port_b<if_type>::vbind( interface_ ); } virtual inline int vbind( sc_port_base& parent_ ) { inout_port_type* inout_parent = DCAST<inout_port_type*>( &parent_ ); if( inout_parent != 0 ) { sc_port_base::bind( *inout_parent ); return 0; } // type mismatch return 2; } // constructors public: sc_inout() : base_type(), m_init_val_p(0), m_traces( 0 ) {} explicit sc_inout( const char* name_ ) : base_type( name_ ), m_init_val_p(0), m_traces( 0 ) {} explicit sc_inout( inout_if_type& interface_ ) : base_type( interface_ ), m_init_val_p(0), m_traces( 0 ) {} sc_inout( const char* name_, inout_if_type& interface_ ) : base_type( name_, interface_ ), m_init_val_p(0), m_traces( 0 ) {} explicit sc_inout( inout_port_type& parent_ ) : base_type( parent_ ), m_init_val_p(0), m_traces( 0 ) {} sc_inout( const char* name_, inout_port_type& parent_ ) : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 ) {} sc_inout( this_type& parent_ ) : base_type( parent_ ), m_init_val_p(0), m_traces( 0 ) {} sc_inout( const char* name_, this_type& parent_ ) : base_type( name_, parent_ ), m_init_val_p(0), m_traces( 0 ) {} // destructor virtual inline ~sc_inout() { remove_traces(); } // bit and part selection sc_dt::sc_int_bitref_r operator [] ( int i ) const { return (*this)->read()[i]; } sc_dt::sc_int_bitref_r bit( int i ) const { return (*this)->read()[i]; } sc_int_sigref& operator [] ( int i ) { return (*this)->select_part(i,i); } sc_int_sigref& bit( int i ) { return (*this)->select_part(i,i); } sc_dt::sc_int_subref_r operator () ( int left, int right ) const { return (*this)->read()(left,right); } sc_dt::sc_int_subref_r range( int left, int right ) const { return (*this)->read()(left,right); } sc_int_sigref& operator () ( int left, int right ) { return (*this)->select_part(left,right); } sc_int_sigref& range( int left, int right ) { return (*this)->select_part(left,right); } // interface access shortcut methods // get the default event const sc_event& default_event() const { return (*this)->value_changed_event(); } // get the value changed event const sc_event& value_changed_event() const { return (*this)->value_changed_event(); } // read the current value const sc_dt::sc_int<W>& read() const { return (*this)->read(); } operator sc_dt::int64 () const { return (sc_dt::int64)(*this)->read(); } // was there a value changed event? bool event() const { return (*this)->event(); } // (other) event finder method(s) sc_event_finder& value_changed() const { return *new sc_event_finder_t<inout_if_type>( *this, &inout_if_type::value_changed_event ); } // reduction methods: inline bool and_reduce() const
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -