107 template <
class X,
class Y>
115 template <
class X,
class T>
182 , typename Y::traits_type >
187 , typename Y::traits_type >
214 {
return static_cast<X&
>( *this ); }
217 {
return static_cast<const X&
>( *this ); }
224 {
assign_p_( *
this, a );
return back_cast(); }
226 X& assign_(
const char* a );
227 X& assign_(
const bool* a );
231 {
assign_v_( *
this, a );
return back_cast(); }
234 {
assign_v_( *
this, a );
return back_cast(); }
237 {
return assign_( (
uint64) a ); }
240 {
return assign_( (
int64) a ); }
242 X& assign_(
unsigned int a );
245 X& assign_(
unsigned long a );
247 X& assign_(
long a );
250 X& assign_(
int64 a );
390 X& operator <<= (
int n );
397 X& operator >>= (
int n );
492 {
return to_anything_signed(); }
493 inline uint64 to_uint64()
const;
495 {
return (
int)to_anything_signed(); }
498 {
return (
unsigned int)to_anything_unsigned(); }
501 {
return (
long)to_anything_signed(); }
504 {
return (
unsigned long)to_anything_unsigned(); }
506 #ifdef SC_DT_DEPRECATED 508 int to_signed()
const 512 {
return to_uint(); }
519 void print( ::std::ostream& os = ::std::cout )
const 529 void scan( ::std::istream& is = ::std::cin );
533 void check_bounds(
int n )
const;
534 void check_wbounds(
int n )
const;
536 sc_digit to_anything_unsigned()
const;
537 int64 to_anything_signed()
const;
545 template <
class X,
class Y>
551 template <
class X,
class Y>
557 #define DECL_BITWISE_AND_OP_T(tp) \ 561 operator & ( tp b, const sc_proxy<X>& px ); 577 #undef DECL_BITWISE_AND_OP_T 582 template <
class X,
class Y>
585 operator |= ( sc_proxy<X>& px,
const sc_proxy<Y>& py );
588 template <
class X,
class Y>
591 operator | (
const sc_proxy<X>& px,
const sc_proxy<Y>& py );
594 #define DECL_BITWISE_OR_OP_T(tp) \ 598 operator | ( tp a, const sc_proxy<X>& px ); 614 #undef DECL_BITWISE_OR_OP_T 619 template <
class X,
class Y>
622 operator ^= ( sc_proxy<X>& px,
const sc_proxy<Y>& py );
625 template <
class X,
class Y>
628 operator ^ (
const sc_proxy<X>& px,
const sc_proxy<Y>& py );
631 #define DECL_BITWISE_XOR_OP_T(tp) \ 635 operator ^ ( tp a, const sc_proxy<X>& px ); 651 #undef DECL_BITWISE_XOR_OP_T 656 template <
class X,
class Y>
659 operator == (
const sc_proxy<X>& px,
const sc_proxy<Y>& py );
661 template <
class X,
class Y>
664 operator != (
const sc_proxy<X>& px,
const sc_proxy<Y>& py );
667 #define DECL_REL_OP_T(tp) \ 671 operator == ( tp b, const sc_proxy<X>& px ); \ 676 operator != ( const sc_proxy<X>& px, tp b ); \ 681 operator != ( tp b, const sc_proxy<X>& px ); 714 x_dw = x.get_word( wi );
715 x_cw = x.get_cword( wi );
723 x.set_word( wi, x_dw );
724 x.set_cword( wi, x_cw );
734 for(
int i = wi; i < sz; ++ i ) {
742 template <
class X,
class Y>
747 if( (
void*) &px != (
void*) &py ) {
749 const Y& y = py.back_cast();
751 int min_sz =
sc_min( sz, y.size() );
753 for( ; i < min_sz; ++ i ) {
754 set_words_( x, i, y.get_word( i ), y.get_cword( i ) );
768 template <
class X,
class T>
775 int len_x = x.length();
776 int len_a = a.length();
777 if ( len_a > len_x ) len_a = len_x;
778 for( i = 0 ; i < len_a; ++ i ) {
781 for( ; i < len_x; ++ i ) {
796 if ( len_a > len_x ) len_a = len_x;
797 for( i = 0 ; i < len_a; ++ i ) {
800 for( ; i < len_x; ++ i ) {
815 if ( len_a > len_x ) len_a = len_x;
816 for( i = 0 ; i < len_a; ++ i ) {
819 for( ; i < len_x; ++ i ) {
831 int len_x = x.length();
833 if ( len_a > len_x ) len_a = len_x;
834 for( i = 0 ; i < len_a; ++ i ) {
837 for( ; i < len_x; ++ i ) {
849 int len_x = x.length();
851 if ( len_a > len_x ) len_a = len_x;
852 for( i = 0 ; i < len_a; ++ i ) {
855 for( ; i < len_x; ++ i ) {
870 int len = x.length();
871 int s_len = s.length() - 1;
872 int min_len =
sc_min( len, s_len );
874 for( ; i < min_len; ++ i ) {
875 char c = s[s_len - i - 1];
881 for( ; i < len; ++ i ) {
882 x.set_bit( i, fill );
894 int len = x.length();
895 for(
int i = 0; i < len; ++ i ) {
908 int len = x.length();
909 for(
int i = 0; i < len; ++ i ) {
910 x.set_bit( i, a[i].
value() );
941 #if defined(SC_LONG_64) 951 ((
sc_digit) (a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
1012 if( x.size() > 1 ) {
1014 ((
sc_digit) (a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
1030 if( x.size() > 1 ) {
1053 for(
int i = 0; i < sz; ++ i ) {
1056 x.set_word( i, x_cw | ~x_dw );
1065 template <
class X,
class Y>
1074 for(
int i = 0; i < sz; ++ i ) {
1078 sc_digit cw = (x_dw & y_cw) | (x_cw & y_dw) | (x_cw & y_cw);
1089 template <
class X,
class Y>
1098 for(
int i = 0; i < sz; ++ i ) {
1102 sc_digit cw = (x_cw & y_cw) | (x_cw & ~y_dw) | (~x_dw & y_cw);
1113 template <
class X,
class Y>
1122 for(
int i = 0; i < sz; ++ i ) {
1145 "positive shift values, shift value = ", n );
1148 if( n >= x.length() ) {
1159 for( ; i >= wn; -- i ) {
1160 set_words_( x, i, x.get_word( i - wn ), x.get_cword( i - wn ) );
1162 for( ; i >= 0; -- i ) {
1163 set_words_( x, i, SC_DIGIT_ZERO, SC_DIGIT_ZERO );
1168 for(
int i = sz - 1; i >= 1; -- i ) {
1172 x_dw |= x.get_word( i - 1 ) >> (SC_DIGIT_SIZE - bn);
1174 x_cw |= x.get_cword( i - 1 ) >> (SC_DIGIT_SIZE - bn);
1199 "positive shift values, shift value = ", n );
1202 if( n >= x.length() ) {
1213 for( ; i < (sz - wn); ++ i ) {
1214 set_words_( x, i, x.get_word( i + wn ), x.get_cword( i + wn ) );
1216 for( ; i < sz; ++ i ) {
1217 set_words_( x, i, SC_DIGIT_ZERO, SC_DIGIT_ZERO );
1222 for(
int i = 0; i < (sz - 1); ++ i ) {
1226 x_dw |= x.get_word( i + 1 ) << (SC_DIGIT_SIZE - bn);
1228 x_cw |= x.get_cword( i + 1 ) << (SC_DIGIT_SIZE - bn);
1266 int len = x.length();
1267 int half_len = len / 2;
1268 for(
int i = 0, j = len - 1; i < half_len; ++ i, --j ) {
1270 x.set_bit( i, x.get_bit( j ) );
1289 const X& x = back_cast();
1291 int len = x.length();
1292 for(
int i = 0; i < len; ++ i ) {
1303 const X& x = back_cast();
1305 int len = x.length();
1306 for(
int i = 0; i < len; ++ i ) {
1317 const X& x = back_cast();
1319 int len = x.length();
1320 for(
int i = 0; i < len; ++ i ) {
1329 template <
class X,
class Y>
1334 return !( px == py );
1338 #define DEFN_REL_OP_T(tp) \ 1339 template <class X> \ 1342 operator == ( tp b, const sc_proxy<X>& px ) \ 1344 return ( px == b ); \ 1347 template <class X> \ 1350 operator != ( const sc_proxy<X>& px, tp b ) \ 1352 return !( px == b ); \ 1355 template <class X> \ 1358 operator != ( tp b, const sc_proxy<X>& px ) \ 1360 return !( px == b ); \ 1377 #undef DEFN_REL_OP_T 1387 const X& x = back_cast();
1388 int len = x.length();
1390 for(
int i = 0; i < len; ++ i ) {
1422 back_cast() = s.c_str();
1431 if( n < 0 || n >= back_cast().length() ) {
1442 if( n < 0 || n >= back_cast().size() ) {
1456 const X& x = back_cast();
1457 int len = x.length();
1462 if( len >= SC_DIGIT_SIZE ) {
1465 return ( w & (~SC_DIGIT_ZERO >> (SC_DIGIT_SIZE - len)) );
1475 const X& x = back_cast();
1476 int len = x.length();
1480 uint64 w = x.get_word( 0 );
1481 if( len > SC_DIGIT_SIZE )
1486 uint64 w1 = x.get_word( 1 );
1490 else if( len == SC_DIGIT_SIZE )
1496 return ( w & (~SC_DIGIT_ZERO >> (SC_DIGIT_SIZE - len)) );
1505 const X& x = back_cast();
1506 int len = x.length();
1509 if( len > SC_DIGIT_SIZE )
1525 return (
int64)( w & (~zero >> (64 - len)) );
1527 return (
int64)( w | (~zero << len) );
1586 operator << ( ::std::ostream& os, const sc_proxy<X>& a )
value_type nand_reduce() const
Template traits helper to select the correct bit/value/vector_types for.
#define DECL_REL_OP_T(tp)
const sc_digit SC_DIGIT_TWO
X & assign_(const sc_uint_base &a)
static const sc_logic_value_t and_table[4][4]
void check_bounds(int n) const
const T sc_min(const T &a, const T &b)
SC_API void sc_proxy_out_of_bounds(const char *msg=NULL, int64 val=0)
X & assign_(const sc_proxy< Y > &a)
bool operator==(const sc_bit &a, const sc_bit &b)
Arbitrary precision signed arithmetic.
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
Proxy class for sc_proxy part selection (r-value and l-value).
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
sc_bitref_r< X > bit(int i) const
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
void set_words_(X &x, int wi, sc_digit x_dw, sc_digit x_cw)
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
void assign_v_(sc_proxy< X > &px, const T &a)
sc_proxy_traits< sc_bv_base > traits_type
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Arbitrary precision signed number.
const sc_digit SC_DIGIT_ONE
value_type or_reduce() const
Proxy class for sc_proxy part selection (r-value only).
void check_wbounds(int n) const
SC_API const std::string convert_to_bin(const char *s)
traits_type::value_type value_type
X & assign_(const sc_int_base &a)
Base class template for bit/logic vector classes.
Arbitrary precision unsigned number.
value_type nor_reduce() const
X & b_and_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
sc_logic_value_t
Enumeration of values for sc_logic.
uint64 const sc_uint_base int b
#define DECL_BITWISE_OR_OP_T(tp)
bool operator!=(const sc_bit &a, const sc_bit &b)
X & assign_(const sc_signed &a)
const sc_bit b_not(const sc_bit &a)
const sc_bit operator|(const sc_bit &a, const sc_bit &b)
SC_API const std::string convert_to_fmt(const std::string &s, sc_numrep numrep, bool)
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
const sc_lv_base lrotate(const sc_proxy< X > &x, int n)
sc_bitref< X > bit(int i)
Miscellaneous definitions that are needed by the headers.
An unsigned integer whose length is less than 64 bits.
Arbitrary size logic vector base class.
#define SC_REPORT_WARNING(msg_type, msg)
static const sc_logic_value_t xor_table[4][4]
X & assign_(const sc_unsigned &a)
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
Arbitrary precision unsigned arithmetic.
static const sc_logic_value_t not_table[4]
sc_proxy_traits< sc_lv_base > traits_type
static const char logic_to_char[4]
Proxy class for sc_proxy bit selection (r-value and l-value).
sc_digit to_anything_unsigned() const
const sc_lv_base reverse(const sc_proxy< X > &x)
sc_clock period is zero sc_clock low time is zero sc_fifo< T > cannot have more than one writer bind interface to port failed complete binding failed remove port failed insert primitive channel failed sc_signal< T > cannot have more than one driver resolved port not bound to resolved signal sc_semaphore requires an initial value
void scan(::std::istream &is=::std::cin)
SC_API const std::string to_string(sc_enc)
X & b_or_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
traits_type::bit_type bit_type
sc_subref< X > range(int hi, int lo)
static const sc_logic_value_t char_to_logic[128]
sc_numrep
Enumeration of number representations for character string conversion.
value_type and_reduce() const
const sc_bit operator^(const sc_bit &a, const sc_bit &b)
unsigned long to_ulong() const
const X & back_cast() const
int64 to_anything_signed() const
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
void extend_sign_w_(X &x, int wi, bool sign)
C++ implementation of logic type. Behaves.
Report ids for the datatypes/bit code.
const sc_digit SC_DIGIT_ZERO
sc_logic_value_t value_type
sc_subref_r< X > range(int hi, int lo) const
void assign_p_(sc_proxy< X > &px, const sc_proxy< Y > &py)
#define DECL_BITWISE_XOR_OP_T(tp)
X & b_xor_assign_(sc_proxy< X > &a, const sc_proxy< Y > &b)
#define DECL_BITWISE_AND_OP_T(tp)
value_type xnor_reduce() const
const sc_lv_base rrotate(const sc_proxy< X > &x, int n)
const sc_bit operator&(const sc_bit &a, const sc_bit &b)
sc_numrep sc_io_base(::std::ostream &, sc_numrep)
sc_proxy_traits< X >::traits_type traits_type
static const sc_logic_value_t or_table[4][4]
inline ::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
SC_NORETURN_ SC_API void sc_abort()
value_type xor_reduce() const
const sc_bit operator~(const sc_bit &a)
Arbitrary size bit vector base class.
void print(::std::ostream &os=::std::cout) const
unsigned int to_uint() const
bool sc_io_show_base(::std::ostream &)
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
A signed integer whose length is less than 64 bit.
inline ::std::istream & operator>>(::std::istream &is, sc_bit &a)
#define DEFN_REL_OP_T(tp)
void get_words_(const X &x, int wi, sc_digit &x_dw, sc_digit &x_cw)
const std::string to_string() const