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

📄 sc_unsigned.h

📁 system C源码 一种替代verilog的语言
💻 H
📖 第 1 页 / 共 5 页
字号:
    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_unsigned_subref> m_pool;};inline::std::istream&operator >> ( ::std::istream&, sc_unsigned_subref& );// ----------------------------------------------------------------------------//  CLASS : sc_unsigned////  Arbitrary precision unsigned number.// ----------------------------------------------------------------------------class sc_unsigned : public sc_value_base{    friend class sc_concatref;    friend class sc_unsigned_bitref_r;    friend class sc_unsigned_bitref;    friend class sc_unsigned_subref_r;    friend class sc_unsigned_subref;    friend class sc_signed;    friend class sc_signed_subref;    friend class sc_signed_subref_r;  // Needed for types using sc_unsigned.  typedef bool elemtype;public:    // constructors    explicit sc_unsigned( int nb = sc_length_param().len() );    sc_unsigned( const sc_unsigned& v );    sc_unsigned( const sc_signed&   v );	template<class T>    explicit sc_unsigned( const sc_generic_base<T>& v );    explicit sc_unsigned( const sc_bv_base& v );    explicit sc_unsigned( const sc_lv_base& v );    explicit sc_unsigned( const sc_int_subref_r& v );    explicit sc_unsigned( const sc_uint_subref_r& v );    explicit sc_unsigned( const sc_signed_subref_r& v );    explicit sc_unsigned( const sc_unsigned_subref_r& v );    // assignment operators    const sc_unsigned& operator = (const sc_unsigned&        v);    const sc_unsigned& operator = (const sc_unsigned_subref_r& a );    template<class T>    const sc_unsigned& operator = ( const sc_generic_base<T>& a )        { a->to_sc_unsigned(*this); return *this; }    const sc_unsigned& operator = (const sc_signed&          v);    const sc_unsigned& operator = (const sc_signed_subref_r& a );    const sc_unsigned& operator = ( const char*               v);    const sc_unsigned& operator = ( int64                     v);    const sc_unsigned& operator = ( uint64                    v);    const sc_unsigned& operator = ( long                      v);    const sc_unsigned& operator = ( unsigned long             v);    const sc_unsigned& operator = ( int                       v)	{ return operator=((long) v); }    const sc_unsigned& operator = ( unsigned int              v)	{ return operator=((unsigned long) v); }    const sc_unsigned& operator = ( double                    v);    const sc_unsigned& operator = ( const sc_int_base&        v);    const sc_unsigned& operator = ( const sc_uint_base&       v);    const sc_unsigned& operator = ( const sc_bv_base& );    const sc_unsigned& operator = ( const sc_lv_base& );#ifdef SC_INCLUDE_FX    const sc_unsigned& operator = ( const sc_fxval& );    const sc_unsigned& operator = ( const sc_fxval_fast& );    const sc_unsigned& operator = ( const sc_fxnum& );    const sc_unsigned& operator = ( const sc_fxnum_fast& );#endif    // destructor    virtual ~sc_unsigned()	{#           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-1; }    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_unsigned& operator ++ ();    const sc_unsigned operator ++ (int);    // Decrement operators.    sc_unsigned& operator -- ();    const sc_unsigned operator -- (int);    // bit selection    inline void check_index( int i ) const        { if ( (i < 0) || (i >= nbits-1) ) invalid_index(i); }    void invalid_index( int i ) const;    sc_unsigned_bitref& operator [] ( int i )        {            check_index(i);            sc_unsigned_bitref* result_p =	    	sc_unsigned_bitref::m_pool.allocate();            result_p->initialize( this, i );            return *result_p;        }    const sc_unsigned_bitref_r& operator [] ( int i ) const        {            check_index(i);            sc_unsigned_bitref* result_p =	        sc_unsigned_bitref::m_pool.allocate();            result_p->initialize( this, i );            return *result_p;        }    sc_unsigned_bitref& bit( int i )        {            check_index(i);            sc_unsigned_bitref* result_p =	        sc_unsigned_bitref::m_pool.allocate();            result_p->initialize( this, i );            return *result_p;        }    const sc_unsigned_bitref_r& bit( int i ) const        {            check_index(i);            sc_unsigned_bitref* result_p =	        sc_unsigned_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 an unsigned 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-1) ) invalid_range(l,r);            }            else            {                if ( (r < 0) || (l >= nbits-1) ) invalid_range(l,r);            }        }    void invalid_range( int l, int r ) const;    sc_unsigned_subref& range( int i, int j )        {            check_range(i,j);            sc_unsigned_subref* result_p =	        sc_unsigned_subref::m_pool.allocate();            result_p->initialize( this, i, j );            return *result_p;        }    const sc_unsigned_subref_r& range( int i, int j ) const        {            check_range(i,j);            sc_unsigned_subref* result_p =	        sc_unsigned_subref::m_pool.allocate();            result_p->initialize( this, i, j );            return *result_p;        }    sc_unsigned_subref& operator () ( int i, int j )        {            check_range(i,j);            sc_unsigned_subref* result_p =	        sc_unsigned_subref::m_pool.allocate();            result_p->initialize( this, i, j );            return *result_p;        }    const sc_unsigned_subref_r& operator () ( int i, int j ) const        {            check_range(i,j);            sc_unsigned_subref* result_p =	        sc_unsigned_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    // explicit conversion to character string    const std::string to_string( sc_numrep numrep = SC_DEC ) const;    const std::string to_string( sc_numrep numrep, bool w_prefix ) const;    // Print functions. dump prints the internals of the class.    void print( ::std::ostream& os = ::std::cout ) const	{ os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }    void scan( ::std::istream& is = ::std::cin );    void dump( ::std::ostream& os = ::std::cout ) const;  // Functions to find various properties.  int  length() const { return nbits - 1; }  // Bit width.  bool iszero() const;                       // Is the number zero?  bool sign() const { return 0; }            // Sign.    // reduce methods    bool and_reduce() const;    bool nand_reduce() const        { return ( ! and_reduce() ); }    bool or_reduce() const;    bool nor_reduce() const        { return ( ! or_reduce() ); }    bool xor_reduce() const;    bool xnor_reduce() const        { return ( ! xor_reduce() ); }  // Functions to access individual bits.  bool test(int i) const;      // Is the ith bit 0 or 1?  void set(int i);             // Set the ith bit to 1.  void clear(int i);           // Set the ith bit to 0.  void set(int i, bool v)      // Set the ith bit to v.    { if (v) set(i); else clear(i);  }  void invert(int i)           // Negate the ith bit.    { if (test(i)) clear(i); else set(i);  }  // Make the number equal to its mirror image.  void reverse();  // Get/set a packed bit representation of the number.  void get_packed_rep(sc_digit *buf) const;  void set_packed_rep(sc_digit *buf);  /*    The comparison of the old and new semantics are as follows:    Let s = sc_signed,        u = sc_unsigned,        un = { uint64, unsigned long, unsigned int },        sn = { int64, long, int, char* }, and        OP = { +, -, *, /, % }.    Old semantics:                     New semantics:      u OP u -> u                        u OP u -> u

⌨️ 快捷键说明

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