📄 scx_signal_unsigned.h
字号:
// 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_biguint<W>& read() const { return (*this)->read(); } operator const sc_dt::sc_biguint<W>& () const { return (*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 { 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_init_val_p != 0 ) { (*this)->write( *m_init_val_p ); delete m_init_val_p; m_init_val_p = 0; } 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_inout"; } // value initialization inline void initialize( const sc_dt::sc_biguint<W>& value_ ) { inout_if_type* iface = DCAST<inout_if_type*>( this->get_interface() ); if( iface != 0 ) { iface->write( value_ ); } else { if( m_init_val_p == 0 ) { m_init_val_p = new sc_dt::sc_biguint<W>; } *m_init_val_p = value_; } } // 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); } virtual inline void concat_set(sc_dt::int64 src, int low_i) { *this = (src >> ((low_i < 64) ? low_i : 63)); }#if 0 // #### virtual inline void concat_set(const sc_dt::sc_lv_base& src, int low_i) { *this = src >> low_i; }#endif // 0 #### virtual inline void concat_set(const sc_dt::sc_signed& src, int low_i) { *this = (src >> low_i); } virtual inline void concat_set(const sc_dt::sc_unsigned& src, int low_i) { *this = (src >> low_i); } virtual inline void concat_set(sc_dt::uint64 src, int low_i) { *this = (low_i < 64 ) ? src >> low_i : (sc_dt::uint64)0; } // assignment operators: public: inline void operator = ( const this_type& new_val ) { (*this)->write( (const sc_dt::sc_unsigned&)new_val ); } inline void operator = ( const char* new_val ) { sc_dt::sc_unsigned aa(W); aa = new_val; (*this)->write( aa ); } inline void operator = ( sc_dt::uint64 new_val ) { (*this)->write(new_val); } inline void operator = ( sc_dt::int64 new_val ) { (*this)->write((sc_dt::int64)new_val); } inline void operator = ( int new_val ) { (*this)->write((sc_dt::int64)new_val); } inline void operator = ( long new_val ) { (*this)->write((sc_dt::int64)new_val); } inline void operator = ( short new_val ) { (*this)->write((sc_dt::uint64)new_val); } inline void operator = ( unsigned int new_val ) { (*this)->write((sc_dt::uint64)new_val); } inline void operator = ( unsigned long new_val ) { (*this)->write((sc_dt::uint64)new_val); } inline void operator = ( unsigned short new_val ) { (*this)->write((sc_dt::uint64)new_val); } template<typename T> inline void operator = ( const sc_dt::sc_generic_base<T>& new_val ) { sc_dt::sc_unsigned temp(W); new_val->to_sc_unsigned(temp); (*this)->write(temp); } inline void operator = ( const sc_dt::sc_signed& new_val ) { (*this)->write(new_val); } inline void operator = ( const sc_dt::sc_unsigned& new_val ) { (*this)->write(new_val); } inline void operator = ( const sc_dt::sc_bv_base& new_val ) { (*this)->write((sc_dt::sc_biguint<W>)new_val); } inline void operator = ( const sc_dt::sc_lv_base& new_val ) { (*this)->write((sc_dt::sc_biguint<W>)new_val); } inline void write( const sc_in<sc_dt::sc_biguint<W> >& new_val ) { (*this)->write( new_val.read() ); } inline void write( const sc_inout<sc_dt::sc_biguint<W> >& new_val ) { (*this)->write( new_val.read() ); } inline void write( const sc_dt::sc_biguint<W>& new_val ) { (*this)->write( new_val ); } 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; } } sc_dt::sc_biguint<W>* m_init_val_p; mutable sc_trace_params_vec* m_traces; private: // disabled sc_inout( const sc_inout<sc_dt::sc_biguint<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_inout<sc_dt::sc_biguint<W> >& a ){ a.read().print( os ); return os;}//==============================================================================// CLASS sc_out<sc_dt::sc_biguint<W> >//// This class implements an output port whose target acts like an // sc_dt::sc_biguint<W> data value. This class is a derivation of sc_inout, since// output ports are really no different from input/output ports.//==============================================================================SC_TEMPLATEclass sc_out<sc_dt::sc_biguint<W> > : public sc_inout<sc_dt::sc_biguint<W> >{ public: // typedefs typedef sc_dt::sc_biguint<W> data_type; typedef sc_out<data_type> this_type; typedef sc_inout<data_type> base_type; typedef typename base_type::inout_if_type inout_if_type; typedef typename base_type::inout_port_type inout_port_type; // 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 inline ~sc_out() {} // assignment operators: public: inline void operator = ( const this_type& new_val ) { (*this)->write( (const sc_dt::sc_unsigned&)new_val ); } inline void operator = ( const char* new_val ) { sc_dt::sc_unsigned aa(W); aa = new_val; (*this)->write( aa ); } inline void operator = ( sc_dt::uint64 new_val ) { (*this)->write(new_val); } inline void operator = ( sc_dt::int64 new_val ) { (*this)->write((sc_dt::uint64)new_val); } inline void operator = ( int new_val ) { (*this)->write((sc_dt::uint64)new_val); } inline void operator = ( long new_val ) { (*this)->write((sc_dt::uint64)new_val); } inline void operator = ( short new_val ) { (*this)->write((sc_dt::uint64)new_val); } inline void operator = ( unsigned int new_val ) { (*this)->write((sc_dt::uint64)new_val); } inline void operator = ( unsigned long new_val ) { (*this)->write((sc_dt::uint64)new_val); } inline void operator = ( unsigned short new_val ) { (*this)->write((sc_dt::uint64)new_val); } template<typename T> inline void operator = ( const sc_dt::sc_generic_base<T>& new_val ) { sc_dt::sc_unsigned temp(W); new_val->to_sc_unsigned(temp); (*this)->write(temp); } inline void operator = ( const sc_dt::sc_signed& new_val ) { (*this)->write(new_val); } inline void operator = ( const sc_dt::sc_unsigned& new_val ) { (*this)->write(new_val); } inline void operator = ( const sc_dt::sc_bv_base& new_val ) { (*this)->write((sc_dt::sc_biguint<W>)new_val); } inline void operator = ( const sc_dt::sc_lv_base& new_val ) { (*this)->write((sc_dt::sc_biguint<W>)new_val); } private: // disabled sc_out( const this_type& );};//------------------------------------------------------------------------------//"sc_unsigned_sigref::initialize"//// This method initializes an object instance from the supplied arguments.// if_p -> target of this selection.// left_ = left-most bit in selection.// right_ = right-most bit in selection.//------------------------------------------------------------------------------inline void sc_unsigned_sigref::initialize( sc_unsigned_part_if* if_p, int left_, int right_ ){ m_if_p = if_p; m_left = left_; m_right = right_; m_obj_p = if_p->part_read_target();}//------------------------------------------------------------------------------//"sc_unsigned_sigref::operator ="//// These operators assign a value to the bits associated with this object// instance within this object instance's target signal.//------------------------------------------------------------------------------inline void sc_unsigned_sigref::operator = ( sc_dt::uint64 v ){ m_if_p->write_part( v, m_left, m_right );}inline void sc_unsigned_sigref::operator = ( const char* v ){ sc_dt::sc_unsigned tmp(length()); tmp = v; *this = tmp;}inline void sc_unsigned_sigref:: operator = ( sc_dt::int64 v ){ *this = (sc_dt::uint64)v; }inline void sc_unsigned_sigref:: operator = ( int v ){ *this = (sc_dt::uint64)v; }inline void sc_unsigned_sigref:: operator = ( long v ){ *this = (sc_dt::uint64)v; }inline void sc_unsigned_sigref:: operator = ( unsigned int v ){ *this = (sc_dt::uint64)v; }inline void sc_unsigned_sigref:: operator = ( unsigned long v ){ *this = (sc_dt::uint64)v; }void sc_unsigned_sigref::operator = ( const sc_unsigned_sigref& v ){ *this = (sc_dt::sc_unsigned)v;}inline void sc_unsigned_sigref:: operator = ( const sc_dt::sc_signed& v ){ m_if_p->write_part( v, m_left, m_right );}inline void sc_unsigned_sigref:: operator = ( const sc_dt::sc_unsigned& v ){ m_if_p->write_part( v, m_left, m_right );}template<typename T>inline void sc_unsigned_sigref:: operator = ( const sc_dt::sc_generic_base<T>& v ){ sc_dt::sc_unsigned temp(m_left-m_right+1); v->to_sc_unsigned(temp); m_if_p->write_part( temp, m_left, m_right );}#undef SC_TEMPLATE} // namespace sc_core#endif // !defined(SC_SIGNAL_UNSIGNED_H)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -