Go to the documentation of this file.
61 #ifndef __SYSTEMC_EXT_DT_BIT_SC_PROXY_HH__
62 #define __SYSTEMC_EXT_DT_BIT_SC_PROXY_HH__
66 #include "../../utils/functions.hh"
67 #include "../int/sc_int_base.hh"
68 #include "../int/sc_signed.hh"
69 #include "../int/sc_uint_base.hh"
70 #include "../int/sc_unsigned.hh"
93 template <
class X,
class Y>
95 template <
class X,
class Y>
108 template <
class X,
class Y>
109 inline void assign_p_(sc_proxy<X> &
px,
const sc_proxy<Y> &py);
114 template <
class X,
class T>
131 template <
typename X>
138 typedef bool value_type;
144 struct sc_proxy_traits<sc_lv_base>
146 typedef sc_proxy_traits<sc_lv_base> traits_type;
148 typedef sc_logic bit_type;
149 typedef sc_lv_base vector_type;
152 template <
typename X>
153 struct sc_proxy_traits<sc_bitref_r<
X> > : sc_proxy_traits<X> {};
155 template <
typename X>
156 struct sc_proxy_traits<sc_bitref<
X> > : sc_proxy_traits<X> {};
158 template <
typename X>
159 struct sc_proxy_traits<sc_subref_r<
X> > : sc_proxy_traits<X> {};
161 template <
typename X>
162 struct sc_proxy_traits<sc_subref<
X> > : sc_proxy_traits<X> {};
164 template <
typename X>
165 struct sc_proxy_traits<sc_proxy<
X> > : sc_proxy_traits<X> {};
168 template <
typename X,
typename Y>
169 struct sc_mixed_proxy_traits_helper : sc_proxy_traits<sc_lv_base>
172 template <
typename X>
175 template <
typename X,
typename Y>
178 typename X::traits_type, typename Y::traits_type>
181 template <
typename X,
typename Y>
184 typename X::traits_type, typename Y::traits_type>
200 typedef typename traits_type::bit_type
bit_type;
209 const X &
back_cast()
const {
return static_cast<const X &
>(*this); }
366 sc_bitref_r<X>
bit(
int i)
const {
return sc_bitref_r<X>(
back_cast(),
i); }
447 print(::std::ostream &
os=::std::cout)
const
457 void scan(::std::istream &
is=::std::cin);
474 template <
class X,
class Y>
478 template <
class X,
class Y>
483 #define DECL_BITWISE_AND_OP_T(tp) \
485 inline const sc_lv_base operator & (tp b, const sc_proxy<X> &px);
501 #undef DECL_BITWISE_AND_OP_T
504 template <
class X,
class Y>
507 template <
class X,
class Y>
512 #define DECL_BITWISE_OR_OP_T(tp) \
514 inline const sc_lv_base operator | (tp a, const sc_proxy<X> &px);
530 #undef DECL_BITWISE_OR_OP_T
533 template <
class X,
class Y>
536 template <
class X,
class Y>
538 const sc_proxy<X> &
px,
const sc_proxy<Y> &py);
540 #define DECL_BITWISE_XOR_OP_T(tp) \
542 inline const sc_lv_base operator ^ (tp a, const sc_proxy<X> &px);
558 #undef DECL_BITWISE_XOR_OP_T
561 template <
class X,
class Y>
562 inline bool operator == (
const sc_proxy<X> &
px,
const sc_proxy<Y> &py);
564 template <
class X,
class Y>
565 inline bool operator != (
const sc_proxy<X> &
px,
const sc_proxy<Y> &py);
567 #define DECL_REL_OP_T(tp) \
569 inline bool operator == (tp b, const sc_proxy<X> &px); \
572 inline bool operator != (const sc_proxy<X> &px, tp b); \
575 inline 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) {
630 template <
class X,
class Y>
634 if ((
void *)&
px != (
void *)&py) {
635 X &
x =
px.back_cast();
636 const Y &y = py.back_cast();
638 int min_sz =
sc_min(sz, y.size());
640 for (;
i < min_sz; ++
i) {
655 template <
class X,
class T>
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) {
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) {
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);
934 template <
class X,
class Y>
938 X &
x =
px.back_cast();
939 const Y &y = py.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);
955 template <
class X,
class Y>
960 const Y &y = py.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);
976 template <
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) {
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) {
1071 for (;
i < sz; ++
i) {
1077 for (
int i = 0;
i < (sz - 1); ++
i) {
1098 inline const sc_lv_base
lrotate(
const sc_proxy<X> &
x,
int n);
1102 inline const sc_lv_base
rrotate(
const sc_proxy<X>&
x,
int n);
1110 int len =
x.length();
1111 int half_len =
len / 2;
1112 for (
int i = 0,
j =
len - 1;
i < half_len; ++
i, --
j) {
1113 value_type
t =
x.get_bit(
i);
1114 x.set_bit(
i,
x.get_bit(
j));
1121 inline const sc_lv_base
reverse(
const sc_proxy<X> &
a);
1128 const X &
x = back_cast();
1129 value_type result = value_type(1);
1130 int len =
x.length();
1131 for (
int i = 0;
i <
len; ++
i) {
1141 const X &
x = back_cast();
1142 value_type result = value_type(0);
1143 int len =
x.length();
1144 for (
int i = 0;
i <
len; ++
i) {
1154 const X &
x = back_cast();
1155 value_type result = value_type(0);
1156 int len =
x.length();
1157 for (
int i = 0;
i <
len; ++
i) {
1164 template <
class X,
class Y>
1172 #define DEFN_REL_OP_T(tp) \
1173 template <class X> \
1174 inline bool operator == (tp b, const sc_proxy<X> &px) { return (px == b); } \
1176 template <class X> \
1177 inline bool operator != (const sc_proxy<X> &px, tp b) { return !(px == b); } \
1179 template <class X> \
1180 inline bool operator != (tp b, const sc_proxy<X> &px) { return !(px == b); }
1196 #undef DEFN_REL_OP_T
1200 inline const std::string
1203 const X &
x = back_cast();
1204 int len =
x.length();
1206 for (
int i = 0;
i <
len; ++
i) {
1213 inline const std::string
1220 inline const std::string
1233 back_cast() =
s.c_str();
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();
1304 const X &
x = back_cast();
1305 int len =
x.length();
1321 value_type sgn =
x.get_bit(
len - 1);
1323 return (
int64)(
w & (~zero >> (64 -
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();
1378 inline ::std::ostream &
1386 inline ::std::istream &
1395 #endif // __SYSTEMC_EXT_DT_BIT_SC_PROXY_HH__
const char SC_ID_VECTOR_CONTAINS_LOGIC_VALUE_[]
value_type or_reduce() const
X & operator|=(const char *b)
sc_signed operator|(const sc_unsigned &u, const sc_int_base &v)
int64 to_anything_signed() const
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
const sc_digit SC_DIGIT_ZERO
X & b_and_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
static const char logic_to_char[4]
static const sc_logic_value_t and_table[4][4]
void get_words_(const X &x, int wi, sc_digit &x_dw, sc_digit &x_cw)
value_type nor_reduce() const
const sc_lv_base operator&(const char *b) const
X & b_xor_assign_(sc_proxy< X > &a, const sc_proxy< Y > &b)
value_type and_reduce() const
const std::string to_string(sc_enc enc)
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
#define DECL_BITWISE_AND_OP_T(tp)
unsigned long to_ulong() const
bool operator==(const char *b) const
void assign_v_(sc_proxy< X > &px, const T &a)
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
sc_bitref< X > bit(int i)
bool sc_io_show_base(::std::ostream &os)
sc_signed operator^(const sc_unsigned &u, const sc_int_base &v)
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
traits_type::bit_type bit_type
bool operator==(const sc_signed &u, const sc_int_base &v)
static const sc_logic_value_t char_to_logic[128]
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
value_type nand_reduce() const
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
void assign_p_(sc_proxy< X > &px, const sc_proxy< Y > &py)
const sc_lv_base operator|(const char *b) const
const std::string to_string() const
#define DECL_BITWISE_OR_OP_T(tp)
const sc_lv_base operator>>(int n) const
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
const sc_digit SC_DIGIT_ONE
sc_numrep sc_io_base(::std::ostream &os, sc_numrep def_base)
const sc_lv_base lrotate(const sc_proxy< X > &x, int n)
static const sc_logic_value_t or_table[4][4]
unsigned int to_uint() const
X & b_or_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
sc_digit to_anything_unsigned() const
const sc_lv_base operator<<(int n) const
void print(::std::ostream &os=::std::cout) const
bool operator!=(const sc_signed &u, const sc_int_base &v)
const sc_lv_base operator^(const char *b) const
const sc_lv_base reverse(const sc_proxy< X > &x)
X & operator&=(const char *b)
value_type xnor_reduce() const
const sc_lv_base operator~() const
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
const T sc_min(const T &a, const T &b)
sc_subref< X > range(int hi, int lo)
#define DECL_REL_OP_T(tp)
void check_wbounds(int n) const
void extend_sign_w_(X &x, int wi, bool sign)
sc_bitref< X > operator[](int i)
const std::string convert_to_fmt(const std::string &s, sc_numrep numrep, bool w_prefix)
void set_words_(X &x, int wi, sc_digit x_dw, sc_digit x_cw)
#define SC_REPORT_WARNING(msg_type, msg)
const sc_lv_base rrotate(const sc_proxy< X > &x, int n)
sc_subref< X > operator()(int hi, int lo)
const std::string convert_to_bin(const char *s)
sc_signed operator>>(const sc_signed &u, const sc_int_base &v)
X & assign_(const sc_proxy< Y > &a)
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
static const sc_logic_value_t xor_table[4][4]
void scan(::std::istream &is=::std::cin)
#define DEFN_REL_OP_T(tp)
void check_bounds(int n) const
#define DECL_BITWISE_XOR_OP_T(tp)
static const sc_logic_value_t not_table[4]
X & operator^=(const char *b)
value_type xor_reduce() const
traits_type::value_type value_type
sc_proxy_traits< X >::traits_type traits_type
const sc_digit SC_DIGIT_TWO
sc_signed operator&(const sc_unsigned &u, const sc_int_base &v)
void sc_proxy_out_of_bounds(const char *msg, int64 val)
Generated on Wed Sep 30 2020 14:02:15 for gem5 by doxygen 1.8.17