sc_signed.h

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

H
1,617
字号
  // Logical GREATER_THAN operators:  bool operator > (const sc_unsigned&  u, const sc_signed&    v);  bool operator > (const sc_signed&    u, const sc_unsigned&  v);  bool operator > (const sc_signed&    u, const sc_signed&    v);  bool operator > (const sc_signed&    u, int64               v);  bool operator > (const sc_signed&    u, uint64              v);  bool operator > (const sc_signed&    u, long                v);  bool operator > (const sc_signed&    u, unsigned long       v);  inline bool operator > (const sc_signed&    u, int                 v);  inline bool operator > (const sc_signed&    u, unsigned int        v);  bool operator > (int64               u, const sc_signed&    v);  bool operator > (uint64              u, const sc_signed&    v);  bool operator > (long                u, const sc_signed&    v);  bool operator > (unsigned long       u, const sc_signed&    v);  inline bool operator > (int                 u, const sc_signed&    v);  inline bool operator > (unsigned int        u, const sc_signed&    v);  bool operator > (const sc_signed&    u, const sc_int_base&  v);  bool operator > (const sc_signed&    u, const sc_uint_base& v);  bool operator > (const sc_int_base&  u, const sc_signed&    v);  bool operator > (const sc_uint_base& u, const sc_signed&    v);  // Logical GREATER_THAN_AND_EQUAL operators:  bool operator >= (const sc_unsigned&  u, const sc_signed&    v);  bool operator >= (const sc_signed&    u, const sc_unsigned&  v);  bool operator >= (const sc_signed&    u, const sc_signed&    v);  bool operator >= (const sc_signed&    u, int64               v);  bool operator >= (const sc_signed&    u, uint64              v);  bool operator >= (const sc_signed&    u, long                v);  bool operator >= (const sc_signed&    u, unsigned long       v);  inline bool operator >= (const sc_signed&    u, int                 v);  inline bool operator >= (const sc_signed&    u, unsigned int        v);  bool operator >= (int64               u, const sc_signed&    v);  bool operator >= (uint64              u, const sc_signed&    v);  bool operator >= (long                u, const sc_signed&    v);  bool operator >= (unsigned long       u, const sc_signed&    v);  inline bool operator >= (int                 u, const sc_signed&    v);  inline bool operator >= (unsigned int        u, const sc_signed&    v);  bool operator >= (const sc_signed&    u, const sc_int_base&  v);  bool operator >= (const sc_signed&    u, const sc_uint_base& v);  bool operator >= (const sc_int_base&  u, const sc_signed&    v);  bool operator >= (const sc_uint_base& u, const sc_signed&    v);  // Bitwise NOT operator (unary).  sc_signed operator ~ (const sc_signed& u);// ----------------------------------------------------------------------------//  CLASS : sc_signed_bitref_r////  Proxy class for sc_signed bit selection (r-value only).// ----------------------------------------------------------------------------class sc_signed_bitref_r : public sc_value_base{    friend class sc_signed;protected:    // constructor    sc_signed_bitref_r()        {}    void initialize( const sc_signed* obj_p, int index_ )        {	    m_index = index_;	    m_obj_p = ( CCAST<sc_signed*>( obj_p ) );	}public:    // destructor    virtual ~sc_signed_bitref_r()	{}    // copy constructor    sc_signed_bitref_r( const sc_signed_bitref_r& a )	: m_index( a.m_index ), m_obj_p( a.m_obj_p )	{}    // capacity    int length() const	{ return 1; }    // implicit conversion to bool    operator uint64 () const;    bool operator ! () const;    bool operator ~ () const;    // explicit conversions    bool value() const	{ return operator uint64(); }    bool to_bool() const	{ return operator uint64(); }    // concatenation support    virtual int concat_length(bool* xz_present_p) const        { if ( xz_present_p ) *xz_present_p = false; return 1; }    virtual uint64 concat_get_uint64() const	{ return (uint64)operator uint64(); }    virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const	{	    int  bit_mask = 1 << (low_i % BITS_PER_DIGIT);	    int  word_i = low_i / BITS_PER_DIGIT;	    dst_p[word_i] &= ~bit_mask;	    return false;        }    virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const	{	    int  bit_mask = 1 << (low_i % BITS_PER_DIGIT);	    bool result;	// True if non-zero.	    int  word_i = low_i / BITS_PER_DIGIT;	    if ( operator uint64() )	    {		dst_p[word_i] |= bit_mask;		result = true;	    }	    else	    {		dst_p[word_i] &= ~bit_mask;		result = false;	    }	    return result;        }    // other methods    void print( ::std::ostream& os = ::std::cout ) const	{ os << to_bool(); }protected:    int        m_index;  // Bit to be selected.    sc_signed* m_obj_p;  // Target of this bit selection.private:    // disabled    const sc_signed_bitref_r& operator = ( const sc_signed_bitref_r& );};inline::std::ostream&operator << ( ::std::ostream&, const sc_signed_bitref_r& );// ----------------------------------------------------------------------------//  CLASS : sc_signed_bitref////  Proxy class for sc_signed bit selection (r-value and l-value).// ----------------------------------------------------------------------------class sc_signed_bitref    : public sc_signed_bitref_r{    friend class sc_signed;    friend class sc_core::sc_vpool<sc_signed_bitref>;    // constructorprotected:    sc_signed_bitref()	{}public:    // copy constructor    sc_signed_bitref( const sc_signed_bitref& a )	: sc_signed_bitref_r( a )	{}    // assignment operators    const sc_signed_bitref& operator = ( const sc_signed_bitref_r& );    const sc_signed_bitref& operator = ( const sc_signed_bitref& );    const sc_signed_bitref& operator = ( bool );    const sc_signed_bitref& operator &= ( bool );    const sc_signed_bitref& operator |= ( bool );    const sc_signed_bitref& operator ^= ( bool );    // 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_bitref> m_pool;};inline::std::istream&operator >> ( ::std::istream&, sc_signed_bitref& );// ----------------------------------------------------------------------------//  CLASS : sc_signed_subref_r////  Proxy class for sc_signed part selection (r-value only).// ----------------------------------------------------------------------------class sc_signed_subref_r : public sc_value_base{    friend class sc_signed;    friend class sc_signed_signal;    friend class sc_unsigned;protected:    // constructor    sc_signed_subref_r()	{}    void initialize( const sc_signed* obj_p, int left_, int right_ )        {	    m_obj_p = ( CCAST<sc_signed*>( obj_p ));	    m_left = left_;	    m_right = right_;	}public:    // destructor    virtual ~sc_signed_subref_r()	{}    // copy constructor    sc_signed_subref_r( const sc_signed_subref_r& a )	: m_left( a.m_left ), m_obj_p( a.m_obj_p ), m_right( a.m_right )	{}    // capacity    int length() const        { return m_left >= m_right ? (m_left-m_right+1) : (m_right-m_left+1 ); }    // implicit conversion to sc_unsigned    operator sc_unsigned () const;    // 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;    // 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;    // concatenation support    virtual int concat_length(bool* xz_present_p) const        {	    if ( xz_present_p ) *xz_present_p = false;	    return m_left - m_right + 1;        }    virtual uint64 concat_get_uint64() const;    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;    // reduce methods    bool and_reduce() const;    bool nand_reduce() const;    bool or_reduce() const;    bool nor_reduce() const;    bool xor_reduce() const ;    bool xnor_reduce() const;    // other methods    void print( ::std::ostream& os = ::std::cout ) const	{ os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }protected:    int        m_left;   // Left-most bit in this part selection.    sc_signed* m_obj_p;  // Target of this part selection.

⌨️ 快捷键说明

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