⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sc_bit_proxies.h

📁 system C源码 一种替代verilog的语言
💻 H
📖 第 1 页 / 共 5 页
字号:
	this->m_obj.set_bit( this->m_index, a.value() );    }    return *this;}// bitwise assignment operatorstemplate <class X>inlinesc_bitref<X>&sc_bitref<X>::operator &= ( const sc_bitref_r<X>& a ){    if( &a != this ) {	this->m_obj.set_bit( this->m_index,			     sc_logic::and_table[this->value()][a.value()] );    }    return *this;}template <class X>inlinesc_bitref<X>&sc_bitref<X>::operator &= ( const sc_logic& a ){    this->m_obj.set_bit( this->m_index,			 sc_logic::and_table[this->value()][a.value()] );    return *this;}template <class X>inlinesc_bitref<X>&sc_bitref<X>::operator |= ( const sc_bitref_r<X>& a ){    if( &a != this ) {	this->m_obj.set_bit( this->m_index,			     sc_logic::or_table[this->value()][a.value()] );    }    return *this;}template <class X>inlinesc_bitref<X>&sc_bitref<X>::operator |= ( const sc_logic& a ){    this->m_obj.set_bit( this->m_index,			 sc_logic::or_table[this->value()][a.value()] );    return *this;}template <class X>inlinesc_bitref<X>&sc_bitref<X>::operator ^= ( const sc_bitref_r<X>& a ){    if( &a != this ) {	this->m_obj.set_bit( this->m_index,			     sc_logic::xor_table[this->value()][a.value()] );    }    return *this;}template <class X>inlinesc_bitref<X>&sc_bitref<X>::operator ^= ( const sc_logic& a ){    this->m_obj.set_bit( this->m_index,			 sc_logic::xor_table[this->value()][a.value()] );    return *this;}// bitwise operators and functions// bitwise complementtemplate <class X>inlinesc_bitref<X>&sc_bitref<X>::b_not(){    this->m_obj.set_bit( this->m_index,			 sc_logic::not_table[this->value()] );    return *this;}// common methodstemplate <class X>inlinevoidsc_bitref<X>::set_bit( int n, sc_logic_value_t value ){    if( n == 0 ) {	this->m_obj.set_bit( this->m_index, value );    } else {	SC_REPORT_ERROR( sc_core::SC_ID_OUT_OF_BOUNDS_, 0 );    }}template <class X>inlinevoidsc_bitref<X>::set_word( int n, sc_digit w ){    unsigned int bi = this->m_index % (8*sizeof(sc_digit));    sc_digit     temp;    unsigned int wi = this->m_index / (8*sizeof(sc_digit));    if( n == 0 ) {        temp = this->m_obj.get_word(wi);        temp = (temp & ~(1 << bi)) | ((w&1) << bi);        this->m_obj.set_word(wi, temp);    } else {        SC_REPORT_ERROR( sc_core::SC_ID_OUT_OF_BOUNDS_, 0 );    }}template <class X>inlinevoidsc_bitref<X>::set_cword( int n, sc_digit w ){    unsigned int bi = this->m_index % (8*sizeof(sc_digit));    sc_digit     temp;    unsigned int wi = this->m_index / (8*sizeof(sc_digit));    if( n == 0 ) {        temp = this->m_obj.get_cword(wi);        temp = (temp & ~(1 << bi)) | ((w&1) << bi);        this->m_obj.set_cword(wi, temp);    } else {        SC_REPORT_ERROR( sc_core::SC_ID_OUT_OF_BOUNDS_, 0 );    }}// other methodstemplate <class X>inlinevoidsc_bitref<X>::scan( ::std::istream& is ){    char c;    is >> c;    *this = c;}// l-value concatenation operators and functionstemplate <class T1, class T2>inlinesc_concref<sc_bitref<T1>,sc_bitref<T2> >operator , ( sc_bitref<T1> a, sc_bitref<T2> b ){    return sc_concref<sc_bitref<T1>,sc_bitref<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref<sc_bitref<T1>,sc_subref<T2> >operator , ( sc_bitref<T1> a, sc_subref<T2> b ){    return sc_concref<sc_bitref<T1>,sc_subref<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2, class T3>inlinesc_concref<sc_bitref<T1>,sc_concref<T2,T3> >operator , ( sc_bitref<T1> a, sc_concref<T2,T3> b ){    return sc_concref<sc_bitref<T1>,sc_concref<T2,T3> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref<sc_bitref<T1>,T2>operator , ( sc_bitref<T1> a, sc_proxy<T2>& b ){    return sc_concref<sc_bitref<T1>,T2>(	*a.clone(), b.back_cast(), 1 );}template <class T1, class T2>inlinesc_concref<sc_bitref<T1>,sc_bitref<T2> >concat( sc_bitref<T1> a, sc_bitref<T2> b ){    return sc_concref<sc_bitref<T1>,sc_bitref<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref<sc_bitref<T1>,sc_subref<T2> >concat( sc_bitref<T1> a, sc_subref<T2> b ){    return sc_concref<sc_bitref<T1>,sc_subref<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2, class T3>inlinesc_concref<sc_bitref<T1>,sc_concref<T2,T3> >concat( sc_bitref<T1> a, sc_concref<T2,T3> b ){    return sc_concref<sc_bitref<T1>,sc_concref<T2,T3> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref<sc_bitref<T1>,T2>concat( sc_bitref<T1> a, sc_proxy<T2>& b ){    return sc_concref<sc_bitref<T1>,T2>(	*a.clone(), b.back_cast(), 1 );}template <class X>inline::std::istream&operator >> ( ::std::istream& is, sc_bitref<X> a ){    a.scan( is );    return is;}// ----------------------------------------------------------------------------//  CLASS TEMPLATE : sc_subref_r<X>////  Proxy class for sc_proxy part selection (r-value only).// ----------------------------------------------------------------------------template <class X>inlinevoidsc_subref_r<X>::check_bounds(){    int len = m_obj.length();    if( m_hi < 0 || m_hi >= len || m_lo < 0 || m_lo >= len ) {	SC_REPORT_ERROR( sc_core::SC_ID_OUT_OF_BOUNDS_, 0 );    }    if( reversed() ) {	m_len = m_lo - m_hi + 1;    } else {	m_len = m_hi - m_lo + 1;    }}// common methodstemplate <class X>inlinesc_logic_value_tsc_subref_r<X>::get_bit( int n ) const{    if( reversed() ) {	return m_obj.get_bit( m_lo - n );    } else {	return m_obj.get_bit( m_lo + n );    }}template <class X>inlinevoidsc_subref_r<X>::set_bit( int n, sc_logic_value_t value ){    if( reversed() ) {	m_obj.set_bit( m_lo - n, value );    } else {	m_obj.set_bit( m_lo + n, value );    }}template <class X>inlinesc_digitsc_subref_r<X>::get_word( int i ) const{    int n1 = 0;    int n2 = 0;    sc_digit result = 0;    int k = 0;    if( reversed() ) {	n1 = m_lo - i * SC_DIGIT_SIZE;	n2 = sc_max( n1 - SC_DIGIT_SIZE, m_hi - 1 );	for( int n = n1; n > n2; n -- ) {	    result |= (m_obj[n].value() & SC_DIGIT_ONE) << k ++;	}    } else {	n1 = m_lo + i * SC_DIGIT_SIZE;	n2 = sc_min( n1 + SC_DIGIT_SIZE, m_hi + 1 );	for( int n = n1; n < n2; n ++ ) {	    result |= (m_obj[n].value() & SC_DIGIT_ONE) << k ++;	}    }    return result;}template <class X>inlinevoidsc_subref_r<X>::set_word( int i, sc_digit w ){    int n1 = 0;    int n2 = 0;    int k = 0;    if( reversed() ) {	n1 = m_lo - i * SC_DIGIT_SIZE;	n2 = sc_max( n1 - SC_DIGIT_SIZE, m_hi - 1 );	for( int n = n1; n > n2; n -- ) {	    m_obj.set_bit( n, sc_logic_value_t( (w >> k ++) & SC_DIGIT_ONE |						m_obj[n].value() & SC_DIGIT_TWO ) );	}    } else {	n1 = m_lo + i * SC_DIGIT_SIZE;	n2 = sc_min( n1 + SC_DIGIT_SIZE, m_hi + 1 );	for( int n = n1; n < n2; n ++ ) {	    m_obj.set_bit( n, sc_logic_value_t( (w >> k ++) & SC_DIGIT_ONE |						m_obj[n].value() & SC_DIGIT_TWO ) );	}    }}template <class X>inlinesc_digitsc_subref_r<X>::get_cword( int i ) const{    int n1 = 0;    int n2 = 0;    sc_digit result = 0;    int k = 0;    if( reversed() ) {	n1 = m_lo - i * SC_DIGIT_SIZE;	n2 = sc_max( n1 - SC_DIGIT_SIZE, m_hi - 1 );	for( int n = n1; n > n2; n -- ) {	    result |= ((m_obj[n].value() & SC_DIGIT_TWO) >> 1) << k ++;	}    } else {	n1 = m_lo + i * SC_DIGIT_SIZE;	n2 = sc_min( n1 + SC_DIGIT_SIZE, m_hi + 1 );	for( int n = n1; n < n2; n ++ ) {	    result |= ((m_obj[n].value() & SC_DIGIT_TWO) >> 1) << k ++;	}    }    return result;}template <class X>inlinevoidsc_subref_r<X>::set_cword( int i, sc_digit w ){    int n1 = 0;    int n2 = 0;    int k = 0;    if( reversed() ) {	n1 = m_lo - i * SC_DIGIT_SIZE;	n2 = sc_max( n1 - SC_DIGIT_SIZE, m_hi - 1 );	for( int n = n1; n > n2; n -- ) {	    m_obj.set_bit( n, sc_logic_value_t( ((w >> k ++) & SC_DIGIT_ONE) << 1 |						m_obj[n].value() & SC_DIGIT_ONE ) );	}    } else {	n1 = m_lo + i * SC_DIGIT_SIZE;	n2 = sc_min( n1 + SC_DIGIT_SIZE, m_hi + 1 );	for( int n = n1; n < n2; n ++ ) {	    m_obj.set_bit( n, sc_logic_value_t( ((w >> k ++) & SC_DIGIT_ONE) << 1 |						m_obj[n].value() & SC_DIGIT_ONE ) );	}    }}// other methodstemplate <class X>inlineboolsc_subref_r<X>::is_01() const{    int sz = size();    for( int i = 0; i < sz; ++ i ) {	if( get_cword( i ) != SC_DIGIT_ZERO ) {	    return false;	}    }    return true;}// r-value concatenation operators and functionstemplate <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,sc_bitref_r<T2> >operator , ( sc_subref_r<T1> a, sc_bitref_r<T2> b ){    return sc_concref_r<sc_subref_r<T1>,sc_bitref_r<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,sc_subref_r<T2> >operator , ( sc_subref_r<T1> a, sc_subref_r<T2> b ){    return sc_concref_r<sc_subref_r<T1>,sc_subref_r<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2, class T3>inlinesc_concref_r<sc_subref_r<T1>,sc_concref_r<T2,T3> >operator , ( sc_subref_r<T1> a, sc_concref_r<T2,T3> b ){    return sc_concref_r<sc_subref_r<T1>,sc_concref_r<T2,T3> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,T2>operator , ( sc_subref_r<T1> a, const sc_proxy<T2>& b ){    return sc_concref_r<sc_subref_r<T1>,T2>(	*a.clone(), b.back_cast(), 1 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,sc_bitref_r<T2> >concat( sc_subref_r<T1> a, sc_bitref_r<T2> b ){    return sc_concref_r<sc_subref_r<T1>,sc_bitref_r<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,sc_subref_r<T2> >concat( sc_subref_r<T1> a, sc_subref_r<T2> b ){    return sc_concref_r<sc_subref_r<T1>,sc_subref_r<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2, class T3>inlinesc_concref_r<sc_subref_r<T1>,sc_concref_r<T2,T3> >concat( sc_subref_r<T1> a, sc_concref_r<T2,T3> b ){    return sc_concref_r<sc_subref_r<T1>,sc_concref_r<T2,T3> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,T2>concat( sc_subref_r<T1> a, const sc_proxy<T2>& b ){    return sc_concref_r<sc_subref_r<T1>,T2>(	*a.clone(), b.back_cast(), 1 );}#ifdef SC_DT_MIXED_COMMA_OPERATORStemplate <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,sc_bitref_r<T2> >operator , ( sc_subref_r<T1> a, sc_bitref<T2> b ){    return sc_concref_r<sc_subref_r<T1>,sc_bitref_r<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,sc_bitref_r<T2> >operator , ( sc_subref<T1> a, sc_bitref_r<T2> b ){    return sc_concref_r<sc_subref_r<T1>,sc_bitref_r<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,sc_subref_r<T2> >operator , ( sc_subref_r<T1> a, sc_subref<T2> b ){    return sc_concref_r<sc_subref_r<T1>,sc_subref_r<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,sc_subref_r<T2> >operator , ( sc_subref<T1> a, sc_subref_r<T2> b ){    return sc_concref_r<sc_subref_r<T1>,sc_subref_r<T2> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2, class T3>inlinesc_concref_r<sc_subref_r<T1>,sc_concref_r<T2,T3> >operator , ( sc_subref_r<T1> a, sc_concref<T2,T3> b ){    return sc_concref_r<sc_subref_r<T1>,sc_concref_r<T2,T3> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2, class T3>inlinesc_concref_r<sc_subref_r<T1>,sc_concref_r<T2,T3> >operator , ( sc_subref<T1> a, sc_concref_r<T2,T3> b ){    return sc_concref_r<sc_subref_r<T1>,sc_concref_r<T2,T3> >(	*a.clone(), *b.clone(), 3 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,T2>operator , ( sc_subref<T1> a, const sc_proxy<T2>& b ){    return sc_concref_r<sc_subref_r<T1>,T2>(	*a.clone(), b.back_cast(), 1 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,T2>operator , ( sc_subref_r<T1> a, sc_proxy<T2>& b ){    return sc_concref_r<sc_subref_r<T1>,T2>(	*a.clone(), b.back_cast(), 1 );}template <class T1, class T2>inlinesc_concref_r<sc_subref_r<T1>,sc_bitref_r<T2> >concat( sc_subref_r<T1> a, 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -