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

📄 sc_signed.cpp

📁 system C源码 一种替代verilog的语言
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  if (u.sgn == SC_ZERO) // case 1    return sc_signed(v);  if (v.sgn == SC_ZERO) // case 2    return sc_signed(u);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           v.sgn, v.nbits, v.ndigits, v.digit);  }sc_signedoperator+(const sc_signed &u, int64 v){  if (v == 0)  // case 2    return sc_signed(u);  CONVERT_INT64(v);  if (u.sgn == SC_ZERO)  // case 1    return sc_signed(vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator+(int64 u, const sc_signed &v){  if (u == 0) // case 1    return sc_signed(v);  CONVERT_INT64(u);  if (v.sgn == SC_ZERO)  // case 2    return sc_signed(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator+(const sc_unsigned &u, int64 v){  if (v == 0)  // case 2    return sc_signed(u);  CONVERT_INT64(v);  if (u.sgn == SC_ZERO)  // case 1    return sc_signed(vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator+(int64 u, const sc_unsigned &v){  if (u == 0) // case 1    return sc_signed(v);  CONVERT_INT64(u);  if (v.sgn == SC_ZERO)  // case 2    return sc_signed(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator+(const sc_signed &u, uint64 v){  if (v == 0)  // case 2    return sc_signed(u);  CONVERT_INT64(v);  if (u.sgn == SC_ZERO)  // case 1    return sc_signed(vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator+(uint64 u, const sc_signed &v){  if (u == 0) // case 1    return sc_signed(v);  CONVERT_INT64(u);  if (v.sgn == SC_ZERO)  // case 2    return sc_signed(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator+(const sc_signed &u, long v){  if (v == 0)  // case 2    return sc_signed(u);  CONVERT_LONG(v);  if (u.sgn == SC_ZERO)  // case 1    return sc_signed(vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd);}sc_signedoperator+(long u, const sc_signed &v){  if (u == 0) // case 1    return sc_signed(v);  CONVERT_LONG(u);  if (v.sgn == SC_ZERO)  // case 2    return sc_signed(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                           v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator+(const sc_unsigned &u, long v){  if (v == 0)  // case 2    return sc_signed(u);  CONVERT_LONG(v);  if (u.sgn == SC_ZERO)  // case 1    return sc_signed(vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd);}sc_signedoperator+(long u, const sc_unsigned &v){  if (u == 0) // case 1    return sc_signed(v);  CONVERT_LONG(u);  if (v.sgn == SC_ZERO)  // case 2    return sc_signed(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                           v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator+(const sc_signed &u, unsigned long v){  if (v == 0) // case 2    return sc_signed(u);  CONVERT_LONG(v);  if (u.sgn == SC_ZERO)  // case 1    return sc_signed(vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd);}sc_signedoperator+(unsigned long u, const sc_signed &v){  if (u == 0) // case 1    return sc_signed(v);  CONVERT_LONG(u);  if (v.sgn == SC_ZERO)  // case 2    return sc_signed(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                           v.sgn, v.nbits, v.ndigits, v.digit);}// The rest of the operators in this section are included from// sc_nbcommon.cpp.// ----------------------------------------------------------------------------//  SECTION: MINUS operators: -, -=, --// ----------------------------------------------------------------------------// Cases to consider when computing u + v:// 1. u - 0 = u // 2. 0 - v = -v// 3. if sgn(u) != sgn(v)//    3.1 u - (-v) = u + v = sgn(u) * (u + v)//    3.2 (-u) - v = -(u + v) ==> sgn(u) * (u + v)// 4. if sgn(u) == sgn(v)//    4.1 u - v = +(u - v) = sgn(u) * (u - v) //    4.2 (-u) - (-v) = -(u - v) = sgn(u) * (u - v)//// Specialization of above cases for computing --u or u--: // 1. 0 - 1 = -1// 3. (-u) - 1 = -(u + 1) = sgn(u) * (u + 1)// 4. u - 1 = u - 1 = sgn(u) * (u - 1)sc_signedoperator-(const sc_unsigned& u, const sc_unsigned& v){  if (v.sgn == SC_ZERO)  // case 1    return sc_signed(u);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(v, -v.sgn);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_unsigned& u, const sc_signed& v){  if (v.sgn == SC_ZERO)  // case 1    return sc_signed(u);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(v, -v.sgn);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_signed& u, const sc_unsigned& v){  if (v.sgn == SC_ZERO)  // case 1    return sc_signed(u);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(v, -v.sgn);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_signed& u, const sc_signed& v){  if (v.sgn == SC_ZERO)  // case 1    return sc_signed(u);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(v, -v.sgn);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_signed &u, int64 v){  if (v == 0) // case 1    return sc_signed(u);  CONVERT_INT64(v);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(-vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator-(int64 u, const sc_signed& v){  if (u == 0) // case 1    return sc_signed(v, -v.sgn);  CONVERT_INT64(u);  if (v.sgn == SC_ZERO) // case 2    return sc_signed(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_unsigned &u, int64 v){  if (v == 0) // case 1    return sc_signed(u);  CONVERT_INT64(v);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(-vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator-(int64 u, const sc_unsigned& v){  if (u == 0) // case 1    return sc_signed(v, -v.sgn);  CONVERT_INT64(u);  if (v.sgn == SC_ZERO) // case 2    return sc_signed(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_signed &u, uint64 v){  if (v == 0) // case 1    return sc_signed(u);  CONVERT_INT64(v);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(-vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator-(uint64 u, const sc_signed& v){  if (u == 0) // case 1    return sc_signed(v, -v.sgn);  CONVERT_INT64(u);  if (v.sgn == SC_ZERO) // case 2    return sc_signed(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_unsigned &u, uint64 v){  if (v == 0) // case 1    return sc_signed(u);  CONVERT_INT64(v);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(-vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -vs, BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator-(uint64 u, const sc_unsigned& v){  if (u == 0) // case 1    return sc_signed(v, -v.sgn);  CONVERT_INT64(u);  if (v.sgn == SC_ZERO) // case 2    return sc_signed(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_signed &u, long v){  if (v == 0) // case 1    return sc_signed(u);  CONVERT_LONG(v);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(-vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd);}sc_signedoperator-(long u, const sc_signed& v){  if (u == 0) // case 1    return sc_signed(v, -v.sgn);  CONVERT_LONG(u);  if (v.sgn == SC_ZERO) // case 2    return sc_signed(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_unsigned &u, long v){  if (v == 0) // case 1    return sc_signed(u);  CONVERT_LONG(v);  if (u.sgn == SC_ZERO) // case 2    return sc_signed(-vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd, false);  // cases 3 and 4  return add_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           -vs, BITS_PER_ULONG, DIGITS_PER_ULONG, vd);}sc_signedoperator-(long u, const sc_unsigned& v){  if (u == 0) // case 1    return sc_signed(v, -v.sgn);  CONVERT_LONG(u);  if (v.sgn == SC_ZERO) // case 2    return sc_signed(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud, false);  // cases 3 and 4  return add_signed_friend(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                           -v.sgn, v.nbits, v.ndigits, v.digit);}sc_signedoperator-(const sc_signed &u, unsigned long v){  if (v == 0) // case 1

⌨️ 快捷键说明

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