61#ifndef __SYSTEMC_EXT_DT_BIT_SC_PROXY_HH__
62#define __SYSTEMC_EXT_DT_BIT_SC_PROXY_HH__
93template <
class X,
class Y>
95template <
class X,
class Y>
108template <
class X,
class Y>
114template <
class X,
class T>
168template <
typename X,
typename Y>
175template <
typename X,
typename Y>
178 typename X::traits_type, typename Y::traits_type>
181template <
typename X,
typename Y>
184 typename X::traits_type, typename Y::traits_type>
209 const X &
back_cast()
const {
return static_cast<const X &
>(*this); }
447 print(::std::ostream &os=::std::cout)
const
457 void scan(::std::istream &is=::std::cin);
474template <
class X,
class Y>
478template <
class X,
class Y>
483#define DECL_BITWISE_AND_OP_T(tp) \
485inline const sc_lv_base operator & (tp b, const sc_proxy<X> &px);
501#undef DECL_BITWISE_AND_OP_T
504template <
class X,
class Y>
505inline X &
operator |= (sc_proxy<X> &px,
const sc_proxy<Y> &py);
507template <
class X,
class Y>
509 const sc_proxy<X> &px,
const sc_proxy<Y> &py);
512#define DECL_BITWISE_OR_OP_T(tp) \
514inline const sc_lv_base operator | (tp a, const sc_proxy<X> &px);
530#undef DECL_BITWISE_OR_OP_T
533template <
class X,
class Y>
534inline X &
operator ^= (sc_proxy<X> &px,
const sc_proxy<Y> &py);
536template <
class X,
class Y>
538 const sc_proxy<X> &px,
const sc_proxy<Y> &py);
540#define DECL_BITWISE_XOR_OP_T(tp) \
542inline const sc_lv_base operator ^ (tp a, const sc_proxy<X> &px);
558#undef DECL_BITWISE_XOR_OP_T
561template <
class X,
class Y>
562inline bool operator == (
const sc_proxy<X> &px,
const sc_proxy<Y> &py);
564template <
class X,
class Y>
565inline bool operator != (
const sc_proxy<X> &px,
const sc_proxy<Y> &py);
567#define DECL_REL_OP_T(tp) \
569inline bool operator == (tp b, const sc_proxy<X> &px); \
572inline bool operator != (const sc_proxy<X> &px, tp b); \
575inline bool operator != (tp b, const sc_proxy<X> &px);
606 x_dw = x.get_word(wi);
607 x_cw = x.get_cword(wi);
614 x.set_word(wi, x_dw);
615 x.set_cword(wi, x_cw);
624 for (
int i = wi; i < sz; ++i) {
630template <
class X,
class Y>
634 if ((
void *)&px != (
void *)&py) {
635 X &x = px.back_cast();
638 int min_sz =
sc_min(sz, y.size());
640 for (; i < min_sz; ++i) {
641 set_words_(x, i, y.get_word(i), y.get_cword(i));
655template <
class X,
class T>
659 X &x = px.back_cast();
661 int len_x = x.length();
662 int len_a =
a.length();
665 for (i = 0; i < len_a; ++i) {
668 for (; i < len_x; ++i) {
677 X &x = px.back_cast();
680 int len_x = x.length();
681 int len_a =
a.length();
682 if ( len_a > len_x ) len_a = len_x;
683 for (i = 0; i < len_a; ++i) {
686 for (; i < len_x; ++i) {
695 X &x = px.back_cast();
698 int len_x = x.length();
699 int len_a =
a.length();
702 for (i = 0; i < len_a; ++i) {
705 for (; i < len_x; ++i) {
714 X &x = px.back_cast();
716 int len_x = x.length();
717 int len_a =
a.length();
720 for (i = 0; i < len_a; ++i) {
723 for (; i < len_x; ++i) {
732 X &x = px.back_cast();
734 int len_x = x.length();
735 int len_a =
a.length();
738 for (i = 0; i < len_a; ++i) {
741 for (; i < len_x; ++i) {
753 int len = x.length();
754 int s_len = s.length() - 1;
757 for (; i < min_len; ++i) {
758 char c = s[s_len - i - 1];
764 for (; i <
len; ++i) {
776 int len = x.length();
777 for (
int i = 0; i <
len; ++i) {
789 int len = x.length();
790 for (
int i = 0; i <
len; ++i) {
791 x.set_bit(i,
a[i].value());
924 for (
int i = 0; i < sz; ++i) {
927 x.set_word(i, x_cw | ~x_dw);
934template <
class X,
class Y>
938 X &x = px.back_cast();
942 for (
int i = 0; i < sz; ++i) {
946 sc_digit cw = (x_dw & y_cw) | (x_cw & y_dw) | (x_cw & y_cw);
955template <
class X,
class Y>
959 X &x = px.back_cast();
963 for (
int i = 0; i < sz; ++i) {
967 sc_digit cw = (x_cw & y_cw) | (x_cw & ~y_dw) | (~x_dw & y_cw);
976template <
class X,
class Y>
980 X &x =
a.back_cast();
981 const Y &y =
b.back_cast();
984 for (
int i = 0; i < sz; ++i) {
1004 "positive shift values, shift value = ", n);
1007 if (n >= x.length()) {
1018 for (; i >= wn; --i) {
1019 set_words_(x, i, x.get_word(i - wn), x.get_cword(i - wn));
1021 for (; i >= 0; --i) {
1027 for (
int i = sz - 1; i >= 1; --i) {
1054 "positive shift values, shift value = ", n);
1057 if (n >= x.length()) {
1068 for (; i < (sz - wn); ++i) {
1069 set_words_(x, i, x.get_word(i + wn), x.get_cword(i + wn));
1071 for (; i < sz; ++i) {
1077 for (
int i = 0; i < (sz - 1); ++i) {
1110 int len = x.length();
1111 int half_len =
len / 2;
1112 for (
int i = 0, j =
len - 1; i < half_len; ++ i, --j) {
1114 x.set_bit(i, x.get_bit(j));
1128 const X &x = back_cast();
1130 int len = x.length();
1131 for (
int i = 0; i <
len; ++i) {
1141 const X &x = back_cast();
1143 int len = x.length();
1144 for (
int i = 0; i <
len; ++i) {
1154 const X &x = back_cast();
1156 int len = x.length();
1157 for (
int i = 0; i <
len; ++i) {
1164template <
class X,
class Y>
1172#define DEFN_REL_OP_T(tp) \
1174inline bool operator == (tp b, const sc_proxy<X> &px) { return (px == b); } \
1177inline bool operator != (const sc_proxy<X> &px, tp b) { return !(px == b); } \
1180inline bool operator != (tp b, const sc_proxy<X> &px) { return !(px == b); }
1200inline const std::string
1203 const X &x = back_cast();
1204 int len = x.length();
1206 for (
int i = 0; i <
len; ++i) {
1213inline const std::string
1220inline const std::string
1233 back_cast() = s.c_str();
1240 if (n < 0 || n >= back_cast().length()) {
1250 if (n < 0 || n >= back_cast().size()) {
1262 const X &x = back_cast();
1263 int len = x.length();
1280 const X &x = back_cast();
1281 int len = x.length();
1285 uint64 w = x.get_word(0);
1290 uint64 w1 = x.get_word(1);
1304 const X &x = back_cast();
1305 int len = x.length();
1323 return (
int64)(w & (~zero >> (64 -
len)));
1325 return (
int64)(w | (~zero <<
len));
1337 return a.and_reduce();
1344 return a.nand_reduce();
1351 return a.or_reduce();
1358 return a.nor_reduce();
1365 return a.xor_reduce();
1372 return a.xnor_reduce();
1378inline ::std::ostream &
1386inline ::std::istream &
static const sc_logic_value_t and_table[4][4]
static const sc_logic_value_t not_table[4]
static const char logic_to_char[4]
static const sc_logic_value_t char_to_logic[128]
static const sc_logic_value_t xor_table[4][4]
static const sc_logic_value_t or_table[4][4]
X & operator&=(const char *b)
void check_bounds(int n) const
void scan(::std::istream &is=::std::cin)
sc_bitref< X > operator[](int i)
const sc_lv_base operator|(const char *b) const
const std::string to_string(sc_numrep, bool) const
traits_type::value_type value_type
int64 to_anything_signed() const
X & operator^=(const char *b)
value_type and_reduce() const
sc_digit to_anything_unsigned() const
X & assign_(unsigned long a)
X & assign_(const sc_int_base &a)
const sc_lv_base operator&(const char *b) const
X & assign_(unsigned int a)
X & assign_(const sc_unsigned &a)
sc_bitref_r< X > bit(int i) const
const std::string to_string(sc_numrep) const
value_type nand_reduce() const
unsigned int to_uint() const
value_type or_reduce() const
void check_wbounds(int n) const
sc_bitref< X > bit(int i)
unsigned long to_ulong() const
const sc_lv_base operator>>(int n) const
value_type nor_reduce() const
X & assign_(const sc_proxy< Y > &a)
traits_type::bit_type bit_type
const std::string to_string() const
X & assign_(const sc_uint_base &a)
const sc_lv_base operator~() const
X & assign_(const sc_signed &a)
X & assign_(const bool *a)
value_type xor_reduce() const
sc_subref< X > range(int hi, int lo)
sc_subref< X > operator()(int hi, int lo)
sc_subref_r< X > range(int hi, int lo) const
value_type xnor_reduce() const
X & assign_(const char *a)
bool operator==(const char *b) const
sc_proxy_traits< X >::traits_type traits_type
const sc_lv_base operator<<(int n) const
const sc_lv_base operator^(const char *b) const
X & assign_(const sc_logic *a)
void print(::std::ostream &os=::std::cout) const
const X & back_cast() const
X & operator|=(const char *b)
const char SC_ID_VECTOR_CONTAINS_LOGIC_VALUE_[]
void assign_v_(sc_proxy< X > &px, const T &a)
const sc_digit SC_DIGIT_ONE
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
X & b_or_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
const sc_lv_base reverse(const sc_proxy< X > &x)
sc_numrep sc_io_base(::std::ostream &os, sc_numrep def_base)
const sc_lv_base lrotate(const sc_proxy< X > &x, int n)
const sc_digit SC_DIGIT_ZERO
void get_words_(const X &x, int wi, sc_digit &x_dw, sc_digit &x_cw)
void set_words_(X &x, int wi, sc_digit x_dw, sc_digit x_cw)
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
sc_signed operator|(const sc_unsigned &u, const sc_int_base &v)
const T sc_min(const T &a, const T &b)
sc_signed operator&(const sc_unsigned &u, const sc_int_base &v)
sc_signed operator^(const sc_unsigned &u, const sc_int_base &v)
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
bool operator==(const sc_signed &u, const sc_int_base &v)
X & b_and_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
X & b_xor_assign_(sc_proxy< X > &a, const sc_proxy< Y > &b)
void assign_p_(sc_proxy< X > &px, const sc_proxy< Y > &py)
bool operator!=(const sc_signed &u, const sc_int_base &v)
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
const sc_digit SC_DIGIT_TWO
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
const std::string to_string(sc_enc enc)
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
bool sc_io_show_base(::std::ostream &os)
const std::string convert_to_fmt(const std::string &s, sc_numrep numrep, bool w_prefix)
const sc_lv_base rrotate(const sc_proxy< X > &x, int n)
const std::string convert_to_bin(const char *s)
void extend_sign_w_(X &x, int wi, bool sign)
void sc_proxy_out_of_bounds(const char *msg, int64 val)
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
sc_signed operator>>(const sc_signed &u, const sc_int_base &v)
#define DEFN_REL_OP_T(tp)
#define DECL_REL_OP_T(tp)
#define DECL_BITWISE_AND_OP_T(tp)
#define DECL_BITWISE_OR_OP_T(tp)
#define DECL_BITWISE_XOR_OP_T(tp)
#define SC_REPORT_WARNING(msg_type, msg)
sc_proxy_traits< sc_bv_base > traits_type
sc_proxy_traits< sc_lv_base > traits_type
sc_logic_value_t value_type