📄 sc_fxnum.h
字号:
bool quantization_flag() const; bool overflow_flag() const; const sc_fxval value() const; // query parameters int wl() const; int iwl() const; sc_q_mode q_mode() const; sc_o_mode o_mode() const; int n_bits() const; const sc_fxtype_params& type_params() const; const sc_fxcast_switch& cast_switch() 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; // internal use only; void observer_read() const; // internal use only; bool get_bit( int ) const;protected: bool set_bit( int, bool ); bool get_slice( int, int, sc_bv_base& ) const; bool set_slice( int, int, const sc_bv_base& ); sc_fxnum_observer* lock_observer() const; void unlock_observer( sc_fxnum_observer* ) const;private: scfx_rep* m_rep; scfx_params m_params; bool m_q_flag; bool m_o_flag; mutable sc_fxnum_observer* m_observer;private: // disabled sc_fxnum(); sc_fxnum( const sc_fxnum& );};// ----------------------------------------------------------------------------// CLASS : sc_fxnum_fast//// Base class for the fixed-point types; limited precision.// ----------------------------------------------------------------------------class sc_fxnum_fast{ friend class sc_fxval_fast; 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_fast_trace; friend class sc_core::wif_sc_fxnum_fast_trace;protected: sc_fxnum_fast_observer* observer() const; void cast(); // constructors sc_fxnum_fast( const sc_fxtype_params&, sc_enc, const sc_fxcast_switch&, sc_fxnum_fast_observer* );#define DECL_CTOR_T(tp) \ sc_fxnum_fast( tp, \ const sc_fxtype_params&, \ sc_enc, \ const sc_fxcast_switch&, \ sc_fxnum_fast_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_fast(); // internal use only; double get_val() const;public: // unary operators const sc_fxval_fast operator - () const; const sc_fxval_fast operator + () const; // unary functions friend void neg( sc_fxval_fast&, const sc_fxnum_fast& ); friend void neg( sc_fxnum_fast&, const sc_fxnum_fast& ); // binary operators#define DECL_BIN_OP_T(op,tp) \ friend const sc_fxval_fast operator op ( const sc_fxnum_fast&, tp ); \ friend const sc_fxval_fast operator op ( tp, const sc_fxnum_fast& );#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_fast operator op ( const sc_fxnum_fast&, \ const sc_fxnum_fast& ); \ 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_fast&) \ DECL_BIN_OP_OTHER(op) DECL_BIN_OP(*,mult) DECL_BIN_OP(+,add) DECL_BIN_OP(-,sub)// DECL_BIN_OP(/,div) friend const sc_fxval_fast operator / ( const sc_fxnum_fast&, const sc_fxnum_fast& ); 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_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_fast operator << ( const sc_fxnum_fast&, int ); friend const sc_fxval_fast operator >> ( const sc_fxnum_fast&, int ); // binary functions#define DECL_BIN_FNC_T(fnc,tp) \ friend void fnc ( sc_fxval_fast&, const sc_fxnum_fast&, tp ); \ friend void fnc ( sc_fxval_fast&, tp, const sc_fxnum_fast& ); \ friend void fnc ( sc_fxnum_fast&, const sc_fxnum_fast&, tp ); \ friend void fnc ( sc_fxnum_fast&, tp, const sc_fxnum_fast& );#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_fast&, const sc_fxnum_fast&, \ const sc_fxnum_fast& ); \ friend void fnc ( sc_fxnum_fast&, const sc_fxnum_fast&, \ const sc_fxnum_fast& ); \ 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&) \ 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_fast&, const sc_fxnum_fast&, int ); friend void rshift( sc_fxval_fast&, const sc_fxnum_fast&, int ); friend void lshift( sc_fxnum_fast&, const sc_fxnum_fast&, int ); friend void rshift( sc_fxnum_fast&, const sc_fxnum_fast&, int ); // relational (including equality) operators#define DECL_REL_OP_T(op,tp) \ friend bool operator op ( const sc_fxnum_fast&, tp ); \ friend bool operator op ( tp, const sc_fxnum_fast& );#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_fast&, const sc_fxnum_fast& ); \ 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_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_fast& 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_fast operator ++ ( int ); const sc_fxval_fast operator -- ( int ); sc_fxnum_fast& operator ++ (); sc_fxnum_fast& operator -- (); // bit selection const sc_fxnum_fast_bitref operator [] ( int ) const; sc_fxnum_fast_bitref operator [] ( int ); const sc_fxnum_fast_bitref bit( int ) const; sc_fxnum_fast_bitref bit( int ); // part selection const sc_fxnum_fast_subref operator () ( int, int ) const; sc_fxnum_fast_subref operator () ( int, int ); const sc_fxnum_fast_subref range( int, int ) const; sc_fxnum_fast_subref range( int, int ); const sc_fxnum_fast_subref operator () () const; sc_fxnum_fast_subref operator () (); const sc_fxnum_fast_subref range() const; sc_fxnum_fast_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; bool quantization_flag() const; bool overflow_flag() const; const sc_fxval_fast value() const; // query parameters int wl() const; int iwl() const; sc_q_mode q_mode() const; sc_o_mode o_mode() const; int n_bits() const; const sc_fxtype_params& type_params() const; const sc_fxcast_switch& cast_switch() 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; // internal use only; void observer_read() const; // internal use only; bool get_bit( int ) const;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -