Go to the documentation of this file.
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) ?
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++) {
296 left_word = (digit[src_i] ^
DIGIT_MASK) + carry;
297 dst_p[dst_i] = ((left_word << left_shift)&
DIGIT_MASK) |
298 (right_word >> right_shift);
302 left_word = (src_i < ndigits) ?
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++)
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)
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();
535 int minlen =
sc_min(nbits,
v.length());
537 for (;
i < minlen; ++
i) {
540 for (;
i < nbits; ++
i) {
550 int minlen =
sc_min(nbits,
v.length());
552 for (;
i < minlen; ++
i) {
555 for (;
i < nbits; ++
i) {
569 return aa.to_string(numrep);
577 return aa.to_string(numrep, w_prefix);
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);
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);
1014 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1048 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1082 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1131 v.nbits,
v.ndigits,
v.digit);
1163 v.nbits,
v.ndigits,
v.digit);
1194 v.nbits,
v.ndigits,
v.digit);
1225 v.nbits,
v.ndigits,
v.digit);
1262 v.nbits,
v.ndigits,
v.digit);
1299 v.nbits,
v.ndigits,
v.digit);
1328 v.nbits,
v.ndigits,
v.digit);
1361 v.nbits,
v.ndigits,
v.digit);
1393 v.nbits,
v.ndigits,
v.digit);
1419 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1447 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1475 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1505 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1539 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1573 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1604 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1637 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1670 v.sgn,
v.nbits,
v.ndigits,
v.digit);
1741 v.sgn,
v.nbits,
v.ndigits,
v.digit) != 0) {
1754 v.sgn,
v.nbits,
v.ndigits,
v.digit, 0, 1) != 0) {
1767 v.sgn,
v.nbits,
v.ndigits,
v.digit, 1, 0) != 0) {
1795 v.sgn,
v.nbits,
v.ndigits,
v.digit) != 0) {
1818 v.sgn,
v.nbits,
v.ndigits,
v.digit) != 0)
1844 v.sgn,
v.nbits,
v.ndigits,
v.digit) != 0)
1866 v.sgn,
v.nbits,
v.ndigits,
v.digit) != 0)
1879 return (!
operator == (
u,
v));
1886 return (!
operator == (
u,
v));
1902 v.sgn,
v.nbits,
v.ndigits,
v.digit) < 0) {
1915 v.sgn,
v.nbits,
v.ndigits,
v.digit, 0, 1) < 0) {
1928 v.sgn,
v.nbits,
v.ndigits,
v.digit, 1, 0) < 0) {
1956 v.sgn,
v.nbits,
v.ndigits,
v.digit) < 0) {
1980 v.sgn,
v.nbits,
v.ndigits,
v.digit) < 0){
2008 v.sgn,
v.nbits,
v.ndigits,
v.digit) < 0) {
2032 v.sgn,
v.nbits,
v.ndigits,
v.digit) < 0) {
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
sc_unsigned operator+(const sc_unsigned &u)
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
const char SC_ID_INIT_FAILED_[]
sc_unsigned operator&(unsigned long u, const sc_unsigned &v)
void vec_zero(int from, int ulen, sc_digit *u)
small_type check_for_zero(small_type s, int ulen, const sc_digit *u)
const std::string to_string(sc_enc enc)
small_type get_sign(Type &u)
sc_unsigned operator*(unsigned long u, const sc_unsigned &v)
const char SC_ID_CONVERSION_FAILED_[]
sc_unsigned mul_unsigned_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
#define CONVERT_LONG_2(u)
small_type mul_signs(small_type us, small_type vs)
sc_unsigned operator>>(const sc_unsigned &u, const sc_signed &v)
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
bool operator<=(const sc_signed &u, const sc_unsigned &v)
void safe_set(int i, bool v, sc_digit *d)
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
sc_unsigned operator^(unsigned long u, const sc_unsigned &v)
sc_unsigned operator%(unsigned long u, const sc_unsigned &v)
sc_unsigned operator<<(const sc_unsigned &u, const sc_signed &v)
bool operator>(const sc_signed &u, const sc_unsigned &v)
#define DIGITS_PER_UINT64
bool operator!=(const sc_signed &u, const sc_unsigned &v)
void trim_unsigned(int nb, int nd, sc_digit *d)
bool operator<(unsigned long u, const sc_unsigned &v)
void trim(small_type added, int nb, int nd, sc_digit *d)
#define SC_REPORT_ERROR(msg_type, msg)
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 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)
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)
#define CONVERT_INT64_2(u)
bool operator>=(const sc_signed &u, const sc_unsigned &v)
const T sc_min(const T &a, const T &b)
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)
int vec_skip_and_cmp(int ulen, const sc_digit *u, int vlen, const sc_digit *v)
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_unsigned operator|(unsigned long u, const sc_unsigned &v)
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)
void from_uint(int ulen, sc_digit *u, Type v)
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
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)
void vec_copy(int n, sc_digit *u, const sc_digit *v)
const char SC_ID_OUT_OF_BOUNDS_[]
bool operator==(unsigned long u, const sc_unsigned &v)
void is_bad_double(double v)
void vec_complement(int ulen, sc_digit *u)
sc_unsigned operator/(unsigned long u, const sc_unsigned &v)
Generated on Wed Sep 30 2020 14:02:15 for gem5 by doxygen 1.8.17