99template class sc_vpool<sc_dt::sc_unsigned_bitref>;
100template class sc_vpool<sc_dt::sc_unsigned_subref>;
101template class sc_vpool<sc_dt::sc_unsigned>;
120 std::stringstream msg;
121 msg <<
"sc_unsigned("<< type_name <<
") : nb = " << nb <<
" is not valid";
133 std::stringstream msg;
134 msg <<
"sc_biguint bit selection: index = " << i <<
" violates "
135 "0 <= index <= " << (
nbits-2);
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)";
184 mask = ~(~0U << left_shift);
185 dst_p[dst_i] = (dst_p[dst_i] & ~mask);
188 for (; dst_i <= end_i; dst_i++)
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];
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++) {
247 dst_p[dst_i] = ((left_word << left_shift) &
DIGIT_MASK) |
248 (right_word >> right_shift);
249 right_word = left_word;
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++) {
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++) {
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++) {
364 *
this = (low_i < 64) ? src >> low_i : src >> 63;
371 *
this = src >> low_i;
373 *
this = (src < 0) ? (
int_type)-1 : 0;
380 *
this = src >> low_i;
388 *
this = (low_i < 64) ? src >> low_i : 0;
403 for (i = 0; i <
ndigits - 1; i++)
426 for (i = 0; i <
nbits - 1; i++)
429 return odd ? true :
false;
443 "character string is zero");
444 }
else if (*
a == 0) {
446 "character string is empty");
452 std::stringstream msg;
453 msg <<
"character string '" <<
a <<
"' is not valid";
519 while (std::floor(v) && (i <
ndigits)) {
537 for (; i < minlen; ++i) {
540 for (; i <
nbits; ++i) {
552 for (; i < minlen; ++i) {
555 for (; i <
nbits; ++i) {
569 return aa.to_string(numrep);
577 return aa.to_string(numrep, w_prefix);
653 return operator >> (u, (
int64)v);
675 return operator != (u, (
int64)v);
680 return operator != ((
int64)u, v);
686 return operator < (u, (
int64)v);
691 return operator < ((
int64)u, v);
697 return operator <= (u, (
int64)v);
702 return operator <= ((
int64)u, v);
708 return operator > (u, (
int64)v);
713 return operator > ((
int64)u, v);
719 return operator >= (u, (
int64)v);
724 return operator >= ((
int64)u, v);
741 return operator + (u, (
uint64)v);
746 return operator + ((
uint64)u, v);
763 return operator * (u, (
uint64)v);
768 return operator * ((
uint64)u, v);
779 return operator / (u, (
uint64)v);
784 return operator / ((
uint64)u, v);
795 return operator % (u, (
uint64)v);
800 return operator % ((
uint64)u, v);
811 return operator & (u, (
uint64)v);
816 return operator & ((
uint64)u, v);
827 return operator | (u, (
uint64)v);
832 return operator | ((
uint64)u, v);
843 return operator ^ (u, (
uint64)v);
848 return operator ^ ((
uint64)u, v);
870 return operator >> (u, (
uint64)v);
892 return operator != (u, (
uint64)v);
897 return operator != ((
uint64)u, v);
903 return operator < (u, (
uint64)v);
908 return operator < ((
uint64)u, v);
914 return operator <= (u, (
uint64)v);
919 return operator <= ((
uint64)u, v);
925 return operator > (u, (
uint64)v);
930 return operator > ((
uint64)u, v);
936 return operator >= (u, (
uint64)v);
941 return operator >= ((
uint64)u, v);
956#define CONVERT_LONG(u) \
957small_type u ## s = get_sign(u); \
958sc_digit u ## d[DIGITS_PER_ULONG]; \
959from_uint(DIGITS_PER_ULONG, u ## d, (unsigned long) u);
961#define CONVERT_LONG_2(u) \
962sc_digit u ## d[DIGITS_PER_ULONG]; \
963from_uint(DIGITS_PER_ULONG, u ## d, (unsigned long) u);
965#define CONVERT_INT(u) \
966small_type u ## s = get_sign(u); \
967sc_digit u ## d[DIGITS_PER_UINT]; \
968from_uint(DIGITS_PER_UINT, u ## d, (unsigned int) u);
970#define CONVERT_INT_2(u) \
971sc_digit u ## d[DIGITS_PER_UINT]; \
972from_uint(DIGITS_PER_UINT, u ## d, (unsigned int) u);
974#define CONVERT_INT64(u) \
975small_type u ## s = get_sign(u); \
976sc_digit u ## d[DIGITS_PER_UINT64]; \
977from_uint(DIGITS_PER_UINT64, u ## d, (uint64) u);
979#define CONVERT_INT64_2(u) \
980sc_digit u ## d[DIGITS_PER_UINT64]; \
981from_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);
1335 if ((u.sgn ==
SC_ZERO) || (v == 0)) {
1352 if ((u == 0) || (v.sgn ==
SC_ZERO)) {
1361 v.nbits, v.ndigits, v.digit);
1368 if ((u.sgn ==
SC_ZERO) || (v == 0)) {
1384 if ((u == 0) || (v.sgn ==
SC_ZERO)) {
1393 v.nbits, v.ndigits, v.digit);
1419 v.sgn, v.nbits, v.ndigits, v.digit);
1426 if ((u.sgn ==
SC_ZERO) || (v == 0))
1440 if ((u == 0) || (v.sgn ==
SC_ZERO))
1447 v.sgn, v.nbits, v.ndigits, v.digit);
1454 if ((u.sgn ==
SC_ZERO) || (v == 0))
1468 if ((u == 0) || (v.sgn ==
SC_ZERO))
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);
1712 return operator >> (u, v.to_long());
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);
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
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"
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
2259#undef CONVERT_INT64_2
bool operator==(const arr_struct1 &, const arr_struct1 &)
sc_signed(int nb=sc_length_param().len())
static sc_core::sc_vpool< sc_unsigned_bitref > m_pool
static sc_core::sc_vpool< sc_unsigned_subref > m_pool
friend sc_unsigned div_unsigned_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
friend 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)
friend sc_unsigned mul_unsigned_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
sc_unsigned(int nb=sc_length_param().len())
friend 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)
friend sc_unsigned mod_unsigned_friend(small_type us, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
friend 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)
friend 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)
friend 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)
const sc_unsigned & operator>>=(const sc_signed &v)
virtual uint64 concat_get_uint64() const
const sc_unsigned & operator&=(const sc_signed &v)
const sc_unsigned & operator<<=(const sc_signed &v)
void invalid_init(const char *type_name, int nb) const
virtual bool concat_get_data(sc_digit *dst_p, int low_i) const
const sc_unsigned & operator+=(const sc_signed &v)
void invalid_range(int l, int r) const
const sc_unsigned & operator-=(const sc_signed &v)
static sc_core::sc_vpool< sc_unsigned > m_pool
void invalid_index(int i) const
const sc_unsigned & operator%=(const sc_signed &v)
void convert_SM_to_2C_to_SM()
const sc_unsigned & operator=(const sc_unsigned &v)
const sc_unsigned & operator/=(const sc_signed &v)
const sc_unsigned & operator^=(const sc_signed &v)
const std::string to_string(sc_numrep numrep=SC_DEC) const
const sc_unsigned & operator*=(const sc_signed &v)
virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const
const sc_unsigned & operator|=(const sc_signed &v)
virtual void concat_set(int64 src, int low_i)
const char SC_ID_CONVERSION_FAILED_[]
const char SC_ID_INIT_FAILED_[]
const char SC_ID_OUT_OF_BOUNDS_[]
int vec_skip_and_cmp(int ulen, const sc_digit *u, int vlen, const sc_digit *v)
small_type get_sign(Type &u)
void from_uint(int ulen, sc_digit *u, Type v)
void vec_copy(int n, sc_digit *u, const sc_digit *v)
void safe_set(int i, bool v, sc_digit *d)
void is_bad_double(double v)
small_type check_for_zero(small_type s, int ulen, const sc_digit *u)
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 vec_complement(int ulen, sc_digit *u)
small_type mul_signs(small_type us, small_type vs)
void vec_zero(int from, int ulen, sc_digit *u)
void trim(small_type added, int nb, int nd, sc_digit *d)
void trim_unsigned(int nb, int nd, sc_digit *d)
std::ostream & operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm)
#define DIGITS_PER_UINT64
#define SC_REPORT_ERROR(msg_type, msg)
#define CONVERT_INT64_2(u)
#define CONVERT_LONG_2(u)
const T sc_min(const T &a, const T &b)