103 #ifndef SC_UNSIGNED_H 104 #define SC_UNSIGNED_H 121 class sc_unsigned_bitref_r;
122 class sc_unsigned_bitref;
123 class sc_unsigned_subref_r;
124 class sc_unsigned_subref;
133 class sc_int_subref_r;
134 class sc_uint_subref_r;
136 class sc_signed_subref_r;
249 inline sc_unsigned
operator + (
const sc_unsigned& u,
unsigned int v);
256 inline sc_unsigned
operator + (
unsigned int u,
const sc_unsigned& v);
258 SC_API sc_unsigned
operator + (
const sc_unsigned& u,
const sc_uint_base& v);
260 SC_API sc_unsigned
operator + (
const sc_uint_base& u,
const sc_unsigned& v);
299 inline sc_unsigned
operator * (
const sc_unsigned& u,
unsigned int v);
306 inline sc_unsigned
operator * (
unsigned int u,
const sc_unsigned& v);
308 SC_API sc_unsigned
operator * (
const sc_unsigned& u,
const sc_uint_base& v);
310 SC_API sc_unsigned
operator * (
const sc_uint_base& u,
const sc_unsigned& v);
324 inline sc_unsigned
operator / (
const sc_unsigned& u,
unsigned int v);
331 inline sc_unsigned
operator / (
unsigned int u,
const sc_unsigned& v);
333 SC_API sc_unsigned
operator / (
const sc_unsigned& u,
const sc_uint_base& v);
335 SC_API sc_unsigned
operator / (
const sc_uint_base& u,
const sc_unsigned& v);
349 inline sc_unsigned
operator % (
const sc_unsigned& u,
unsigned int v);
356 inline sc_unsigned
operator % (
unsigned int u,
const sc_unsigned& v);
358 SC_API sc_unsigned
operator % (
const sc_unsigned& u,
const sc_uint_base& v);
360 SC_API sc_unsigned
operator % (
const sc_uint_base& u,
const sc_unsigned& v);
376 inline sc_unsigned
operator & (
const sc_unsigned& u,
unsigned int v);
383 inline sc_unsigned
operator & (
unsigned int u,
const sc_unsigned& v);
385 SC_API sc_unsigned
operator & (
const sc_unsigned& u,
const sc_uint_base& v);
387 SC_API sc_unsigned
operator & (
const sc_uint_base& u,
const sc_unsigned& v);
401 inline sc_unsigned
operator | (
const sc_unsigned& u,
unsigned int v);
408 inline sc_unsigned
operator | (
unsigned int u,
const sc_unsigned& v);
410 SC_API sc_unsigned
operator | (
const sc_unsigned& u,
const sc_uint_base& v);
412 SC_API sc_unsigned
operator | (
const sc_uint_base& u,
const sc_unsigned& v);
426 inline sc_unsigned
operator ^ (
const sc_unsigned& u,
unsigned int v);
433 inline sc_unsigned
operator ^ (
unsigned int u,
const sc_unsigned& v);
435 SC_API sc_unsigned
operator ^ (
const sc_unsigned& u,
const sc_uint_base& v);
437 SC_API sc_unsigned
operator ^ (
const sc_uint_base& u,
const sc_unsigned& v);
452 inline sc_unsigned
operator << (
const sc_unsigned& u,
int v);
453 inline sc_unsigned
operator << (
const sc_unsigned& u,
unsigned int v);
468 inline sc_unsigned
operator >> (
const sc_unsigned& u,
int v);
469 inline sc_unsigned
operator >> (
const sc_unsigned& u,
unsigned int v);
490 inline bool operator == (
const sc_unsigned& u,
int v);
491 inline bool operator == (
const sc_unsigned& u,
unsigned int v);
497 inline bool operator == (
int u,
const sc_unsigned& v);
498 inline bool operator == (
unsigned int u,
const sc_unsigned& v) ;
515 inline bool operator != (
const sc_unsigned& u,
int v);
516 inline bool operator != (
const sc_unsigned& u,
unsigned int v);
522 inline bool operator != (
int u,
const sc_unsigned& v);
523 inline bool operator != (
unsigned int u,
const sc_unsigned& v);
540 inline bool operator < (
const sc_unsigned& u,
int v);
541 inline bool operator < (
const sc_unsigned& u,
unsigned int v);
547 inline bool operator < (
int u,
const sc_unsigned& v);
548 inline bool operator < (
unsigned int u,
const sc_unsigned& v);
565 inline bool operator <= (
const sc_unsigned& u,
int v);
566 inline bool operator <= (
const sc_unsigned& u,
unsigned int v);
572 inline bool operator <= (
int u,
const sc_unsigned& v);
573 inline bool operator <= (
unsigned int u,
const sc_unsigned& v);
590 inline bool operator > (
const sc_unsigned& u,
int v);
591 inline bool operator > (
const sc_unsigned& u,
unsigned int v);
597 inline bool operator > (
int u,
const sc_unsigned& v);
598 inline bool operator > (
unsigned int u,
const sc_unsigned& v);
615 inline bool operator >= (
const sc_unsigned& u,
int v);
616 inline bool operator >= (
const sc_unsigned& u,
unsigned int v);
622 inline bool operator >= (
int u,
const sc_unsigned& v);
623 inline bool operator >= (
unsigned int u,
const sc_unsigned& v);
666 :
sc_value_base(a), m_index( a.m_index ), m_obj_p( a.m_obj_p )
678 bool operator ! ()
const;
685 {
return operator uint64(); }
688 {
return operator uint64(); }
694 {
if ( xz_present_p ) *xz_present_p =
false;
return 1; }
701 dst_p[word_i] &= ~bit_mask;
711 dst_p[word_i] |= bit_mask;
716 dst_p[word_i] &= ~bit_mask;
724 void print( ::std::ostream& os = ::std::cout )
const 784 virtual void concat_set(
int64 src,
int low_i);
785 virtual void concat_set(
const sc_signed& src,
int low_i);
786 virtual void concat_set(
const sc_unsigned& src,
int low_i);
787 virtual void concat_set(
uint64 src,
int low_i);
792 void scan( ::std::istream& is = ::std::cin );
815 friend class sc_unsigned_signal;
842 :
sc_value_base(a), m_left( a.m_left ), m_obj_p( a.m_obj_p ),
850 {
return m_left >= m_right ? (m_left-m_right+1) : (m_right-m_left+1 ); }
861 unsigned int to_uint()
const;
862 long to_long()
const;
863 unsigned long to_ulong()
const;
864 int64 to_int64()
const;
866 double to_double()
const;
879 if ( xz_present_p ) *xz_present_p =
false;
880 return m_left - m_right + 1;
882 virtual uint64 concat_get_uint64()
const;
883 virtual bool concat_get_ctrl(
sc_digit* dst_p,
int low_i )
const;
884 virtual bool concat_get_data(
sc_digit* dst_p,
int low_i )
const;
897 void print( ::std::ostream& os = ::std::cout )
const 962 {
return operator = ( (
unsigned long) a ); }
965 {
return operator = ( (
long) a ); }
975 virtual void concat_set(
int64 src,
int low_i);
976 virtual void concat_set(
const sc_signed& src,
int low_i);
977 virtual void concat_set(
const sc_unsigned& src,
int low_i);
978 virtual void concat_set(
uint64 src,
int low_i);
982 void scan( ::std::istream& is = ::std::cin );
1013 typedef bool elemtype;
1015 void invalid_init(
const char* type_name,
int nb )
const;
1042 { a->to_sc_unsigned(*
this);
return *
this; }
1054 {
return operator=((
long) v); }
1057 {
return operator=((
unsigned long) v); }
1066 #ifdef SC_INCLUDE_FX 1078 # ifndef SC_MAX_NBITS 1087 {
if ( xz_present_p ) *xz_present_p =
false;
return nbits-1; }
1088 virtual bool concat_get_ctrl(
sc_digit* dst_p,
int low_i )
const;
1089 virtual bool concat_get_data(
sc_digit* dst_p,
int low_i )
const;
1090 virtual uint64 concat_get_uint64()
const;
1091 virtual void concat_set(
int64 src,
int low_i);
1092 virtual void concat_set(
const sc_signed& src,
int low_i);
1093 virtual void concat_set(
const sc_unsigned& src,
int low_i);
1094 virtual void concat_set(
uint64 src,
int low_i);
1110 {
if ( (i < 0) || (i >= nbits-1) ) invalid_index(i); }
1112 void invalid_index(
int i )
const;
1164 if ( (l < 0) || (r >= nbits-1) ) invalid_range(l,r);
1168 if ( (r < 0) || (l >= nbits-1) ) invalid_range(l,r);
1172 void invalid_range(
int l,
int r )
const;
1213 unsigned int to_uint()
const;
1214 long to_long()
const;
1215 unsigned long to_ulong()
const;
1216 int64 to_int64()
const;
1217 uint64 to_uint64()
const;
1218 double to_double()
const;
1220 #ifdef SC_DT_DEPRECATED 1221 int to_signed()
const 1222 {
return to_int(); }
1224 unsigned int to_unsigned()
const 1225 {
return to_uint(); }
1235 void print( ::std::ostream& os = ::std::cout )
const 1238 void scan( ::std::istream& is = ::std::cin );
1240 void dump( ::std::ostream& os = ::std::cout )
const;
1245 bool iszero()
const;
1267 bool test(
int i)
const;
1270 void set(
int i,
bool v)
1271 {
if (v)
set(i);
else clear(i); }
1273 {
if (test(i)) clear(i);
else set(i); }
1279 void get_packed_rep(
sc_digit *buf)
const;
1280 void set_packed_rep(
sc_digit *buf);
1325 {
return operator+(u, (
unsigned long) v); }
1333 {
return operator+((
unsigned long) u, v); }
1342 {
return operator+=((
long) v); }
1344 {
return operator+=((
unsigned long) v); }
1380 {
return operator-=((
long) v); }
1382 {
return operator-=((
unsigned long) v); }
1403 {
return operator*(u, (
unsigned long) v); }
1411 {
return operator*((
unsigned long) u, v); }
1420 {
return operator*=((
long) v); }
1422 {
return operator*=((
unsigned long) v); }
1443 {
return operator/(u, (
unsigned long) v); }
1451 {
return operator/((
unsigned long) u, v); }
1460 {
return operator/=((
long) v); }
1462 {
return operator/=((
unsigned long) v); }
1483 {
return operator%(u, (
unsigned long) v); }
1491 {
return operator%((
unsigned long) u, v); }
1500 {
return operator%=((
long) v); }
1502 {
return operator%=((
unsigned long) v); }
1525 {
return operator&(u, (
unsigned long) v); }
1533 {
return operator&((
unsigned long) u, v); }
1565 {
return operator|(u, (
unsigned long) v); }
1573 {
return operator|((
unsigned long) u, v); }
1605 {
return operator^(u, (
unsigned long) v); }
1613 {
return operator^((
unsigned long) u, v); }
1655 const sc_unsigned& operator <<= (
unsigned long v);
1657 {
return operator<<=((
long) v); }
1659 {
return operator<<=((
unsigned long) v); }
1686 const sc_unsigned& operator >>= (
unsigned long v);
1688 {
return operator>>=((
long) v); }
1690 {
return operator>>=((
unsigned long) v); }
1774 {
return operator<(u, (
unsigned long) v); }
1783 {
return operator<((
unsigned long) u, v); }
1832 {
return operator>(u, (
unsigned long) v); }
1841 {
return operator>((
unsigned long) u, v); }
1995 int num_bits(
int nb)
const {
return nb + 1; }
1997 bool check_if_outside(
int bit_num)
const;
1999 void copy_digits(
int nb,
int nd,
const sc_digit *d)
2007 void convert_2C_to_SM()
2010 void convert_SM_to_2C_to_SM()
2058 a->to_sc_unsigned(temp);
2059 return *
this = temp;
2082 for (
int i = m_right; i <= m_left; i++ )
2083 if ( !target_p->
test(i) )
return false;
2095 for (
int i = m_right; i <= m_left; i++ )
2096 if ( target_p->
test(i) )
return true;
2110 for (
int i = m_right; i <= m_left; i++ )
2111 if ( target_p->
test(i) ) odd = ~odd;
2112 return odd ? true :
false;
2143 return ( *
this = aa = a );
2166 int nb = v->length();
2167 sgn = default_sign();
2169 nbits = num_bits( nb );
2171 invalid_init(
"sc_generic_base<T>", nb );
2175 # ifdef SC_MAX_NBITS 2181 v->to_sc_unsigned(*
this);
virtual ~sc_unsigned_bitref_r()
SC_API sc_signed operator-(const sc_unsigned &u, const sc_signed &v)
Proxy class for sized bit concatenation.
Base class for the fixed-point types; limited precision.
void scan(::std::istream &is=::std::cin)
void copy_digits_unsigned(small_type &us, int unb, int und, sc_digit *ud, int, 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)
void initialize(const sc_unsigned *obj_p, int left_, int right_)
static sc_core::sc_vpool< sc_unsigned_bitref > m_pool
small_type make_zero(int nd, sc_digit *d)
void check_index(int i) const
Proxy class for sc_uint part selection (r-value only).
bool operator==(const sc_bit &a, const sc_bit &b)
Proxy class for sc_int part selection (r-value only).
Fixed-point value types; limited precision.
SC_API sc_signed operator*(const sc_unsigned &u, const sc_signed &v)
virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
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)
void convert_SM_to_2C(small_type s, int nd, sc_digit *d)
virtual uint64 concat_get_uint64() const
Proxy class for sc_unsigned part selection (r-value only).
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Arbitrary precision signed number.
Abstract base class of all SystemC native variables.
void scan(::std::istream &is=::std::cin)
Arbitrary precision unsigned number.
Base class for the fixed-point types; arbitrary precision.
Base class for SystemC bit values.
Proxy class for sc_unsigned bit selection (r-value and l-value).
const sc_unsigned_bitref_r & bit(int i) const
bool operator!=(const sc_bit &a, const sc_bit &b)
sc_unsigned_bitref & bit(int i)
const sc_fxval operator/(const sc_fxnum &a, const sc_fxnum &b)
const sc_bit operator|(const sc_bit &a, const sc_bit &b)
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
small_type convert_unsigned_2C_to_SM(int nb, int nd, sc_digit *d)
Fixed-point value type; arbitrary precision.
void initialize(const sc_unsigned *obj_p, int index_)
SC_API sc_signed operator%(const sc_unsigned &u, const sc_signed &v)
Arbitrary size logic vector base class.
sc_unsigned mod_unsigned_friend(small_type us, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
Proxy class for sc_unsigned part selection (r-value and l-value).
SC_API sc_signed operator+(const sc_unsigned &u, const sc_signed &v)
sc_unsigned_bitref_r(const sc_unsigned_bitref_r &a)
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
Proxy class for sc_signed part selection (r-value and l-value).
bool operator>=(const sc_int_base &a, const sc_int_base &b)
virtual int concat_length(bool *xz_present_p) const
External and friend functions for both sc_signed and.
bool operator<(const sc_int_base &a, const sc_int_base &b)
sc_digit * get_raw() const
const sc_lv_base reverse(const sc_proxy< X > &x)
static sc_core::sc_vpool< sc_unsigned > m_pool
SC_API const std::string to_string(sc_enc)
sc_unsigned(int nb=sc_length_param().len())
bool operator>(const sc_int_base &a, const sc_int_base &b)
Abstract base class of all SystemC `simulation' objects.
void print(::std::ostream &os=::std::cout) const
Proxy class for user-defined value classes and other classes that.
virtual int concat_length(bool *xz_present_p) const
void convert_unsigned_SM_to_2C(small_type s, int nd, sc_digit *d)
sc_numrep
Enumeration of number representations for character string conversion.
const sc_unsigned_subref_r & range(int i, int j) const
const sc_bit operator^(const sc_bit &a, const sc_bit &b)
Proxy class for sc_signed part selection (r-value only).
virtual ~sc_unsigned_subref_r()
virtual int concat_length(bool *xz_present_p) const
void check_range(int l, int r) const
virtual bool concat_get_data(sc_digit *dst_p, int low_i) const
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=0, small_type if_v_signed=0)
sc_unsigned_bitref(const sc_unsigned_bitref &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 print(::std::ostream &os=::std::cout) const
#define SC_API_TEMPLATE_DECL_
small_type convert_unsigned_SM_to_2C_to_SM(small_type s, int nb, int nd, sc_digit *d)
sc_unsigned_subref(const sc_unsigned_subref &a)
static sc_core::sc_vpool< sc_unsigned_subref > m_pool
void scan(::std::istream &is=::std::cin)
sc_unsigned sub_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_bit operator&(const sc_bit &a, const sc_bit &b)
sc_numrep sc_io_base(::std::ostream &, sc_numrep)
sc_unsigned_subref_r(const sc_unsigned_subref_r &a)
Top level header file for arbitrary precision signed/unsigned.
void print(::std::ostream &os=::std::cout) const
Temporary value pool classes.
const sc_unsigned_subref & operator=(const sc_unsigned_subref_r &a)
inline ::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
SC_NORETURN_ SC_API void sc_abort()
const sc_bit operator~(const sc_bit &a)
sc_unsigned div_unsigned_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
Arbitrary size bit vector base class.
External functions for both sc_signed and sc_unsigned.
Proxy class for sc_unsigned bit selection (r-value only).
bool sc_io_show_base(::std::ostream &)
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
bool operator<=(const sc_int_base &a, const sc_int_base &b)
sc_unsigned_subref & range(int i, int j)
inline ::std::istream & operator>>(::std::istream &is, sc_bit &a)
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)
sc_unsigned mul_unsigned_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)