99 template class sc_vpool<sc_dt::sc_unsigned_bitref>;
100 template class sc_vpool<sc_dt::sc_unsigned_subref>;
101 template class sc_vpool<sc_dt::sc_unsigned>;
118 sc_unsigned::invalid_init(
const char *type_name,
int nb)
const 120 std::stringstream msg;
121 msg <<
"sc_unsigned("<< type_name <<
") : nb = " << nb <<
" is not valid";
131 sc_unsigned::invalid_index(
int i)
const 133 std::stringstream msg;
134 msg <<
"sc_biguint bit selection: index = " << i <<
" violates " 135 "0 <= index <= " << (nbits-2);
141 sc_unsigned::invalid_range(
int l,
int r)
const 143 std::stringstream msg;
144 msg <<
"sc_biguint part selection: left = " <<
145 l <<
", right = " << r <<
" \n" 146 " violates either (" << (nbits - 2) <<
" >= left >= 0) or " 147 "(" << (nbits-2) <<
" >= right >= 0)";
166 sc_unsigned::concat_get_ctrl(
sc_digit *dst_p,
int low_i)
const 184 mask = ~(~0U << left_shift);
185 dst_p[dst_i] = (dst_p[dst_i] & ~mask);
188 for (; dst_i <= end_i; dst_i++)
195 sc_unsigned::concat_get_data(
sc_digit *dst_p,
int low_i)
const 211 real_bits = nbits - 1;
213 high_i = low_i + real_bits - 1;
223 if (dst_i == end_i) {
224 mask = ~(~0U << left_shift);
225 dst_p[dst_i] = ((dst_p[dst_i] &
mask) |
229 }
else if (left_shift == 0) {
230 for (src_i = 0; dst_i < end_i; dst_i++, src_i++) {
231 dst_p[dst_i] = digit[src_i];
235 dst_p[dst_i] = digit[src_i] &
mask;
241 mask = ~(~0U << left_shift);
242 right_word = digit[0];
243 dst_p[dst_i] = (dst_p[dst_i] &
mask) |
245 for (src_i = 1, dst_i++; dst_i < end_i; dst_i++, src_i++) {
246 left_word = digit[src_i];
247 dst_p[dst_i] = ((left_word << left_shift) &
DIGIT_MASK) |
248 (right_word >> right_shift);
249 right_word = left_word;
251 left_word = (src_i < ndigits) ? digit[src_i] : 0;
253 dst_p[dst_i] = ((left_word << left_shift) |
254 (right_word >> right_shift)) & mask;
262 if (dst_i == end_i) {
263 mask = ~(~0U << nbits);
265 mask = ~(~0U << left_shift);
266 dst_p[dst_i] = ((dst_p[dst_i] &
mask) |
271 }
else if (left_shift == 0) {
273 for (src_i = 0; dst_i < end_i; dst_i++, src_i++) {
274 right_word = (digit[src_i] ^
DIGIT_MASK) + carry;
280 right_word = (src_i < ndigits) ?
281 (digit[src_i] ^
DIGIT_MASK) + carry : DIGIT_MASK + carry;
282 dst_p[dst_i] = right_word &
mask;
288 mask = ~(~0U << left_shift);
291 dst_p[dst_i] = (dst_p[dst_i] &
mask) |
295 for (src_i = 1, dst_i++; dst_i < end_i; dst_i++, src_i++) {
297 dst_p[dst_i] = ((left_word << left_shift)&
DIGIT_MASK) |
298 (right_word >> right_shift);
302 left_word = (src_i < ndigits) ?
304 mask = ~(~1U << high_i) & DIGIT_MASK;
305 dst_p[dst_i] = ((left_word << left_shift) |
306 (right_word >> right_shift)) & mask;
313 if (dst_i == end_i) {
314 mask = ~(~0U << real_bits) << left_shift;
315 dst_p[dst_i] = dst_p[dst_i] & ~mask;
319 }
else if (left_shift == 0) {
320 for (src_i = 0; dst_i < end_i; dst_i++, src_i++) {
327 mask = ~(~0U << left_shift);
328 dst_p[dst_i] = (dst_p[dst_i] &
mask);
329 for (dst_i++; dst_i <= end_i; dst_i++) {
340 sc_unsigned::concat_get_uint64()
const 362 sc_unsigned::concat_set(
int64 src,
int low_i)
364 *
this = (low_i < 64) ? src >> low_i : src >> 63;
368 sc_unsigned::concat_set(
const sc_signed &src,
int low_i)
371 *
this = src >> low_i;
373 *
this = (src < 0) ? (
int_type)-1 : 0;
380 *
this = src >> low_i;
386 sc_unsigned::concat_set(
uint64 src,
int low_i)
388 *
this = (low_i < 64) ? src >> low_i : 0;
403 for (i = 0; i < ndigits - 1; i++)
406 if ((digit[i] & ~(~0U << ((nbits - 1) % BITS_PER_DIGIT))) ==
407 static_cast<sc_digit>(~(~0U << ((nbits - 1) % BITS_PER_DIGIT)))) {
416 return (sgn ==
SC_ZERO) ? false :
true;
426 for (i = 0; i < nbits - 1; i++)
429 return odd ? true :
false;
439 sc_unsigned::operator = (
const char *
a)
443 "character string is zero");
444 }
else if (*a == 0) {
446 "character string is empty");
450 return this->operator = (aa);
452 std::stringstream msg;
453 msg <<
"character string '" << a <<
"' is not valid";
467 convert_SM_to_2C_to_SM();
481 convert_SM_to_2C_to_SM();
487 sc_unsigned::operator = (
long v)
493 from_uint(ndigits, digit, (
unsigned long)v);
494 convert_SM_to_2C_to_SM();
500 sc_unsigned::operator = (
unsigned long v)
508 convert_SM_to_2C_to_SM();
514 sc_unsigned::operator = (
double v)
519 while (std::floor(v) && (i < ndigits)) {
525 convert_SM_to_2C_to_SM();
537 for (; i < minlen; ++
i) {
540 for (; i < nbits; ++
i) {
552 for (; i < minlen; ++
i) {
555 for (; i < nbits; ++
i) {
588 return operator = ((
int64)v);
594 return operator += ((
int64)v);
600 return operator -= ((
int64)v);
606 return operator *= ((
int64)v);
612 return operator /= ((
int64)v);
618 return operator %= ((
int64)v);
647 return operator <<= ((
int64)v);
658 return operator >>= ((
int64)v);
735 return operator = ((
uint64)v);
751 return operator += ((
uint64)v);
757 return operator -= ((
uint64)v);
773 return operator *= ((
uint64)v);
789 return operator /= ((
uint64)v);
805 return operator %= ((
uint64)v);
864 return operator <<= ((
uint64)v);
875 return operator >>= ((
uint64)v);
956 #define CONVERT_LONG(u) \ 957 small_type u ## s = get_sign(u); \ 958 sc_digit u ## d[DIGITS_PER_ULONG]; \ 959 from_uint(DIGITS_PER_ULONG, u ## d, (unsigned long) u); 961 #define CONVERT_LONG_2(u) \ 962 sc_digit u ## d[DIGITS_PER_ULONG]; \ 963 from_uint(DIGITS_PER_ULONG, u ## d, (unsigned long) u); 965 #define CONVERT_INT(u) \ 966 small_type u ## s = get_sign(u); \ 967 sc_digit u ## d[DIGITS_PER_UINT]; \ 968 from_uint(DIGITS_PER_UINT, u ## d, (unsigned int) u); 970 #define CONVERT_INT_2(u) \ 971 sc_digit u ## d[DIGITS_PER_UINT]; \ 972 from_uint(DIGITS_PER_UINT, u ## d, (unsigned int) u); 974 #define CONVERT_INT64(u) \ 975 small_type u ## s = get_sign(u); \ 976 sc_digit u ## d[DIGITS_PER_UINT64]; \ 977 from_uint(DIGITS_PER_UINT64, u ## d, (uint64) u); 979 #define CONVERT_INT64_2(u) \ 980 sc_digit u ## d[DIGITS_PER_UINT64]; \ 981 from_uint(DIGITS_PER_UINT64, u ## d, (uint64) u); 1879 return (!
operator == (u, v));
1886 return (!
operator == (u, v));
2046 return (
operator < (u, v) ||
operator == (u, v));
2053 return (
operator < (u, v) ||
operator == (u, v));
2066 return (!(
operator <= (u, v)));
2073 return (!(
operator <= (u, v)));
2086 return (!(
operator < (u, v)));
2093 return (!(
operator < (u, v)));
2130 int nd = (us ==
SC_NEG ? und : vnd);
2141 trim(if_u_signed, unb, nd, d);
2146 trim(if_v_signed, vnb, nd, d);
2150 #ifndef SC_MAX_NBITS 2164 sc_unsigned::iszero()
const 2168 }
else if (sgn ==
SC_NEG) {
2184 #ifndef SC_MAX_NBITS 2204 #define CLASS_TYPE sc_unsigned 2205 #define CLASS_TYPE_STR "sc_unsigned" 2207 #define ADD_HELPER add_unsigned_friend 2208 #define SUB_HELPER sub_unsigned_friend 2209 #define MUL_HELPER mul_unsigned_friend 2210 #define DIV_HELPER div_unsigned_friend 2211 #define MOD_HELPER mod_unsigned_friend 2212 #define AND_HELPER and_unsigned_friend 2213 #define OR_HELPER or_unsigned_friend 2214 #define XOR_HELPER xor_unsigned_friend 2216 #include "sc_nbfriends.inc" 2220 #define IF_SC_SIGNED 0 // 0 = sc_unsigned 2221 #define CLASS_TYPE_SUBREF sc_unsigned_subref_r 2222 #define OTHER_CLASS_TYPE sc_signed 2223 #define OTHER_CLASS_TYPE_SUBREF sc_signed_subref_r 2225 #define MUL_ON_HELPER mul_on_help_unsigned 2226 #define DIV_ON_HELPER div_on_help_unsigned 2227 #define MOD_ON_HELPER mod_on_help_unsigned 2229 #include "sc_nbcommon.inc" 2231 #undef MOD_ON_HELPER 2232 #undef DIV_ON_HELPER 2233 #undef MUL_ON_HELPER 2235 #undef OTHER_CLASS_TYPE_SUBREF 2236 #undef OTHER_CLASS_TYPE 2237 #undef CLASS_TYPE_SUBREF 2251 #undef CLASS_TYPE_STR 2253 #include "sc_unsigned_bitref.inc" 2254 #include "sc_unsigned_subref.inc" 2257 #undef CONVERT_LONG_2 2258 #undef CONVERT_INT64 2259 #undef CONVERT_INT64_2 int compare_unsigned(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd, small_type if_u_signed, small_type if_v_signed)
void is_bad_double(double v)
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
const char SC_ID_CONVERSION_FAILED_[]
void trim_unsigned(int nb, int nd, sc_digit *d)
bool to_bool(const std::string &value, bool &retval)
Turn a string representation of a boolean into a boolean value.
sc_event_and_expr operator&(sc_event_and_expr expr, sc_event const &e)
void vec_copy(int n, sc_digit *u, const sc_digit *v)
small_type check_for_zero(small_type s, int ulen, const sc_digit *u)
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
const sc_time operator/(const sc_time &t, double d)
#define DIGITS_PER_UINT64
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
bool operator<=(const sc_signed &u, const sc_unsigned &v)
bool operator<(unsigned long u, const sc_unsigned &v)
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
const T sc_min(const T &a, const T &b)
std::ostream & operator<<(std::ostream &os, sc_status s)
#define CONVERT_LONG_2(u)
unsigned long to_ulong() const
const std::string to_string() const
void vec_zero(int from, int ulen, sc_digit *u)
int vec_skip_and_cmp(int ulen, const sc_digit *u, int vlen, const sc_digit *v)
sc_unsigned operator%(unsigned long u, const sc_unsigned &v)
sc_unsigned xor_unsigned_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
bool operator>(const sc_signed &u, const sc_unsigned &v)
small_type mul_signs(small_type us, small_type vs)
sc_unsigned operator>>(const sc_unsigned &u, const sc_signed &v)
sc_unsigned operator^(unsigned long u, const sc_unsigned &v)
const char SC_ID_OUT_OF_BOUNDS_[]
sc_unsigned mod_unsigned_friend(small_type us, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
void vec_complement(int ulen, sc_digit *u)
value_type get_bit(int i) const
#define CONVERT_INT64_2(u)
value_type get_bit(int i) const
sc_unsigned add_unsigned_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
sc_unsigned or_unsigned_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
sc_event_or_expr operator|(sc_event_or_expr expr, sc_event const &e)
bool operator>=(const sc_signed &u, const sc_unsigned &v)
const char SC_ID_INIT_FAILED_[]
const sc_time operator*(const sc_time &t, double d)
bool operator!=(const sc_signed &u, const sc_unsigned &v)
sc_unsigned div_unsigned_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
sc_unsigned and_unsigned_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
#define SC_REPORT_ERROR(msg_type, msg)
const sc_time operator+(const sc_time &a, const sc_time &b)
sc_unsigned mul_unsigned_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
void from_uint(int ulen, sc_digit *u, Type v)
void safe_set(int i, bool v, sc_digit *d)
small_type get_sign(Type &u)
const std::string to_string(sc_enc enc)
void trim(small_type added, int nb, int nd, sc_digit *d)
bool operator==(unsigned long u, const sc_unsigned &v)