63#ifndef __SYSTEMC_EXT_DT_INT_SC_NBUTILS_HH__
64#define __SYSTEMC_EXT_DT_INT_SC_NBUTILS_HH__
95 std::ios::fmtflags
flags = os.flags() & std::ios::basefield;
105 return (os.flags() & ::std::ios::showbase) != 0;
110inline ::std::ostream &
125 const char *src_p,
int dst_n, sc_digit *data_p, sc_digit *ctrl_p=0);
129 const char *src_p,
int dst_n, sc_digit *data_p, sc_digit *ctrl_p=0);
138 const char *v, sc_numrep base=SC_NOBASE);
155extern void vec_add(
int ulen,
const sc_digit *u,
156 int vlen,
const sc_digit *v, sc_digit *w);
157extern void vec_add_on(
int ulen, sc_digit *u,
int vlen,
const sc_digit *v);
158extern void vec_add_on2(
int ulen, sc_digit *u,
int vlen,
const sc_digit *v);
160 sc_digit v, sc_digit *w);
167extern void vec_sub(
int ulen,
const sc_digit *u,
168 int vlen,
const sc_digit *v, sc_digit *w);
169extern void vec_sub_on(
int ulen, sc_digit *u,
int vlen,
const sc_digit *v);
170extern void vec_sub_on2(
int ulen, sc_digit *u,
int vlen,
const sc_digit *v);
172 sc_digit v, sc_digit *w);
180extern void vec_mul(
int ulen,
const sc_digit *u,
181 int vlen,
const sc_digit *v, sc_digit *w);
183 sc_digit v, sc_digit *w);
192 int vlen,
const sc_digit *v, sc_digit *w);
194 sc_digit v, sc_digit *w);
202 int vlen,
const sc_digit *v, sc_digit *w);
203extern sc_digit
vec_rem_small(
int ulen,
const sc_digit *u, sc_digit v);
220extern void vec_shift_right(
int vlen, sc_digit *u,
int nsr, sc_digit fill=0);
221extern void vec_reverse(
int unb,
int und, sc_digit *ud,
int l,
int r=0);
296 sc_assert((ulen <= 0) || (u[ulen - 1] != 0));
297 sc_assert((vlen <= 0) || (v[vlen - 1] != 0));
301 return (ulen - vlen);
304 while ((--ulen >= 0) && (u[ulen] == v[ulen]))
316 return (
int)(u[ulen] - v[ulen]);
332 while ((--ulen >= 0) && (! u[ulen]))
368 return vec_cmp(ulen, u, vlen, v);
378 for (
int i = from; i < ulen; i++)
390 sc_assert((n > 0) && (u != NULL) && (v != NULL));
392 for (
int i = 0; i < n; ++i)
422 for (
int i = 0; i < ulen; ++i) {
448 while (v && (i < ulen)) {
456# define SC_LIKELY_(x) !!(x)
458# define SC_LIKELY_(x) __builtin_expect(!!(x), 1)
475 if (
SC_LIKELY_(u > (std::numeric_limits<Type>::min)()))
507void test_bound_failed(
int nb);
512 if (nb > SC_MAX_NBITS) {
513 test_bound_failed(nb);
526 "div_by_zero<Type>(Type) : division by zero");
591 sc_assert((nb > 0) && (nd > 0) && (d != NULL));
604 trim(added, nb, nd, d);
628 sc_assert((nb > 0) && (nd > 0) && (d != NULL));
640 sc_assert((nb > 0) && (nd > 0) && (d != NULL));
703 sc_assert((nb > 0) && (nd > 0) && (d != NULL));
755 int vnb,
int vnd,
const sc_digit *vd)
812 return std::numeric_limits<double>::has_quiet_NaN && (v != v);
818 return v == std::numeric_limits<double>::infinity() ||
819 v == -std::numeric_limits<double>::infinity();
828 "is_bad_double(double v) : "
829 "v is not finite - NaN or Inf");
const char SC_ID_VALUE_NOT_VALID_[]
const char SC_ID_OPERATION_FAILED_[]
sc_digit vec_rem_small(int ulen, const sc_digit *u, sc_digit v)
void vec_sub_on2(int ulen, sc_digit *ubegin, int vlen, const sc_digit *v)
small_type convert_signed_2C_to_SM(int nb, int nd, sc_digit *d)
int vec_find_first_nonzero(int ulen, const sc_digit *u)
sc_digit high_half(sc_digit d)
void copy_digits_unsigned(small_type &us, int unb, int und, sc_digit *ud, int, int vnd, const sc_digit *vd)
void vec_copy_and_zero(int ulen, sc_digit *u, int vlen, const sc_digit *v)
void vec_add_on(int ulen, sc_digit *ubegin, int vlen, const sc_digit *v)
void vec_add_on2(int ulen, sc_digit *ubegin, int, const sc_digit *v)
void convert_SM_to_2C_trimmed(small_type added, small_type s, int nb, int nd, sc_digit *d)
sc_digit one_and_ones(int n)
sc_digit vec_rem_on_small(int ulen, sc_digit *u, sc_digit v)
void vec_div_small(int ulen, const sc_digit *u, sc_digit v, sc_digit *q)
void convert_unsigned_SM_to_2C_trimmed(small_type s, int nb, int nd, sc_digit *d)
sc_digit high_half_masked(sc_digit d)
sc_numrep sc_io_base(::std::ostream &os, sc_numrep def_base)
void vec_sub_on(int ulen, sc_digit *ubegin, int vlen, const sc_digit *v)
int vec_cmp(int ulen, const sc_digit *u, int vlen, const sc_digit *v)
void vec_shift_right(int ulen, sc_digit *u, int nsr, sc_digit fill)
int vec_skip_and_cmp(int ulen, const sc_digit *u, int vlen, const sc_digit *v)
void vec_reverse(int unb, int und, sc_digit *ud, int l, int r)
const char * get_base_and_sign(const char *v, small_type &b, small_type &s)
void convert_signed_SM_to_2C(small_type s, int nd, sc_digit *d)
void vec_add(int ulen, const sc_digit *u, int vlen, const sc_digit *v, sc_digit *w)
small_type convert_unsigned_2C_to_SM(int nb, int nd, sc_digit *d)
void vec_sub_small_on(int ulen, sc_digit *u, sc_digit v)
small_type get_sign(Type &u)
void from_uint(int ulen, sc_digit *u, Type v)
small_type convert_unsigned_SM_to_2C_to_SM(small_type s, int nb, int nd, sc_digit *d)
small_type convert_signed_SM_to_2C_to_SM(small_type s, int nb, int nd, sc_digit *d)
small_type make_zero(int nd, sc_digit *d)
void vec_add_small(int ulen, const sc_digit *u, sc_digit v, sc_digit *w)
void vec_div_large(int ulen, const sc_digit *u, int vlen, const sc_digit *v, sc_digit *w)
void vec_shift_left(int ulen, sc_digit *u, int nsl)
void vec_copy(int n, sc_digit *u, const sc_digit *v)
void vec_mul_small_on(int ulen, sc_digit *u, sc_digit v)
void vec_sub_small(int ulen, const sc_digit *u, sc_digit v, sc_digit *w)
sc_concref_r< sc_bitref_r< T1 >, sc_bitref_r< T2 > > concat(sc_bitref_r< T1 >, sc_bitref_r< T2 >)
void safe_set(int i, bool v, sc_digit *d)
sc_digit low_half(sc_digit d)
void is_bad_double(double v)
small_type check_for_zero(small_type s, int ulen, const sc_digit *u)
int vec_to_char(int ulen, const sc_digit *u, int vlen, uchar *v)
void vec_sub(int ulen, const sc_digit *u, int vlen, const sc_digit *v, sc_digit *w)
void vec_add_small_on(int ulen, sc_digit *u, sc_digit v)
void vec_mul(int ulen, const sc_digit *u, int vlen, const sc_digit *vbegin, sc_digit *wbegin)
void vec_complement(int ulen, sc_digit *u)
void convert_SM_to_2C(small_type s, int nd, sc_digit *d)
void convert_signed_SM_to_2C_trimmed(small_type s, int nb, int nd, sc_digit *d)
small_type vec_from_str(int unb, int und, sc_digit *u, const char *v, sc_numrep base)
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
small_type fsm_move(char c, small_type &b, small_type &s, small_type &state)
small_type mul_signs(small_type us, small_type vs)
void vec_zero(int from, int ulen, sc_digit *u)
void vec_mul_small(int ulen, const sc_digit *u, sc_digit v, sc_digit *w)
const std::string to_string(sc_enc enc)
bool sc_io_show_base(::std::ostream &os)
void vec_from_char(int ulen, const uchar *u, int vlen, sc_digit *v)
void trim_signed(int nb, int nd, sc_digit *d)
void trim(small_type added, int nb, int nd, sc_digit *d)
void convert_unsigned_SM_to_2C(small_type s, int nd, sc_digit *d)
sc_digit one_and_zeros(int n)
void parse_hex_bits(const char *src_p, int dst_n, sc_digit *data_p, sc_digit *ctrl_p)
void trim_unsigned(int nb, int nd, sc_digit *d)
void vec_rem_large(int ulen, const sc_digit *u, int vlen, const sc_digit *v, sc_digit *w)
int vec_skip_leading_zeros(int ulen, const sc_digit *u)
void parse_binary_bits(const char *src_p, int dst_n, sc_digit *data_p, sc_digit *ctrl_p)
void copy_digits_signed(small_type &us, int unb, int und, sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
#define BITS_PER_HALF_DIGIT
#define SC_REPORT_ERROR(msg_type, msg)