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

📄 sc_signed.cpp

📁 system C源码 一种替代verilog的语言
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  }sc_signedoperator/(const sc_unsigned& u, long v){  small_type s = mul_signs(u.sgn, get_sign(v));  if (s == SC_ZERO) {    div_by_zero(v);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG_2(v);  // other cases  return div_signed_friend(s, u.nbits, u.ndigits, u.digit,                            BITS_PER_ULONG, DIGITS_PER_ULONG, vd);  }sc_signedoperator/(long u, const sc_unsigned& v){  small_type s = mul_signs(v.sgn, get_sign(u));  if (s == SC_ZERO) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG_2(u);  // other cases  return div_signed_friend(s, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                            v.nbits, v.ndigits, v.digit);  }sc_signedoperator/(const sc_signed& u, unsigned long v){  small_type s = mul_signs(u.sgn, get_sign(v));  if (s == SC_ZERO) {    div_by_zero(v);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG_2(v);  // other cases  return div_signed_friend(s, u.nbits, u.ndigits, u.digit,                            BITS_PER_ULONG, DIGITS_PER_ULONG, vd);  }sc_signedoperator/(unsigned long u, const sc_signed& v){  small_type s = mul_signs(v.sgn, get_sign(u));  if (s == SC_ZERO) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG_2(u);  // other cases  return div_signed_friend(s, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                            v.nbits, v.ndigits, v.digit);  }// The rest of the operators in this section are included from// sc_nbcommon.cpp.// ----------------------------------------------------------------------------//  SECTION: MOD operators: %, %=.// ----------------------------------------------------------------------------// Cases to consider when finding the remainder r = u % v:// Note that u = q * v + r for r < q.// 1. 0 % 0 or u % 0 => error// 2. 0 % v => 0 = 0 * v + 0// 3. u % v && u = v => u = 1 * u + 0  - u or v can be 1 or -1// 4. u % v && u < v => u = 0 * v + u  - u can be 1 or -1// 5. u % v && u > v => u = q * v + r  - v can be 1 or -1sc_signedoperator%(const sc_unsigned& u, const sc_signed& v){  if ((u.sgn == SC_ZERO) || (v.sgn == SC_ZERO)) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  // other cases  return mod_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           v.nbits, v.ndigits, v.digit);}sc_signedoperator%(const sc_signed& u, const sc_unsigned& v){  if ((u.sgn == SC_ZERO) || (v.sgn == SC_ZERO)) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  // other cases  return mod_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           v.nbits, v.ndigits, v.digit);}sc_signedoperator%(const sc_signed& u, const sc_signed& v){  if ((u.sgn == SC_ZERO) || (v.sgn == SC_ZERO)) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  // other cases  return mod_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           v.nbits, v.ndigits, v.digit);}sc_signedoperator%(const sc_signed& u, int64 v){  small_type vs = get_sign(v);  if ((u.sgn == SC_ZERO) || (vs == SC_ZERO)) {    div_by_zero(v);  // case 1    return sc_signed();  // case 2  }  CONVERT_INT64_2(v);  // other cases  return mod_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator%(int64 u, const sc_signed& v){  small_type us = get_sign(u);  if ((us == SC_ZERO) || (v.sgn == SC_ZERO)) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  CONVERT_INT64_2(u);  // other cases  return mod_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           v.nbits, v.ndigits, v.digit);}sc_signedoperator%(const sc_unsigned& u, int64 v){  small_type vs = get_sign(v);  if ((u.sgn == SC_ZERO) || (vs == SC_ZERO)) {    div_by_zero(v);  // case 1    return sc_signed();  // case 2  }  CONVERT_INT64_2(v);  // other cases  return mod_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator%(int64 u, const sc_unsigned& v){  small_type us = get_sign(u);  if ((us == SC_ZERO) || (v.sgn == SC_ZERO)) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  CONVERT_INT64_2(u);  // other cases  return mod_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           v.nbits, v.ndigits, v.digit);}sc_signedoperator%(const sc_signed& u, uint64 v){  if ((u.sgn == SC_ZERO) || (v == 0)) {    div_by_zero(v);  // case 1    return sc_signed();  // case 2  }  CONVERT_INT64_2(v);  // other cases  return mod_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           BITS_PER_UINT64, DIGITS_PER_UINT64, vd);}sc_signedoperator%(uint64 u, const sc_signed& v){  if ((u == 0) || (v.sgn == SC_ZERO)) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  CONVERT_INT64(u);  // other cases  return mod_signed_friend(us, BITS_PER_UINT64, DIGITS_PER_UINT64, ud,                           v.nbits, v.ndigits, v.digit);}sc_signedoperator%(const sc_signed& u, long v){  small_type vs = get_sign(v);  if ((u.sgn == SC_ZERO) || (vs == SC_ZERO)) {    div_by_zero(v);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG_2(v);  // other cases  return mod_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           BITS_PER_ULONG, DIGITS_PER_ULONG, vd);}sc_signedoperator%(long u, const sc_signed& v){  small_type us = get_sign(u);  if ((us == SC_ZERO) || (v.sgn == SC_ZERO)) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG_2(u);  // other cases  return mod_signed_friend(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                           v.nbits, v.ndigits, v.digit);}sc_signedoperator%(const sc_unsigned& u, long v){  small_type vs = get_sign(v);  if ((u.sgn == SC_ZERO) || (vs == SC_ZERO)) {    div_by_zero(v);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG_2(v);  // other cases  return mod_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           BITS_PER_ULONG, DIGITS_PER_ULONG, vd);}sc_signedoperator%(long u, const sc_unsigned& v){  small_type us = get_sign(u);  if ((us == SC_ZERO) || (v.sgn == SC_ZERO)) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG_2(u);  // other cases  return mod_signed_friend(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                           v.nbits, v.ndigits, v.digit);}sc_signedoperator%(const sc_signed& u, unsigned long v){  if ((u.sgn == SC_ZERO) || (v == 0)) {    div_by_zero(v);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG_2(v);  // other cases  return mod_signed_friend(u.sgn, u.nbits, u.ndigits, u.digit,                           BITS_PER_ULONG, DIGITS_PER_ULONG, vd);}sc_signedoperator%(unsigned long u, const sc_signed& v){  if ((u == 0) || (v.sgn == SC_ZERO)) {    div_by_zero(v.sgn);  // case 1    return sc_signed();  // case 2  }  CONVERT_LONG(u);  // other cases  return mod_signed_friend(us, BITS_PER_ULONG, DIGITS_PER_ULONG, ud,                           v.nbits, v.ndigits, v.digit);}// The rest of the operators in this section are included from// sc_nbcommon.cpp.// ----------------------------------------------------------------------------//  SECTION: Bitwise AND operators: &, &=// ----------------------------------------------------------------------------// Cases to consider when computing u & v:// 1. u & 0 = 0 & v = 0// 2. u & v => sgn = +// 3. (-u) & (-v) => sgn = -// 4. u & (-v) => sgn = +// 5. (-u) & v => sgn = +sc_signedoperator&(const sc_unsigned& u, const sc_signed& v){  if ((u.sgn == SC_ZERO) || (v.sgn == SC_ZERO)) // case 1    return sc_signed();  // other cases  return and_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 ((u.sgn == SC_ZERO) || (v.sgn == SC_ZERO)) // case 1    return sc_signed();  // other cases  return and_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 ((u.sgn == SC_ZERO) || (v.sgn == SC_ZERO)) // case 1    return sc_signed();  // other cases  return and_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 ((u.sgn == SC_ZERO) || (v == 0)) // case 1    return sc_signed();  CONVERT_INT64(v);  // other cases  return and_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) || (v.sgn == SC_ZERO)) // case 1    return sc_signed();  CONVERT_INT64(u);  // other cases  return and_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 ((u.sgn == SC_ZERO) || (v == 0)) // case 1    return sc_signed();  CONVERT_INT64(v);  // other cases  return and_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) || (v.sgn == SC_ZERO)) // case 1    return sc_signed();  CONVERT_INT64(u);  // other cases  return and_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 ((u.sgn == SC_ZERO) || (v == 0)) // case 1    return sc_signed();  CONVERT_INT64(v);  // other cases  return and_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) || (v.sgn == SC_ZERO)) // case 1    return sc_signed();  CONVERT_INT64(u);  // other cases  return and_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 ((u.sgn == SC_ZERO) || (v == 0)) // case 1    return sc_signed();  CONVERT_LONG(v);  // other cases  return and_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) || (v.sgn == SC_ZERO)) // case 1    return sc_signed();  CONVERT_LONG(u);  // other cases  return and_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 ((u.sgn == SC_ZERO) || (v == 0)) // case 1    return sc_signed();  CONVERT_LONG(v);  // other cases  return and_signed_fri

⌨️ 快捷键说明

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