Go to the documentation of this file.
69 #ifndef __SYSTEMC_EXT_DT_INT_SC_INT_BASE_HH__
70 #define __SYSTEMC_EXT_DT_INT_SC_INT_BASE_HH__
74 #include "../misc/sc_value_base.hh"
75 #include "../sc_temporary.hh"
86 class sc_int_bitref_r;
88 class sc_int_subref_r;
91 class sc_signed_subref_r;
92 class sc_unsigned_subref_r;
110 extern template class sc_vpool<sc_dt::sc_int_bitref>;
111 extern template class sc_vpool<sc_dt::sc_int_subref>;
124 inline bool operator == (
const sc_int_base &
a,
const sc_int_base &
b);
125 inline bool operator != (
const sc_int_base &
a,
const sc_int_base &
b);
126 inline bool operator < (
const sc_int_base &
a,
const sc_int_base &
b);
127 inline bool operator <= (
const sc_int_base &
a,
const sc_int_base &
b);
128 inline bool operator > (
const sc_int_base &
a,
const sc_int_base &
b);
129 inline bool operator >= (
const sc_int_base &
a,
const sc_int_base &
b);
165 #ifdef SC_DT_DEPRECATED
166 int bitwidth()
const {
return length(); }
174 *xz_present_p =
false;
183 dst_p[word_i] &= ~bit_mask;
194 dst_p[word_i] |= bit_mask;
197 dst_p[word_i] &= ~bit_mask;
211 bool operator ! ()
const;
265 virtual void concat_set(
int64 src,
int low_i);
266 virtual void concat_set(
const sc_signed &src,
int low_i);
267 virtual void concat_set(
const sc_unsigned &src,
int low_i);
268 virtual void concat_set(
uint64 src,
int low_i);
271 void scan(::std::istream &
is=::std::cin);
317 int length()
const {
return (m_left - m_right + 1); }
324 *xz_present_p =
false;
327 virtual bool concat_get_ctrl(
sc_digit* dst_p,
int low_i )
const;
328 virtual bool concat_get_data(
sc_digit* dst_p,
int low_i )
const;
356 unsigned int to_uint()
const;
357 long to_long()
const;
358 unsigned long to_ulong()
const;
359 int64 to_int64()
const;
361 double to_double()
const;
425 return operator = (
a->to_int64());
431 operator = (
unsigned long a)
443 operator = (
unsigned int a)
461 operator = (
double a)
472 virtual void concat_set(
int64 src,
int low_i);
473 virtual void concat_set(
const sc_signed &src,
int low_i);
474 virtual void concat_set(
const sc_unsigned &src,
int low_i);
475 virtual void concat_set(
uint64 src,
int low_i);
478 void scan(::std::istream &
is=::std::cin);
503 void invalid_length()
const;
504 void invalid_index(
int i)
const;
505 void invalid_range(
int l,
int r)
const;
518 if (i < 0 || i >= m_len) {
526 if (r < 0 || l >= m_len ||
l <
r) {
531 void check_value()
const;
539 m_val = (m_val << m_ulen >> m_ulen);
617 m_val =
a->to_int64();
636 operator = (
unsigned long a)
652 operator = (
unsigned int a)
676 operator = (
double a)
808 return a.m_val ==
b.m_val;
814 return a.m_val !=
b.m_val;
820 return a.m_val <
b.m_val;
826 return a.m_val <=
b.m_val;
832 return a.m_val >
b.m_val;
838 return a.m_val >=
b.m_val;
843 sc_int_bitref &operator [] (
int i);
844 const sc_int_bitref_r &operator [] (
int i)
const;
846 sc_int_bitref &bit(
int i);
847 const sc_int_bitref_r &bit(
int i)
const;
851 sc_int_subref &operator () (
int left,
int right);
852 const sc_int_subref_r &operator () (
int left,
int right)
const;
854 sc_int_subref &range(
int left,
int right);
855 const sc_int_subref_r &range(
int left,
int right)
const;
877 *xz_present_p =
false;
880 virtual bool concat_get_ctrl(
sc_digit* dst_p,
int low_i )
const;
881 virtual bool concat_get_data(
sc_digit* dst_p,
int low_i )
const;
890 virtual void concat_set(
int64 src,
int low_i);
891 virtual void concat_set(
const sc_signed &src,
int low_i);
892 virtual void concat_set(
const sc_unsigned &src,
int low_i);
893 virtual void concat_set(
uint64 src,
int low_i);
911 int to_int()
const {
return (
int)m_val; }
912 unsigned int to_uint()
const {
return (
unsigned int)m_val; }
914 unsigned long to_ulong()
const {
return (
unsigned long)m_val; }
934 void scan(::std::istream &
is=::std::cin);
954 inline sc_int_bitref_r::operator
uint64 ()
const
956 return m_obj_p->test(m_index);
960 sc_int_bitref_r::operator ! ()
const
962 return ! m_obj_p->test(m_index);
968 return !m_obj_p->test(m_index);
972 inline ::std::ostream &
988 inline sc_int_bitref &
991 m_obj_p->set(m_index, (
bool)
b);
992 m_obj_p->extend_sign();
999 m_obj_p->set(m_index, (
bool)
b);
1000 m_obj_p->extend_sign();
1005 sc_int_bitref::operator = (
bool b)
1007 m_obj_p->set(m_index,
b);
1008 m_obj_p->extend_sign();
1017 m_obj_p->set(m_index,
b);
1018 m_obj_p->extend_sign();
1027 m_obj_p->set(m_index,
b);
1028 m_obj_p->extend_sign();
1037 m_obj_p->m_val ^= (
UINT_ONE << m_index);
1038 m_obj_p->extend_sign();
1045 inline ::std::istream &
1065 int uright = uleft + m_right;
1066 return (
val << uleft >> uright);
1076 return a.and_reduce();
1083 return a.or_reduce();
1090 return a.xor_reduce();
1097 sc_int_subref_r::to_int()
const
1099 int result =
static_cast<int>(
operator uint_type());
1104 sc_int_subref_r::to_uint()
const
1106 unsigned int result =
static_cast<unsigned int>(
operator uint_type());
1111 sc_int_subref_r::to_long()
const
1113 long result =
static_cast<long>(
operator uint_type());
1117 inline unsigned long
1118 sc_int_subref_r::to_ulong()
const
1120 unsigned long result =
static_cast<unsigned long>(
operator uint_type());
1125 sc_int_subref_r::to_int64()
const
1132 sc_int_subref_r::to_uint64()
const
1139 sc_int_subref_r::to_double()
const
1141 double result =
static_cast<double>(
operator uint_type());
1148 inline const std::string
1153 return a.to_string(numrep);
1156 inline const std::string
1161 return a.to_string(numrep, w_prefix);
1170 return a.and_reduce();
1176 return a.nand_reduce();
1182 return a.or_reduce();
1188 return a.nor_reduce();
1194 return a.xor_reduce();
1200 return a.xnor_reduce();
1205 inline ::std::ostream &
1221 inline sc_int_subref &
1224 return operator = (
a.operator
int_type());
1228 sc_int_subref::operator = (
const char *
a)
1231 return (*
this =
aa =
a);
1236 inline ::std::istream &
1252 inline sc_int_bitref &
1253 sc_int_base::operator [] (
int i)
1262 sc_int_base::operator [] (
int i)
const
1272 sc_int_base::bit(
int i)
1281 sc_int_base::bit(
int i)
const
1293 sc_int_base::operator () (
int left,
int right)
1295 check_range(left, right);
1302 sc_int_base::operator () (
int left,
int right)
const
1304 check_range(left, right);
1312 sc_int_base::range(
int left,
int right)
1314 check_range(left, right);
1321 sc_int_base::range(
int left,
int right)
const
1323 check_range(left, right);
1335 return a.and_reduce();
1341 return a.nand_reduce();
1347 return a.or_reduce();
1353 return a.nor_reduce();
1359 return a.xor_reduce();
1365 return a.xnor_reduce();
1370 inline ::std::ostream &
1377 inline ::std::istream &
1386 #endif // __SYSTEMC_EXT_DT_INT_SC_INT_BASE_HH__
friend class sc_int_bitref_r
bool to_bool(const std::string &value, bool &retval)
Turn a string representation of a boolean into a boolean value.
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
friend class sc_int_signal
bool operator==(const sc_int_base &a, const sc_int_base &b)
void check_range(int l, int r) const
static sc_core::sc_vpool< sc_int_bitref > m_pool
const std::string to_string(sc_enc enc)
virtual uint64 concat_get_uint64() const
void initialize(const sc_int_base *obj_p, int left_i, int right_i)
virtual ~sc_int_subref_r()
bool operator>=(const sc_int_base &a, const sc_int_base &b)
bool operator<=(const sc_int_base &a, const sc_int_base &b)
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
bool sc_io_show_base(::std::ostream &os)
static const uint64 UINT_ONE
bool or_reduce(const sc_int_base &a)
bool xnor_reduce(const sc_int_base &a)
bool operator!=(const sc_int_base &a, const sc_int_base &b)
sc_int_base(int w=sc_length_param().len())
virtual uint64 concat_get_uint64() const
unsigned int to_uint() const
bool operator>(const sc_int_base &a, const sc_int_base &b)
virtual int concat_length(bool *xz_present_p) const
void print(::std::ostream &os=::std::cout) const
void print(::std::ostream &os=::std::cout) const
inline ::std::istream & operator>>(::std::istream &, sc_int_base &)
friend class sc_int_bitref
virtual bool concat_get_data(sc_digit *dst_p, int low_i) const
sc_numrep sc_io_base(::std::ostream &os, sc_numrep def_base)
sc_int_base(const sc_int_subref_r &a)
sc_int_subref_r(const sc_int_subref_r &a)
static const uint64 UINT64_32ONES
sc_int_base(int_type v, int w)
void check_index(int i) const
inline ::std::ostream & operator<<(::std::ostream &, const sc_int_base &)
bool nor_reduce(const sc_int_base &a)
virtual int concat_length(bool *xz_present_p) const
friend class sc_int_subref
bool xor_reduce(const sc_int_base &a)
void print(::std::ostream &os=::std::cout) const
sc_int_base(const sc_int_base &a)
static sc_core::sc_vpool< sc_int_subref > m_pool
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
friend class sc_int_subref
virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const
const sc_bit operator~(const sc_bit &a)
virtual ~sc_int_bitref_r()
const uint_type mask_int[SC_INTWIDTH][SC_INTWIDTH]
sc_int_bitref_r(const sc_int_bitref_r &a)
virtual uint64 concat_get_uint64() const
bool operator<(const sc_int_base &a, const sc_int_base &b)
friend class sc_int_subref_r
bool nand_reduce(const sc_int_base &a)
bool and_reduce(const sc_int_base &a)
sc_int_subref(const sc_int_subref &a)
sc_int_bitref(const sc_int_bitref &a)
void check_length() const
unsigned long to_ulong() const
sc_int_base(const sc_generic_base< T > &a)
void initialize(const sc_int_base *obj_p, int index_)
virtual int concat_length(bool *xz_present_p) const
Generated on Wed Sep 30 2020 14:02:16 for gem5 by doxygen 1.8.17