77 #ifndef __SYSTEMC_EXT_DT_MISC_SC_CONCATREF_HH__ 78 #define __SYSTEMC_EXT_DT_MISC_SC_CONCATREF_HH__ 82 #include "../bit/sc_bv.hh" 83 #include "../bit/sc_lv.hh" 84 #include "../int/sc_int_base.hh" 85 #include "../int/sc_signed.hh" 86 #include "../int/sc_uint_base.hh" 87 #include "../int/sc_unsigned.hh" 88 #include "../sc_temporary.hh" 134 m_flags = (left_xz || right_xz) ? cf_xz_present : cf_none;
148 m_flags = (left_xz || right_xz) ? cf_xz_present : cf_none;
155 unsigned int length()
const {
return m_len; }
162 *xz_present_p = m_flags & cf_xz_present ? true :
false;
169 m_left_p->concat_clear_data(to_ones);
170 m_right_p->concat_clear_data(to_ones);
176 bool rnz = m_right_p->concat_get_ctrl(dst_p, low_i);
177 bool lnz = m_left_p->concat_get_ctrl(dst_p, low_i + m_len_r);
184 bool rnz = m_right_p->concat_get_data(dst_p, low_i);
185 bool lnz = m_left_p->concat_get_data(dst_p, low_i + m_len_r);
193 return m_right_p->concat_get_uint64();
195 return (m_left_p->concat_get_uint64() << m_len_r) |
196 m_right_p->concat_get_uint64();
203 m_right_p->concat_set(src, low_i);
204 m_left_p->concat_set(src, low_i + m_len_r);
210 m_right_p->concat_set(src, low_i);
211 m_left_p->concat_set(src, low_i + m_len_r);
217 m_right_p->concat_set(src, low_i);
218 m_left_p->concat_set(src, low_i + m_len_r);
224 m_right_p->concat_set(src, low_i);
225 m_left_p->concat_set(src, low_i + m_len_r);
235 result = m_right_p->concat_get_uint64();
238 result = (m_left_p->concat_get_uint64() << m_len_r) |
239 (result & ~(mask << m_len_r));
243 result = result & ~(mask << m_len);
260 right_non_zero = m_right_p->concat_get_data(result_p->
digit, 0);
261 left_non_zero = m_left_p->concat_get_data(result_p->
digit, m_len_r);
262 if (left_non_zero || right_non_zero)
270 int to_int()
const {
return (
int)to_int64(); }
271 unsigned int to_uint()
const {
return (
unsigned int)to_uint64(); }
272 long to_long()
const {
return (
long)to_int64(); }
273 unsigned long to_ulong()
const {
return (
unsigned long)to_uint64(); }
274 double to_double()
const {
return value().to_double(); }
281 operator uint64 ()
const {
return to_uint64(); }
296 return value().to_string(numrep);
302 return value().to_string(numrep,w_prefix);
310 m_left_p->concat_set((
int64)v, m_len_r);
318 m_left_p->concat_set((
int64)v, m_len_r);
326 m_left_p->concat_set(v, m_len_r);
331 operator = (
unsigned int v)
334 m_left_p->concat_set((
uint64)v, m_len_r);
339 operator = (
unsigned long v)
342 m_left_p->concat_set((
uint64)v, m_len_r);
350 m_left_p->concat_set(v, m_len_r);
360 m_left_p->concat_set(temp, m_len_r);
368 m_left_p->concat_set(v, m_len_r);
376 m_left_p->concat_set(v, m_len_r);
381 operator = (
const char *v_p)
386 m_left_p->concat_set(v, m_len_r);
395 m_right_p->concat_set(temp, 0);
396 m_left_p->concat_set(temp, m_len_r);
405 m_right_p->concat_set(data, 0);
406 m_left_p->concat_set(data, m_len_r);
419 void print(::std::ostream &
os=::std::cout)
const {
os << this->value(); }
448 sc_concatref() : m_left_p(0), m_right_p(0), m_len(0), m_len_r(0), m_flags()
470 return target.
value() << (int)shift;
476 return target.
value() << (int)shift;
482 return target.
value() << (int)shift;
494 return target.
value() << (int)shift;
500 return target.
value() << (int)shift;
506 return target.
value() >> (int)shift;
512 return target.
value() >> (int)shift;
518 return target.
value() >> (int)shift;
530 return target.
value() >> (int)shift;
536 return target.
value() >> (int)shift;
540 inline ::std::ostream &
543 return os << v.
value();
546 inline ::std::istream &
589 *xz_present_p =
false;
598 dst_p[word_i] &= ~bit;
608 dst_p[word_i] |= bit;
610 dst_p[word_i] &= ~bit;
617 return m_value ? 1 : 0;
626 #define SC_CONCAT_OP_TYPE(RESULT, OP, OTHER_TYPE) \ 628 operator OP (const sc_concatref &a, OTHER_TYPE b) \ 630 return a.value() OP b; \ 633 operator OP (OTHER_TYPE a, const sc_concatref &b) \ 635 return a OP b.value(); \ 639 #define SC_CONCAT_OP(RESULT, OP) \ 641 operator OP (const sc_concatref &a, const sc_concatref &b) \ 643 return a.value() OP b.value(); \ 645 SC_CONCAT_OP_TYPE(const sc_signed, OP, int) \ 646 SC_CONCAT_OP_TYPE(const sc_signed, OP, long) \ 647 SC_CONCAT_OP_TYPE(const sc_signed, OP, int64) \ 648 SC_CONCAT_OP_TYPE(RESULT, OP, unsigned int) \ 649 SC_CONCAT_OP_TYPE(RESULT, OP, unsigned long) \ 650 SC_CONCAT_OP_TYPE(RESULT, OP, uint64) \ 651 SC_CONCAT_OP_TYPE(const sc_signed, OP, const sc_int_base &) \ 652 SC_CONCAT_OP_TYPE(RESULT, OP, const sc_uint_base &) \ 653 SC_CONCAT_OP_TYPE(const sc_signed, OP, const sc_signed &) \ 654 SC_CONCAT_OP_TYPE(RESULT, OP, const sc_unsigned &) \ 656 operator OP (const sc_concatref &a, bool b) \ 658 return a.value() OP (int)b; \ 661 operator OP (bool a, const sc_concatref &b) \ 663 return (int)a OP b.value(); \ 666 #define SC_CONCAT_BOOL_OP(OP) \ 668 operator OP (const sc_concatref &a, const sc_concatref &b) \ 670 return a.value() OP b.value(); \ 672 SC_CONCAT_OP_TYPE(bool, OP, int) \ 673 SC_CONCAT_OP_TYPE(bool, OP, long) \ 674 SC_CONCAT_OP_TYPE(bool, OP, int64) \ 675 SC_CONCAT_OP_TYPE(bool, OP, unsigned int) \ 676 SC_CONCAT_OP_TYPE(bool, OP, unsigned long) \ 677 SC_CONCAT_OP_TYPE(bool, OP, uint64) \ 678 SC_CONCAT_OP_TYPE(bool, OP, const sc_int_base &) \ 679 SC_CONCAT_OP_TYPE(bool, OP, const sc_uint_base &) \ 680 SC_CONCAT_OP_TYPE(bool, OP, const sc_signed &) \ 681 SC_CONCAT_OP_TYPE(bool, OP, const sc_unsigned &) \ 683 operator OP (const sc_concatref &a, bool b) \ 685 return a.value() OP (int)b; \ 688 operator OP (bool a, const sc_concatref &b) \ 690 return (int)a OP b.value(); \ 709 #undef SC_CONCAT_OP_TYPE 806 #endif // __SYSTEMC_EXT_DT_MISC_SC_CONCATREF_HH__
virtual void concat_set(int64 src, int low_i)
CLASS_TYPE operator~(const CLASS_TYPE &u)
virtual uint64 concat_get_uint64() const
virtual void concat_clear_data(bool to_ones)
virtual bool concat_get_data(sc_digit *dst_p, int low_i) const
static sc_core::sc_vpool< sc_concatref > m_pool
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
void scan(::std::istream &is)
const sc_unsigned & value() const
sc_concref_r< sc_bitref_r< T1 >, sc_bitref_r< T2 > > operator,(sc_bitref_r< T1 >, sc_bitref_r< T2 >)
#define SC_CONCAT_OP(RESULT, OP)
void print(::std::ostream &os=::std::cout) const
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
virtual void concat_set(const sc_signed &src, int low_i)
void to_sc_signed(sc_signed &target) const
sc_value_base * m_right_p
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
virtual void concat_set(int64 src, int low_i)
virtual void concat_set(uint64 src, int low_i)
virtual int concat_length(bool *xz_present_p) const
void scan(::std::istream &is=::std::cin)
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const
static sc_core::sc_vpool< sc_concat_bool > m_pool
virtual int concat_length(bool *xz_present_p=0) const
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
sc_byte_heap sc_temp_heap(0x300000)
virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const
#define SC_CONCAT_BOOL_OP(OP)
virtual uint64 concat_get_uint64() const
sc_signed operator>>(const sc_signed &u, const sc_int_base &v)
static sc_core::sc_vpool< sc_unsigned > m_pool
static sc_concat_bool * allocate(bool v)
int num_bits(int nb) const
void initialize(sc_value_base &left, sc_value_base &right)
unsigned int to_uint() const
virtual ~sc_concat_bool()
virtual void concat_set(const sc_unsigned &src, int low_i)
void initialize(const sc_value_base &left, const sc_value_base &right)
unsigned long to_ulong() const
virtual int concat_length(bool *xz_present_p) const
unsigned int length() const
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
sc_concref_r< sc_bitref_r< T1 >, sc_bitref_r< T2 > > concat(sc_bitref_r< T1 >, sc_bitref_r< T2 >)
void to_sc_unsigned(sc_unsigned &target) const
const std::string to_string(sc_numrep numrep, bool w_prefix) const
virtual bool concat_get_data(sc_digit *dst_p, int low_i) const
sc_signed operator+(const sc_unsigned &u, const sc_int_base &v)
const std::string to_string(sc_numrep numrep=SC_DEC) const
sc_signed operator-(const sc_unsigned &u, const sc_int_base &v)