sc_signed.h

来自「system C源码 一种替代verilog的语言」· C头文件 代码 · 共 1,617 行 · 第 1/5 页

H
1,617
字号
    int        m_right;  // Right-most bit in this part selection.private:    const sc_signed_subref_r& operator = ( const sc_signed_subref_r& );};inline::std::ostream&operator << ( ::std::ostream&, const sc_signed_subref_r& );// ----------------------------------------------------------------------------//  CLASS : sc_signed_subref////  Proxy class for sc_signed part selection (r-value and l-value).// ----------------------------------------------------------------------------class sc_signed_subref    : public sc_signed_subref_r{    friend class sc_signed;    friend class sc_core::sc_vpool<sc_signed_subref>;    // constructor    sc_signed_subref()        {}public:    // copy constructor    sc_signed_subref( const sc_signed_subref& a )	: sc_signed_subref_r( a )	{}    // assignment operators    const sc_signed_subref& operator = ( const sc_signed_subref_r& a );    const sc_signed_subref& operator = ( const sc_signed_subref& a );    const sc_signed_subref& operator = ( const sc_signed& a );    const sc_signed_subref& operator = ( const sc_unsigned_subref_r& a );    const sc_signed_subref& operator = ( const sc_unsigned& a );    template< class T >    const sc_signed_subref& operator = ( const sc_generic_base<T>& a )    {        sc_unsigned temp( length() );	a->to_sc_unsigned(temp);	return operator = (temp);    }    const sc_signed_subref& operator = ( const char* a );    const sc_signed_subref& operator = ( unsigned long a );    const sc_signed_subref& operator = ( long a );    const sc_signed_subref& operator = ( unsigned int a )	{ return operator = ( (unsigned long) a ); }    const sc_signed_subref& operator = ( int a )	{ return operator = ( (long) a ); }    const sc_signed_subref& operator = ( uint64 a );    const sc_signed_subref& operator = ( int64 a );    const sc_signed_subref& operator = ( double a );    const sc_signed_subref& operator = ( const sc_int_base& a );    const sc_signed_subref& operator = ( const sc_uint_base& a );    // concatenation methods    virtual void concat_set(int64 src, int low_i);    virtual void concat_set(const sc_signed& src, int low_i);    virtual void concat_set(const sc_unsigned& src, int low_i);    virtual void concat_set(uint64 src, int low_i);    // other methods    void scan( ::std::istream& is = ::std::cin );protected:    static sc_core::sc_vpool<sc_signed_subref> m_pool;};inline::std::istream&operator >> ( ::std::istream&, sc_signed_subref& );// ----------------------------------------------------------------------------//  CLASS : sc_signed////  Arbitrary precision signed number.// ----------------------------------------------------------------------------class sc_signed : public sc_value_base{    friend class sc_concatref;    friend class sc_signed_bitref_r;    friend class sc_signed_bitref;    friend class sc_signed_subref_r;    friend class sc_signed_subref;    friend class sc_unsigned;    friend class sc_unsigned_subref;  // Needed for types using sc_signed.  typedef bool elemtype;public:    // constructors    explicit sc_signed( int nb = sc_length_param().len() );    sc_signed( const sc_signed&   v );    sc_signed( const sc_unsigned& v );    template<class T>    explicit sc_signed( const sc_generic_base<T>& v );    explicit sc_signed( const sc_bv_base& v );    explicit sc_signed( const sc_lv_base& v );    explicit sc_signed( const sc_int_subref_r& v );    explicit sc_signed( const sc_uint_subref_r& v );    explicit sc_signed( const sc_signed_subref_r& v );    explicit sc_signed( const sc_unsigned_subref_r& v );    // assignment operators    const sc_signed& operator = (const sc_signed&          v);    const sc_signed& operator = (const sc_signed_subref_r& a );    template< class T >    const sc_signed& operator = ( const sc_generic_base<T>& a )        { a->to_sc_signed(*this); return *this; }    const sc_signed& operator = (const sc_unsigned&        v);    const sc_signed& operator = (const sc_unsigned_subref_r& a );    const sc_signed& operator = (const char*               v);    const sc_signed& operator = (int64                     v);    const sc_signed& operator = (uint64                    v);    const sc_signed& operator = (long                      v);    const sc_signed& operator = (unsigned long             v);    const sc_signed& operator = (int                       v)	{ return operator=((long) v); }    const sc_signed& operator = (unsigned int              v)	{ return operator=((unsigned long) v); }    const sc_signed& operator = (double                    v);    const sc_signed& operator = (const sc_int_base&        v);    const sc_signed& operator = (const sc_uint_base&       v);    const sc_signed& operator = ( const sc_bv_base& );    const sc_signed& operator = ( const sc_lv_base& );#ifdef SC_INCLUDE_FX    const sc_signed& operator = ( const sc_fxval& );    const sc_signed& operator = ( const sc_fxval_fast& );    const sc_signed& operator = ( const sc_fxnum& );    const sc_signed& operator = ( const sc_fxnum_fast& );#endif    // destructor    virtual ~sc_signed()	{#ifndef SC_MAX_NBITS	    delete [] digit;#endif	}    // Concatenation support:    sc_digit* get_raw() const	{ return digit; }    virtual int concat_length(bool* xz_present_p) const	{ if ( xz_present_p ) *xz_present_p = false; return nbits; }    virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const;    virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const;    virtual uint64 concat_get_uint64() const;    virtual void concat_set(int64 src, int low_i);    virtual void concat_set(const sc_signed& src, int low_i);    virtual void concat_set(const sc_unsigned& src, int low_i);    virtual void concat_set(uint64 src, int low_i);    // Increment operators.    sc_signed& operator ++ ();    const sc_signed operator ++ (int);    // Decrement operators.    sc_signed& operator -- ();    const sc_signed operator -- (int);    // bit selection    inline void check_index( int i ) const        { if ( i < 0 || i >= nbits ) invalid_index(i); }    void invalid_index( int i ) const;    sc_signed_bitref& operator [] ( int i )        {            check_index(i);	    sc_signed_bitref* result_p =	        sc_signed_bitref::m_pool.allocate();	    result_p->initialize( this, i );	    return *result_p;	}    const sc_signed_bitref_r& operator [] ( int i ) const        {            check_index(i);	    sc_signed_bitref* result_p =	        sc_signed_bitref::m_pool.allocate();	    result_p->initialize( this, i );	    return *result_p;	}    sc_signed_bitref& bit( int i )        {            check_index(i);	    sc_signed_bitref* result_p =	        sc_signed_bitref::m_pool.allocate();	    result_p->initialize( this, i );	    return *result_p;	}    const sc_signed_bitref_r& bit( int i ) const        {            check_index(i);	    sc_signed_bitref* result_p =	        sc_signed_bitref::m_pool.allocate();	    result_p->initialize( this, i );	    return *result_p;	}    // part selection    // Subref operators. Help access the range of bits from the ith to    // jth. These indices have arbitrary precedence with respect to each    // other, i.e., we can have i <= j or i > j. Note the equivalence    // between range(i, j) and operator(i, j). Also note that    // operator(i, i) returns a signed number that corresponds to the    // bit operator[i], so these two forms are not the same.    inline void check_range( int l, int r ) const        {            if ( l < r )            {                if ( l < 0 || r >= nbits ) invalid_range(l,r);            }            else            {                if ( r < 0 || l >= nbits ) invalid_range(l,r);            }        }    void invalid_range( int l, int r ) const;    sc_signed_subref& range( int i, int j )        {	    check_range( i, j );	    sc_signed_subref* result_p =	        sc_signed_subref::m_pool.allocate();	    result_p->initialize( this, i, j );	    return *result_p;	}    const sc_signed_subref_r& range( int i, int j ) const        {	    check_range( i, j );	    sc_signed_subref* result_p =	        sc_signed_subref::m_pool.allocate();	    result_p->initialize( this, i, j );	    return *result_p;	}    sc_signed_subref& operator () ( int i, int j )        {	    check_range( i, j );	    sc_signed_subref* result_p =	        sc_signed_subref::m_pool.allocate();	    result_p->initialize( this, i, j );	    return *result_p;	}    const sc_signed_subref_r& operator () ( int i, int j ) const        {	    check_range( i, j );	    sc_signed_subref* result_p =	        sc_signed_subref::m_pool.allocate();	    result_p->initialize( this, i, j );	    return *result_p;	}    // explicit conversions    int           to_int() const;    unsigned int  to_uint() const;    long          to_long() const;    unsigned long to_ulong() const;    int64         to_int64() const;    uint64        to_uint64() const;    double        to_double() const;#ifdef SC_DT_DEPRECATED    int to_signed() const	{ return to_int(); }    unsigned int to_unsigned() const	{ return to_uint(); }#endif

⌨️ 快捷键说明

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