sc_nbcommon.inc
来自「基于4个mips核的noc设计」· INC 代码 · 共 2,729 行 · 第 1/4 页
INC
2,729 行
return (*this = v); // other cases CONVERT_INT64(v); xor_on_help(sgn, nbits, ndigits, digit, vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd); convert_2C_to_SM(); return *this;}CLASS_TYPE&CLASS_TYPE::operator^=(uint64 v){ if (v == 0) // case 1 return *this; if (sgn == SC_ZERO) // case 2 return (*this = v); // other cases CONVERT_INT64(v); xor_on_help(sgn, nbits, ndigits, digit, vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd); convert_2C_to_SM(); return *this;}CLASS_TYPE&CLASS_TYPE::operator^=(long v){ if (v == 0) // case 1 return *this; if (sgn == SC_ZERO) // case 2 return (*this = v); // other cases CONVERT_LONG(v); xor_on_help(sgn, nbits, ndigits, digit, vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd); convert_2C_to_SM(); return *this;}CLASS_TYPE&CLASS_TYPE::operator^=(unsigned long v){ if (v == 0) // case 1 return *this; if (sgn == SC_ZERO) // case 2 return (*this = v); // other cases CONVERT_LONG(v); xor_on_help(sgn, nbits, ndigits, digit, vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd); convert_2C_to_SM(); return *this;}// ----------------------------------------------------------------------------// SECTION: Bitwise NOT operator: ~// ----------------------------------------------------------------------------CLASS_TYPEoperator~(const CLASS_TYPE& u){ small_type s = u.sgn; if (s == SC_ZERO) { unsigned long d = 1; return CLASS_TYPE(SC_NEG, u.nbits, 1, &d, false); } int nd = u.ndigits;#ifdef SC_MAX_NBITS unsigned long d[MAX_NDIGITS];#else unsigned long *d = new unsigned long[nd];#endif vec_copy(nd, d, u.digit); if (s == SC_POS) { s = SC_NEG; vec_add_small_on(nd, d, 1); } else { s = SC_POS; vec_sub_small_on(nd, d, 1); if (check_for_zero(nd, d)) s = SC_ZERO; } return CLASS_TYPE(s, u.nbits, nd, d);}// ----------------------------------------------------------------------------// SECTION: LEFT SHIFT operators: <<, <<=// ----------------------------------------------------------------------------CLASS_TYPEoperator<<(const CLASS_TYPE& u, const CLASS_TYPE& v){ if (v.sgn == SC_ZERO) return CLASS_TYPE(u);#ifdef SC_SIGNED if (v.sgn == SC_NEG) return CLASS_TYPE(u);#endif return operator<<(u, v.to_ulong());}CLASS_TYPE&CLASS_TYPE::operator<<=(const CLASS_TYPE& v){ if (v.sgn == SC_ZERO) return *this;#ifdef SC_SIGNED if (v.sgn == SC_NEG) return *this;#endif return operator<<=(v.to_ulong());}CLASS_TYPE&CLASS_TYPE::operator<<=(const OTHER_CLASS_TYPE& v){ if (v.sgn == SC_ZERO) return *this;#ifdef SC_UNSIGNED if (v.sgn == SC_NEG) return *this;#endif return operator<<=(v.to_ulong());}CLASS_TYPEoperator<<(const CLASS_TYPE& u, int64 v){ if (v <= 0) return CLASS_TYPE(u); return operator<<(u, (unsigned long) v);}CLASS_TYPEoperator<<(const CLASS_TYPE& u, uint64 v){ if (v == 0) return CLASS_TYPE(u); return operator<<(u, (unsigned long) v);}CLASS_TYPE&CLASS_TYPE::operator<<=(int64 v){ if (v <= 0) return *this; return operator<<=((unsigned long) v);}CLASS_TYPE&CLASS_TYPE::operator<<=(uint64 v){ if (v == 0) return *this; return operator<<=((unsigned long) v);}CLASS_TYPEoperator<<(const CLASS_TYPE& u, long v){ if (v <= 0) return CLASS_TYPE(u); return operator<<(u, (unsigned long) v);}CLASS_TYPEoperator<<(const CLASS_TYPE& u, unsigned long v){ if (v == 0) return CLASS_TYPE(u); if (u.sgn == SC_ZERO) return CLASS_TYPE(u); int nb = u.nbits + v; int nd = DIV_CEIL(nb);#ifdef SC_MAX_NBITS test_bound(nb); unsigned long d[MAX_NDIGITS];#else unsigned long *d = new unsigned long[nd];#endif vec_copy_and_zero(nd, d, u.ndigits, u.digit); convert_SM_to_2C(u.sgn, nd, d); vec_shift_left(nd, d, v); small_type s = convert_signed_2C_to_SM(nb, nd, d); return CLASS_TYPE(s, nb, nd, d);}CLASS_TYPE&CLASS_TYPE::operator<<=(long v){ if (v <= 0) return *this; return operator<<=((unsigned long) v);}CLASS_TYPE&CLASS_TYPE::operator<<=(unsigned long v){ if (v == 0) return *this; if (sgn == SC_ZERO) return *this; convert_SM_to_2C(); vec_shift_left(ndigits, digit, v); convert_2C_to_SM(); return *this;}// ----------------------------------------------------------------------------// SECTION: RIGHT SHIFT operators: >>, >>=// ----------------------------------------------------------------------------CLASS_TYPEoperator>>(const CLASS_TYPE& u, const CLASS_TYPE& v){ if (v.sgn == SC_ZERO) return CLASS_TYPE(u);#ifdef SC_SIGNED if (v.sgn == SC_NEG) return CLASS_TYPE(u);#endif return operator>>(u, v.to_long());}CLASS_TYPE&CLASS_TYPE::operator>>=(const CLASS_TYPE& v){ if (v.sgn == SC_ZERO) return *this;#ifdef SC_SIGNED if (v.sgn == SC_NEG) return *this;#endif return operator>>=(v.to_long());}CLASS_TYPE&CLASS_TYPE::operator>>=(const OTHER_CLASS_TYPE& v){ if (v.sgn == SC_ZERO) return *this;#ifdef SC_UNSIGNED if (v.sgn == SC_NEG) return *this;#endif return operator>>=(v.to_ulong());}CLASS_TYPEoperator>>(const CLASS_TYPE& u, int64 v){ if (v <= 0) return CLASS_TYPE(u); return operator>>(u, (unsigned long) v);}CLASS_TYPEoperator>>(const CLASS_TYPE& u, uint64 v){ if (v == 0) return CLASS_TYPE(u); return operator>>(u, (unsigned long) v);}CLASS_TYPE&CLASS_TYPE::operator>>=(int64 v){ if (v <= 0) return *this; return operator>>=((unsigned long) v);}CLASS_TYPE&CLASS_TYPE::operator>>=(uint64 v){ if (v == 0) return *this; return operator>>=((unsigned long) v);}CLASS_TYPEoperator>>(const CLASS_TYPE& u, long v){ if (v <= 0) return CLASS_TYPE(u); return operator>>(u, (unsigned long) v);}CLASS_TYPEoperator>>(const CLASS_TYPE& u, unsigned long v){ if (v == 0) return CLASS_TYPE(u); if (u.sgn == SC_ZERO) return CLASS_TYPE(u); int nb = u.nbits; int nd = u.ndigits;#ifdef SC_MAX_NBITS unsigned long d[MAX_NDIGITS];#else unsigned long *d = new unsigned long[nd];#endif vec_copy(nd, d, u.digit); convert_SM_to_2C(u.sgn, nd, d); if (u.sgn == SC_NEG) vec_shift_right(nd, d, v, DIGIT_MASK); else vec_shift_right(nd, d, v, 0); small_type s = convert_signed_2C_to_SM(nb, nd, d); return CLASS_TYPE(s, nb, nd, d);}CLASS_TYPE&CLASS_TYPE::operator>>=(long v){ if (v <= 0) return *this; return operator>>=((unsigned long) v);}CLASS_TYPE&CLASS_TYPE::operator>>=(unsigned long v){ if (v == 0) return *this; if (sgn == SC_ZERO) return *this; convert_SM_to_2C(); if (sgn == SC_NEG) vec_shift_right(ndigits, digit, v, DIGIT_MASK); else vec_shift_right(ndigits, digit, v, 0); convert_2C_to_SM(); return *this;}// ----------------------------------------------------------------------------// SECTION: EQUAL TO operator: ==// ----------------------------------------------------------------------------// Defined in the sc_signed.cpp and sc_unsigned.cpp.// ----------------------------------------------------------------------------// SECTION: NOT_EQUAL operator: !=// ----------------------------------------------------------------------------booloperator!=(const CLASS_TYPE& u, const CLASS_TYPE& v){ return (! operator==(u, v));}booloperator!=(const CLASS_TYPE& u, int64 v){ return (! operator==(u, v));}booloperator!=(int64 u, const CLASS_TYPE& v){ return (! operator==(u, v)); }booloperator!=(const CLASS_TYPE& u, uint64 v){ return (! operator==(u, v)); }booloperator!=(uint64 u, const CLASS_TYPE& v){ return (! operator==(u, v)); }booloperator!=(const CLASS_TYPE& u, long v){ return (! operator==(u, v));}booloperator!=(long u, const CLASS_TYPE& v){ return (! operator==(u, v)); }booloperator!=(const CLASS_TYPE& u, unsigned long v){ return (! operator==(u, v)); }booloperator!=(unsigned long u, const CLASS_TYPE& v){ return (! operator==(u, v)); }// ----------------------------------------------------------------------------// SECTION: LESS THAN operator: <// ----------------------------------------------------------------------------// Defined in the sc_signed.cpp and sc_unsigned.cpp.// ----------------------------------------------------------------------------// SECTION: LESS THAN or EQUAL operator: <=// ----------------------------------------------------------------------------booloperator<=(const CLASS_TYPE& u, const CLASS_TYPE& v){ return (operator<(u, v) || operator==(u, v));}booloperator<=(const CLASS_TYPE& u, int64 v){ return (operator<(u, v) || operator==(u, v));}booloperator<=(int64 u, const CLASS_TYPE& v){ return (operator<(u, v) || operator==(u, v));}booloperator<=(const CLASS_TYPE& u, uint64 v){ return (operator<(u, v) || operator==(u, v));}booloperator<=(uint64 u, const CLASS_TYPE& v){ return (operator<(u, v) || operator==(u, v));}booloperator<=(const CLASS_TYPE& u, long v){ return (operator<(u, v) || operator==(u, v));}booloperator<=(long u, const CLASS_TYPE& v){ return (operator<(u, v) || operator==(u, v));}booloperator<=(const CLASS_TYPE& u, unsigned long v){ return (operator<(u, v) || operator==(u, v));}booloperator<=(unsigned long u, const CLASS_TYPE& v){ return (operator<(u, v) || operator==(u, v));}// ----------------------------------------------------------------------------// SECTION: GREATER THAN operator: >// ----------------------------------------------------------------------------booloperator>(const CLASS_TYPE& u, const CLASS_TYPE& v){ return (! (operator<=(u, v)));}booloperator>(const CLASS_TYPE& u, int64 v){ return (! (operator<=(u, v)));}booloperator>(int64 u, const CLASS_TYPE& v){ return (! (operator<=(u, v)));}booloperator>(const CLASS_TYPE& u, uint64 v){ return (! (operator<=(u, v)));}booloperator>(uint64 u, const CLASS_TYPE& v){ return (! (operator<=(u, v)));}booloperator>(const CLASS_TYPE& u, long v){ return (! (operator<=(u, v)));}booloperator>(long u, const CLASS_TYPE& v){ return (! (operator<=(u, v)));}booloperator>(const CLASS_TYPE& u, unsigned long v){ return (! (operator<=(u, v)));}booloperator>(unsigned long u, const CLASS_TYPE& v){ return (! (operator<=(u, v)));}// ----------------------------------------------------------------------------// SECTION: GREATER THAN or EQUAL operator: >=// ----------------------------------------------------------------------------booloperator>=(const CLASS_TYPE& u, const CLASS_TYPE& v){ return (! (operator<(u, v)));}booloperator>=(const CLASS_TYPE& u, int64 v){ return (! (operator<(u, v)));}booloperator>=(int64 u, const CLASS_TYPE& v)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?