96template class sc_vpool<sc_dt::sc_signed_bitref>;
97template class sc_vpool<sc_dt::sc_signed_subref>;
110sc_signed::invalid_init(
const char *type_name,
int nb)
const
112 std::stringstream msg;
113 msg <<
"sc_signed("<< type_name <<
") : nb = " << nb <<
" is not valid";
122sc_signed::invalid_index(
int i)
const
124 std::stringstream msg;
125 msg <<
"sc_bigint bit selection: index = " << i <<
" violates "
126 "0 <= index <= " << (nbits - 1);
132sc_signed::invalid_range(
int l,
int r)
const
134 std::stringstream msg;
135 msg <<
"sc_bigint part selection: left = " <<
136 l <<
", right = " << r <<
" \n"
137 " violates either (" << (nbits-1) <<
" >= left >= 0) or "
138 "(" << (nbits-1) <<
" >= right >= 0)";
158sc_signed::concat_get_ctrl(
sc_digit *dst_p,
int low_i)
const
171 mask = ~(~0U << left_shift);
172 dst_p[dst_i] = (dst_p[dst_i] & ~mask);
175 for (; dst_i <= end_i; dst_i++)
182sc_signed::concat_get_data(
sc_digit *dst_p,
int low_i)
const
198 high_i = low_i + nbits - 1;
208 if (dst_i == end_i) {
209 mask = ~(~0U << left_shift);
210 dst_p[dst_i] = ((dst_p[dst_i] & mask) |
214 }
else if (left_shift == 0) {
215 for (src_i = 0; dst_i < end_i; dst_i++, src_i++) {
216 dst_p[dst_i] = digit[src_i];
220 dst_p[dst_i] = digit[src_i] & mask;
226 mask = ~(~0U << left_shift);
227 right_word = digit[0];
228 dst_p[dst_i] = (dst_p[dst_i] & mask) |
230 for (src_i = 1, dst_i++; dst_i < end_i; dst_i++, src_i++) {
231 left_word = digit[src_i];
232 dst_p[dst_i] = ((left_word << left_shift)&
DIGIT_MASK) |
233 (right_word >> right_shift);
234 right_word = left_word;
236 left_word = (src_i < ndigits) ? digit[src_i] : 0;
238 dst_p[dst_i] = ((left_word << left_shift) |
239 (right_word >> right_shift)) & mask;
247 if (dst_i == end_i) {
248 mask = ~(~0U << nbits);
249 right_word = ((digit[0] ^
DIGIT_MASK) + 1) & mask;
250 mask = ~(~0U << left_shift);
251 dst_p[dst_i] = ((dst_p[dst_i] & mask) |
255 }
else if (left_shift == 0) {
257 for (src_i = 0; dst_i < end_i; dst_i++, src_i++) {
258 right_word = (digit[src_i] ^
DIGIT_MASK) + carry;
264 right_word = (src_i < ndigits) ?
266 dst_p[dst_i] = right_word & mask;
272 mask = ~(~0U << left_shift);
275 dst_p[dst_i] = (dst_p[dst_i] & mask) |
279 for (src_i = 1, dst_i++; dst_i < end_i; dst_i++, src_i++) {
280 left_word = (digit[src_i] ^
DIGIT_MASK) + carry;
281 dst_p[dst_i] = ((left_word << left_shift)&
DIGIT_MASK) |
282 (right_word >> right_shift);
286 left_word = (src_i < ndigits) ?
289 dst_p[dst_i] = ((left_word << left_shift) |
290 (right_word >> right_shift)) & mask;
298 if (dst_i == end_i) {
299 mask = ~(~0U << nbits) << left_shift;
300 dst_p[dst_i] = dst_p[dst_i] & ~mask;
303 }
else if (left_shift == 0) {
304 for (src_i = 0; dst_i < end_i; dst_i++, src_i++) {
311 mask = ~(~0U << left_shift);
312 dst_p[dst_i] = (dst_p[dst_i] & mask);
313 for (dst_i++; dst_i <= end_i; dst_i++) {
325sc_signed::concat_get_uint64()
const
347 result = result & ~(mask << nbits);
359sc_signed::concat_set(
int64 src,
int low_i)
361 *
this = (low_i < 64) ? src >> low_i : src >> 63;
368 *
this = src >> low_i;
377 *
this = src >> low_i;
383sc_signed::concat_set(
uint64 src,
int low_i)
385 *
this = (low_i < 64) ? src >> low_i : 0;
393sc_signed::and_reduce()
const
400 for (i = 0; i < ndigits-1; i++) {
414sc_signed::or_reduce()
const
416 return sgn ==
SC_ZERO ? false :
true;
420sc_signed::xor_reduce()
const
426 for (i = 0; i < nbits; i++)
429 return odd ? true :
false;
441sc_signed::operator = (
const char *
a)
445 "character string is zero");
446 }
else if (*
a == 0) {
448 "character string is empty");
452 return this->operator = (aa);
454 std::stringstream msg;
455 msg <<
"character string '" <<
a <<
"' is not valid";
471 convert_SM_to_2C_to_SM();
485 convert_SM_to_2C_to_SM();
491sc_signed::operator=(
long v)
498 from_uint(ndigits, digit, (
unsigned long)v);
500 convert_SM_to_2C_to_SM();
506sc_signed::operator=(
unsigned long v)
514 convert_SM_to_2C_to_SM();
520sc_signed::operator=(
double v)
531 while (std::floor(v) && (i < ndigits)) {
537 convert_SM_to_2C_to_SM();
547 int minlen =
sc_min(nbits, v.length());
549 for (; i < minlen; ++i) {
552 for (; i < nbits; ++i) {
562 int minlen =
sc_min(nbits, v.length());
564 for (; i < minlen; ++i) {
567 for (; i < nbits; ++i) {
581 return aa.to_string(numrep);
585sc_signed::to_string(
sc_numrep numrep,
bool w_prefix)
const
589 return aa.to_string(numrep, w_prefix);
600 return operator = ((
int64)v);
607 return operator + (u,
static_cast<int64>(v));
613 return operator + (
static_cast<int64>(u), v);
619 return operator + (u, (
int64)v);
625 return operator + ((
int64)u, v);
631 return operator += ((
int64)v);
638 return operator - (u, (
int64)v);
644 return operator - ((
int64)u, v);
650 return operator - (u, (
int64)v);
656 return operator - ((
int64)u, v);
662 return operator -= ((
int64)v);
669 return operator * (u,
static_cast<int64>(v));
675 return operator * (
static_cast<int64>(u), v);
681 return operator * (u, (
int64)v);
687 return operator * ((
int64)u, v);
693 return operator *= ((
int64)v);
700 return operator / (u,
static_cast<int64>(v));
706 return operator / (
static_cast<int64>(u), v);
712 return operator / (u, (
int64)v);
718 return operator / ((
int64)u, v);
724 return operator /= ((
int64)v);
731 return operator % (u,
static_cast<int64>(v));
737 return operator % (
static_cast<int64>(u), v);
743 return operator % (u, (
int64)v);
749 return operator % ((
int64)u, v);
755 return operator %= ((
int64)v);
762 return operator & (u,
static_cast<int64>(v));
768 return operator & (
static_cast<int64>(u), v);
774 return operator & (u, (
int64)v);
780 return operator & ((
int64)u, v);
786 return operator &= ((
int64)v);
793 return operator | (u,
static_cast<int64>(v));
799 return operator | (
static_cast<int64>(u), v);
805 return operator|(u, (
int64)v);
811 return operator | ((
int64)u, v);
817 return operator |= ((
int64)v);
824 return operator ^ (u,
static_cast<int64>(v));
830 return operator ^ (
static_cast<int64>(u), v);
836 return operator ^ (u, (
int64)v);
842 return operator ^ ((
int64)u, v);
848 return operator ^= ((
int64)v);
855 return operator << (u, (
int64)v);
861 return operator <<= ((
int64)v);
868 return operator >> (u, (
int64)v);
874 return operator >>= ((
int64)v);
894 return operator != (u, (
int64)v);
900 return operator != ((
int64)u, v);
907 return operator < (u, (
int64)v);
913 return operator < ((
int64)u, v);
920 return operator <= (u, (
int64)v);
926 return operator <= ((
int64)u, v);
933 return operator > (u, (
int64)v);
939 return operator > ((
int64)u, v);
946 return operator >= (u, (
int64)v);
952 return operator >= ((
int64)u, v);
963 return operator = ((
uint64)v);
970 return operator + (u, (
uint64)v);
976 return operator + ((
uint64)u, v);
982 return operator += ((
uint64)v);
989 return operator - (u, (
uint64)v);
995 return operator - ((
uint64)u, v);
1001 return operator - (u, (
uint64)v);
1007 return operator - ((
uint64)u, v);
1013 return operator -= ((
uint64)v);
1020 return operator * (u, (
uint64)v);
1026 return operator * ((
uint64)u, v);
1032 return operator *= ((
uint64)v);
1039 return operator / (u, (
uint64)v);
1045 return operator / ((
uint64)u, v);
1051 return operator /= ((
uint64)v);
1058 return operator % (u, (
uint64)v);
1064 return operator % ((
uint64)u, v);
1070 return operator %= ((
uint64)v);
1077 return operator & (u, (
uint64)v);
1083 return operator & ((
uint64)u, v);
1089 return operator &= ((
uint64)v);
1096 return operator | (u, (
uint64)v);
1102 return operator | ((
uint64)u, v);
1108 return operator |= ((
uint64)v);
1115 return operator ^ (u, (
uint64)v);
1121 return operator ^ ((
uint64)u, v);
1127 return operator ^= ((
uint64)v);
1134 return operator << (u, (
uint64)v);
1140 return operator <<= ((
uint64)v);
1147 return operator >> (u, (
uint64)v);
1153 return operator >>= ((
uint64)v);
1173 return operator != (u, (
uint64)v);
1179 return operator != ((
uint64)u, v);
1186 return operator < (u, (
uint64)v);
1192 return operator < ((
uint64)u, v);
1199 return operator <= (u, (
uint64)v);
1205 return operator <= ((
uint64)u, v);
1212 return operator > (u, (
uint64)v);
1218 return operator > ((
uint64)u, v);
1225 return operator >= (u, (
uint64)v);
1231 return operator >= ((
uint64)u, v);
1246#define CONVERT_LONG(u) \
1247small_type u ## s = get_sign(u); \
1248sc_digit u ## d[DIGITS_PER_ULONG]; \
1249from_uint(DIGITS_PER_ULONG, u ## d, (unsigned long) u);
1251#define CONVERT_LONG_2(u) \
1252sc_digit u ## d[DIGITS_PER_ULONG]; \
1253from_uint(DIGITS_PER_ULONG, u ## d, (unsigned long) u);
1255#define CONVERT_INT(u) \
1256small_type u ## s = get_sign(u); \
1257sc_digit u ## d[DIGITS_PER_UINT]; \
1258from_uint(DIGITS_PER_UINT, u ## d, (unsigned int) u);
1260#define CONVERT_INT_2(u) \
1261sc_digit u ## d[DIGITS_PER_UINT]; \
1262from_uint(DIGITS_PER_UINT, u ## d, (unsigned int) u);
1264#define CONVERT_INT64(u) \
1265small_type u ## s = get_sign(u); \
1266sc_digit u ## d[DIGITS_PER_UINT64]; \
1267from_uint(DIGITS_PER_UINT64, u ## d, (uint64) u);
1269#define CONVERT_INT64_2(u) \
1270sc_digit u ## d[DIGITS_PER_UINT64]; \
1271from_uint(DIGITS_PER_UINT64, u ## d, (uint64) u);
1304 v.sgn, v.nbits, v.ndigits, v.digit);
1319 v.sgn, v.nbits, v.ndigits, v.digit);
1334 v.sgn, v.nbits, v.ndigits, v.digit);
1368 v.sgn, v.nbits, v.ndigits, v.digit);
1402 v.sgn, v.nbits, v.ndigits, v.digit);
1436 v.sgn, v.nbits, v.ndigits, v.digit);
1470 v.sgn, v.nbits, v.ndigits, v.digit);
1504 v.sgn, v.nbits, v.ndigits, v.digit);
1538 v.sgn, v.nbits, v.ndigits, v.digit);
1574 -v.sgn, v.nbits, v.ndigits, v.digit);
1589 -v.sgn, v.nbits, v.ndigits, v.digit);
1604 -v.sgn, v.nbits, v.ndigits, v.digit);
1619 -v.sgn, v.nbits, v.ndigits, v.digit);
1653 -v.sgn, v.nbits, v.ndigits, v.digit);
1687 -v.sgn, v.nbits, v.ndigits, v.digit);
1722 -v.sgn, v.nbits, v.ndigits, v.digit);
1756 -v.sgn, v.nbits, v.ndigits, v.digit);
1790 -v.sgn, v.nbits, v.ndigits, v.digit);
1824 -v.sgn, v.nbits, v.ndigits, v.digit);
1858 -v.sgn, v.nbits, v.ndigits, v.digit);
1892 -v.sgn, v.nbits, v.ndigits, v.digit);
1919 v.nbits, v.ndigits, v.digit);
1933 v.nbits, v.ndigits, v.digit);
1947 v.nbits, v.ndigits, v.digit);
1979 v.nbits, v.ndigits, v.digit);
2011 v.nbits, v.ndigits, v.digit);
2043 v.nbits, v.ndigits, v.digit);
2075 v.nbits, v.ndigits, v.digit);
2107 v.nbits, v.ndigits, v.digit);
2138 v.nbits, v.ndigits, v.digit);
2169 v.nbits, v.ndigits, v.digit);
2185 v.nbits, v.ndigits, v.digit);
2201 v.nbits, v.ndigits, v.digit);
2237 v.nbits, v.ndigits, v.digit);
2273 v.nbits, v.ndigits, v.digit);
2310 v.nbits, v.ndigits, v.digit);
2346 v.nbits, v.ndigits, v.digit);
2382 v.nbits, v.ndigits, v.digit);
2419 v.nbits, v.ndigits, v.digit);
2448 v.nbits, v.ndigits, v.digit);
2462 v.nbits, v.ndigits, v.digit);
2476 v.nbits, v.ndigits, v.digit);
2512 v.nbits, v.ndigits, v.digit);
2548 v.nbits, v.ndigits, v.digit);
2555 if ((u.sgn ==
SC_ZERO) || (v == 0)) {
2571 if ((u == 0) || (v.sgn ==
SC_ZERO)) {
2580 v.nbits, v.ndigits, v.digit);
2616 v.nbits, v.ndigits, v.digit);
2653 v.nbits, v.ndigits, v.digit);
2660 if ((u.sgn ==
SC_ZERO) || (v == 0)) {
2676 if ((u == 0) || (v.sgn ==
SC_ZERO)) {
2685 v.nbits, v.ndigits, v.digit);
2711 v.sgn, v.nbits, v.ndigits, v.digit);
2723 v.sgn, v.nbits, v.ndigits, v.digit);
2735 v.sgn, v.nbits, v.ndigits, v.digit);
2742 if ((u.sgn ==
SC_ZERO) || (v == 0))
2756 if ((u == 0) || (v.sgn ==
SC_ZERO))
2763 v.sgn, v.nbits, v.ndigits, v.digit);
2770 if ((u.sgn ==
SC_ZERO) || (v == 0))
2784 if ((u == 0) || (v.sgn ==
SC_ZERO))
2791 v.sgn, v.nbits, v.ndigits, v.digit);
2798 if ((u.sgn ==
SC_ZERO) || (v == 0))
2812 if ((u == 0) || (v.sgn ==
SC_ZERO))
2819 v.sgn, v.nbits, v.ndigits, v.digit);
2826 if ((u.sgn ==
SC_ZERO) || (v == 0))
2840 if ((u == 0) || (v.sgn ==
SC_ZERO))
2847 v.sgn, v.nbits, v.ndigits, v.digit);
2854 if ((u.sgn ==
SC_ZERO) || (v == 0))
2868 if ((u == 0) || (v.sgn ==
SC_ZERO))
2875 v.sgn, v.nbits, v.ndigits, v.digit);
2882 if ((u.sgn ==
SC_ZERO) || (v == 0))
2896 if ((u == 0) || (v.sgn ==
SC_ZERO))
2903 v.sgn, v.nbits, v.ndigits, v.digit);
2933 v.sgn, v.nbits, v.ndigits, v.digit);
2948 v.sgn, v.nbits, v.ndigits, v.digit);
2963 v.sgn, v.nbits, v.ndigits, v.digit);
2997 v.sgn, v.nbits, v.ndigits, v.digit);
3031 v.sgn, v.nbits, v.ndigits, v.digit);
3065 v.sgn, v.nbits, v.ndigits, v.digit);
3099 v.sgn, v.nbits, v.ndigits, v.digit);
3133 v.sgn, v.nbits, v.ndigits, v.digit);
3167 v.sgn, v.nbits, v.ndigits, v.digit);
3199 v.sgn, v.nbits, v.ndigits, v.digit);
3215 v.sgn, v.nbits, v.ndigits, v.digit);
3230 v.sgn, v.nbits, v.ndigits, v.digit);
3264 v.sgn, v.nbits, v.ndigits, v.digit);
3298 v.sgn, v.nbits, v.ndigits, v.digit);
3331 v.sgn, v.nbits, v.ndigits, v.digit);
3365 v.sgn, v.nbits, v.ndigits, v.digit);
3399 v.sgn, v.nbits, v.ndigits, v.digit);
3432 v.sgn, v.nbits, v.ndigits, v.digit);
3456 return operator << (u, v.to_ulong());
3473 return operator >> (u, v.to_ulong());
3671 }
else if (u.sgn ==
SC_NEG) {
3696 }
else if (vs ==
SC_NEG) {
3721 }
else if (us ==
SC_NEG) {
3791 }
else if (vs ==
SC_NEG) {
3816 }
else if (us ==
SC_NEG) {
3826operator < (
const sc_signed &u,
unsigned long v)
3848operator < (
unsigned long u,
const sc_signed &v)
3895sc_signed::iszero()
const
3907sc_signed::sign()
const
3926#define CLASS_TYPE sc_signed
3927#define CLASS_TYPE_STR "sc_signed"
3929#define ADD_HELPER add_signed_friend
3930#define SUB_HELPER sub_signed_friend
3931#define MUL_HELPER mul_signed_friend
3932#define DIV_HELPER div_signed_friend
3933#define MOD_HELPER mod_signed_friend
3934#define AND_HELPER and_signed_friend
3935#define OR_HELPER or_signed_friend
3936#define XOR_HELPER xor_signed_friend
3938#include "sc_nbfriends.inc"
3942#define IF_SC_SIGNED 1
3943#define CLASS_TYPE_SUBREF sc_signed_subref_r
3944#define OTHER_CLASS_TYPE sc_unsigned
3945#define OTHER_CLASS_TYPE_SUBREF sc_unsigned_subref_r
3947#define MUL_ON_HELPER mul_on_help_signed
3948#define DIV_ON_HELPER div_on_help_signed
3949#define MOD_ON_HELPER mod_on_help_signed
3951#include "sc_nbcommon.inc"
3957#undef OTHER_CLASS_TYPE_SUBREF
3958#undef OTHER_CLASS_TYPE
3959#undef CLASS_TYPE_SUBREF
3973#undef CLASS_TYPE_STR
3975#include "sc_signed_bitref.inc"
3976#include "sc_signed_subref.inc"
3979#undef CONVERT_LONG_2
3981#undef CONVERT_INT64_2
bool operator==(const arr_struct1 &, const arr_struct1 &)
const char SC_ID_CONVERSION_FAILED_[]
const char SC_ID_INIT_FAILED_[]
const char SC_ID_OUT_OF_BOUNDS_[]
sc_signed xor_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
sc_signed and_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
int vec_skip_and_cmp(int ulen, const sc_digit *u, int vlen, const sc_digit *v)
sc_signed add_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
small_type get_sign(Type &u)
void from_uint(int ulen, sc_digit *u, Type v)
sc_signed div_signed_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
const T sc_min(const T &a, const T &b)
void safe_set(int i, bool v, sc_digit *d)
void is_bad_double(double v)
sc_signed mul_signed_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
small_type check_for_zero(small_type s, int ulen, const sc_digit *u)
small_type mul_signs(small_type us, small_type vs)
void vec_zero(int from, int ulen, sc_digit *u)
sc_signed mod_signed_friend(small_type us, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
sc_signed or_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
sc_digit one_and_zeros(int n)
#define DIGITS_PER_UINT64
#define SC_REPORT_ERROR(msg_type, msg)
#define CONVERT_INT64_2(u)
#define CONVERT_LONG_2(u)