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

📄 sc_fxnum.h

📁 system C源码 一种替代verilog的语言
💻 H
📖 第 1 页 / 共 5 页
字号:
#undef DECL_ASN_OP_A    // relational operators#define DECL_REL_OP_T(op,tp)                                                  \    friend bool operator op ( const sc_fxnum_fast_subref&, tp );              \    friend bool operator op ( tp, const sc_fxnum_fast_subref& );#define DECL_REL_OP(op)                                                       \    friend bool operator op ( const sc_fxnum_fast_subref&,                    \			      const sc_fxnum_fast_subref& );                  \    friend bool operator op ( const sc_fxnum_fast_subref&,                    \			      const sc_fxnum_subref& );                       \    DECL_REL_OP_T(op,const sc_bv_base&)                                       \    DECL_REL_OP_T(op,const sc_lv_base&)                                       \    DECL_REL_OP_T(op,const char*)                                             \    DECL_REL_OP_T(op,const bool*)                                             \    DECL_REL_OP_T(op,const sc_signed&)                                        \    DECL_REL_OP_T(op,const sc_unsigned&)                                      \    DECL_REL_OP_T(op,int)                                                     \    DECL_REL_OP_T(op,unsigned int)                                            \    DECL_REL_OP_T(op,long)                                                    \    DECL_REL_OP_T(op,unsigned long)    DECL_REL_OP(==)    DECL_REL_OP(!=)#undef DECL_REL_OP_T#undef DECL_REL_OP    // reduce functions    bool and_reduce() const;    bool nand_reduce() const;    bool or_reduce() const;    bool nor_reduce() const;    bool xor_reduce() const;    bool xnor_reduce() const;    // query parameter    int length() 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;#ifdef SC_DT_DEPRECATED    int           to_signed() const;    unsigned int  to_unsigned() const;#endif    const std::string to_string() const;    const std::string to_string( sc_numrep ) const;    const std::string to_string( sc_numrep, bool ) const;    // implicit conversion    operator sc_bv_base() const;    // print or dump content    void print( ::std::ostream& = ::std::cout ) const;    void scan( ::std::istream& = ::std::cin );    void dump( ::std::ostream& = ::std::cout ) const;private:    sc_fxnum_fast& m_num;    int            m_from;    int            m_to;    sc_bv_base& m_bv;private:    // disabled    sc_fxnum_fast_subref();};// ----------------------------------------------------------------------------//  CLASS : sc_fxnum////  Base class for the fixed-point types; arbitrary precision.// ----------------------------------------------------------------------------class sc_fxnum{    friend class sc_fxval;    friend class sc_fxnum_bitref;    friend class sc_fxnum_subref;    friend class sc_fxnum_fast_bitref;    friend class sc_fxnum_fast_subref;    friend class sc_core::vcd_sc_fxnum_trace;    friend class sc_core::wif_sc_fxnum_trace;protected:    sc_fxnum_observer* observer() const;    void cast();    // constructors    sc_fxnum( const sc_fxtype_params&,	      sc_enc,	      const sc_fxcast_switch&,	      sc_fxnum_observer* );#define DECL_CTOR_T(tp)                                                       \    sc_fxnum( tp,                                                             \	      const sc_fxtype_params&,                                        \	      sc_enc,                                                         \	      const sc_fxcast_switch&,                                        \	      sc_fxnum_observer* );    DECL_CTOR_T(int)    DECL_CTOR_T(unsigned int)    DECL_CTOR_T(long)    DECL_CTOR_T(unsigned long)    DECL_CTOR_T(double)    DECL_CTOR_T(const char*)    DECL_CTOR_T(const sc_fxval&)    DECL_CTOR_T(const sc_fxval_fast&)    DECL_CTOR_T(const sc_fxnum&)    DECL_CTOR_T(const sc_fxnum_fast&)#ifndef SC_FX_EXCLUDE_OTHER    DECL_CTOR_T(int64)    DECL_CTOR_T(uint64)    DECL_CTOR_T(const sc_int_base&)    DECL_CTOR_T(const sc_uint_base&)    DECL_CTOR_T(const sc_signed&)    DECL_CTOR_T(const sc_unsigned&)#endif#undef DECL_CTOR_T    ~sc_fxnum();    // internal use only;    const scfx_rep* get_rep() const;public:    // unary operators    const sc_fxval operator - () const;    const sc_fxval operator + () const;    // unary functions    friend void neg( sc_fxval&, const sc_fxnum& );    friend void neg( sc_fxnum&, const sc_fxnum& );    // binary operators#define DECL_BIN_OP_T(op,tp)                                                  \    friend const sc_fxval operator op ( const sc_fxnum&, tp );                \    friend const sc_fxval operator op ( tp, const sc_fxnum& );#ifndef SC_FX_EXCLUDE_OTHER#define DECL_BIN_OP_OTHER(op)                                                 \    DECL_BIN_OP_T(op,int64)                                                   \    DECL_BIN_OP_T(op,uint64)                                                  \    DECL_BIN_OP_T(op,const sc_int_base&)                                      \    DECL_BIN_OP_T(op,const sc_uint_base&)                                     \    DECL_BIN_OP_T(op,const sc_signed&)                                        \    DECL_BIN_OP_T(op,const sc_unsigned&)#else#define DECL_BIN_OP_OTHER(op)#endif#define DECL_BIN_OP(op,dummy)                                                 \    friend const sc_fxval operator op ( const sc_fxnum&, const sc_fxnum& );   \    DECL_BIN_OP_T(op,int)                                                     \    DECL_BIN_OP_T(op,unsigned int)                                            \    DECL_BIN_OP_T(op,long)                                                    \    DECL_BIN_OP_T(op,unsigned long)                                           \    DECL_BIN_OP_T(op,double)                                                  \    DECL_BIN_OP_T(op,const char*)                                             \    DECL_BIN_OP_T(op,const sc_fxval&)                                         \    DECL_BIN_OP_T(op,const sc_fxval_fast&)                                    \    DECL_BIN_OP_T(op,const sc_fxnum_fast&)                                    \    DECL_BIN_OP_OTHER(op)    DECL_BIN_OP(*,mult)    DECL_BIN_OP(+,add)    DECL_BIN_OP(-,sub)// don't use macros//    DECL_BIN_OP(/,div)    friend const sc_fxval operator / ( const sc_fxnum&, const sc_fxnum& );    DECL_BIN_OP_T(/,int)    DECL_BIN_OP_T(/,unsigned int)    DECL_BIN_OP_T(/,long)    DECL_BIN_OP_T(/,unsigned long)    DECL_BIN_OP_T(/,double)    DECL_BIN_OP_T(/,const char*)    DECL_BIN_OP_T(/,const sc_fxval&)    DECL_BIN_OP_T(/,const sc_fxval_fast&)    DECL_BIN_OP_T(/,const sc_fxnum_fast&)//    DECL_BIN_OP_OTHER(op)#ifndef SC_FX_EXCLUDE_OTHER    DECL_BIN_OP_T(/,int64)    DECL_BIN_OP_T(/,uint64)    DECL_BIN_OP_T(/,const sc_int_base&)    DECL_BIN_OP_T(/,const sc_uint_base&)    DECL_BIN_OP_T(/,const sc_signed&)    DECL_BIN_OP_T(/,const sc_unsigned&)#endif#undef DECL_BIN_OP_T#undef DECL_BIN_OP_OTHER#undef DECL_BIN_OP    friend const sc_fxval operator << ( const sc_fxnum&, int );    friend const sc_fxval operator >> ( const sc_fxnum&, int );    // binary functions#define DECL_BIN_FNC_T(fnc,tp)                                                \    friend void fnc ( sc_fxval&, const sc_fxnum&, tp );                       \    friend void fnc ( sc_fxval&, tp, const sc_fxnum& );                       \    friend void fnc ( sc_fxnum&, const sc_fxnum&, tp );                       \    friend void fnc ( sc_fxnum&, tp, const sc_fxnum& );#ifndef SC_FX_EXCLUDE_OTHER#define DECL_BIN_FNC_OTHER(fnc)                                               \    DECL_BIN_FNC_T(fnc,int64)                                                 \    DECL_BIN_FNC_T(fnc,uint64)                                                \    DECL_BIN_FNC_T(fnc,const sc_int_base&)                                    \    DECL_BIN_FNC_T(fnc,const sc_uint_base&)                                   \    DECL_BIN_FNC_T(fnc,const sc_signed&)                                      \    DECL_BIN_FNC_T(fnc,const sc_unsigned&)#else#define DECL_BIN_FNC_OTHER(fnc)#endif#define DECL_BIN_FNC(fnc)                                                     \    friend void fnc ( sc_fxval&, const sc_fxnum&, const sc_fxnum& );          \    friend void fnc ( sc_fxnum&, const sc_fxnum&, const sc_fxnum& );          \    DECL_BIN_FNC_T(fnc,int)                                                   \    DECL_BIN_FNC_T(fnc,unsigned int)                                          \    DECL_BIN_FNC_T(fnc,long)                                                  \    DECL_BIN_FNC_T(fnc,unsigned long)                                         \    DECL_BIN_FNC_T(fnc,double)                                                \    DECL_BIN_FNC_T(fnc,const char*)                                           \    DECL_BIN_FNC_T(fnc,const sc_fxval&)                                       \    DECL_BIN_FNC_T(fnc,const sc_fxval_fast&)                                  \    DECL_BIN_FNC_T(fnc,const sc_fxnum_fast&)                                  \    DECL_BIN_FNC_OTHER(fnc)    DECL_BIN_FNC(mult)    DECL_BIN_FNC(div)    DECL_BIN_FNC(add)    DECL_BIN_FNC(sub)#undef DECL_BIN_FNC_T#undef DECL_BIN_FNC_OTHER#undef DECL_BIN_FNC    friend void lshift( sc_fxval&, const sc_fxnum&, int );    friend void rshift( sc_fxval&, const sc_fxnum&, int );    friend void lshift( sc_fxnum&, const sc_fxnum&, int );    friend void rshift( sc_fxnum&, const sc_fxnum&, int );    // relational (including equality) operators#define DECL_REL_OP_T(op,tp)                                                  \    friend bool operator op ( const sc_fxnum&, tp );                          \    friend bool operator op ( tp, const sc_fxnum& );#ifndef SC_FX_EXCLUDE_OTHER#define DECL_REL_OP_OTHER(op)                                                 \    DECL_REL_OP_T(op,int64)                                                   \    DECL_REL_OP_T(op,uint64)                                                  \    DECL_REL_OP_T(op,const sc_int_base&)                                      \    DECL_REL_OP_T(op,const sc_uint_base&)                                     \    DECL_REL_OP_T(op,const sc_signed&)                                        \    DECL_REL_OP_T(op,const sc_unsigned&)#else#define DECL_REL_OP_OTHER(op)#endif#define DECL_REL_OP(op)                                                       \    friend bool operator op ( const sc_fxnum&, const sc_fxnum& );             \    DECL_REL_OP_T(op,int)                                                     \    DECL_REL_OP_T(op,unsigned int)                                            \    DECL_REL_OP_T(op,long)                                                    \    DECL_REL_OP_T(op,unsigned long)                                           \    DECL_REL_OP_T(op,double)                                                  \    DECL_REL_OP_T(op,const char*)                                             \    DECL_REL_OP_T(op,const sc_fxval&)                                         \    DECL_REL_OP_T(op,const sc_fxval_fast&)                                    \    DECL_REL_OP_T(op,const sc_fxnum_fast&)                                    \    DECL_REL_OP_OTHER(op)    DECL_REL_OP(<)    DECL_REL_OP(<=)    DECL_REL_OP(>)    DECL_REL_OP(>=)    DECL_REL_OP(==)    DECL_REL_OP(!=)#undef DECL_REL_OP_T#undef DECL_REL_OP_OTHER#undef DECL_REL_OP    // assignment operators#define DECL_ASN_OP_T(op,tp)                                                  \    sc_fxnum& operator op( tp );#ifndef SC_FX_EXCLUDE_OTHER#define DECL_ASN_OP_OTHER(op)                                                 \    DECL_ASN_OP_T(op,int64)                                                   \    DECL_ASN_OP_T(op,uint64)                                                  \    DECL_ASN_OP_T(op,const sc_int_base&)                                      \    DECL_ASN_OP_T(op,const sc_uint_base&)                                     \    DECL_ASN_OP_T(op,const sc_signed&)                                        \    DECL_ASN_OP_T(op,const sc_unsigned&)#else#define DECL_ASN_OP_OTHER(op)#endif#define DECL_ASN_OP(op)                                                       \    DECL_ASN_OP_T(op,int)                                                     \    DECL_ASN_OP_T(op,unsigned int)                                            \    DECL_ASN_OP_T(op,long)                                                    \    DECL_ASN_OP_T(op,unsigned long)                                           \    DECL_ASN_OP_T(op,double)                                                  \    DECL_ASN_OP_T(op,const char*)                                             \    DECL_ASN_OP_T(op,const sc_fxval&)                                         \    DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \    DECL_ASN_OP_T(op,const sc_fxnum&)                                         \    DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \    DECL_ASN_OP_OTHER(op)    DECL_ASN_OP(=)    DECL_ASN_OP(*=)    DECL_ASN_OP(/=)    DECL_ASN_OP(+=)    DECL_ASN_OP(-=)    DECL_ASN_OP_T(<<=,int)    DECL_ASN_OP_T(>>=,int)#undef DECL_ASN_OP_T#undef DECL_ASN_OP_OTHER#undef DECL_ASN_OP    // auto-increment and auto-decrement    const sc_fxval operator ++ ( int );    const sc_fxval operator -- ( int );    sc_fxnum& operator ++ ();    sc_fxnum& operator -- ();    // bit selection    const sc_fxnum_bitref operator [] ( int ) const;    sc_fxnum_bitref       operator [] ( int );    const sc_fxnum_bitref bit( int ) const;    sc_fxnum_bitref       bit( int );    // part selection    const sc_fxnum_subref operator () ( int, int ) const;    sc_fxnum_subref       operator () ( int, int );    const sc_fxnum_subref range( int, int ) const;    sc_fxnum_subref       range( int, int );    const sc_fxnum_subref operator () () const;    sc_fxnum_subref       operator () ();    const sc_fxnum_subref range() const;    sc_fxnum_subref       range();    // implicit conversion    operator double() const;		// necessary evil!    // explicit conversion to primitive types    short          to_short() const;    unsigned short to_ushort() const;    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;    float          to_float() const;    double         to_double() const;    // explicit conversion to character string    const std::string to_string() const;    const std::string to_string( sc_numrep ) const;    const std::string to_string( sc_numrep, bool ) const;    const std::string to_string( sc_fmt ) const;    const std::string to_string( sc_numrep, sc_fmt ) const;    const std::string to_string( sc_numrep, bool, sc_fmt ) const;    const std::string to_dec() const;    const std::string to_bin() const;    const std::string to_oct() const;    const std::string to_hex() const;    // query value    bool is_neg() const;    bool is_zero() const;    // internal use only;    bool is_normal() const;

⌨️ 快捷键说明

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