sc_fxnum.h

来自「基于4个mips核的noc设计」· C头文件 代码 · 共 2,243 行 · 第 1/5 页

H
2,243
字号
ostream&operator << ( ostream& os, const sc_fxnum_fast_bitref& a ){    a.print( os );    return os;}inlineistream&operator >> ( istream& is, sc_fxnum_fast_bitref& a ){    a.scan( is );    return is;}// ----------------------------------------------------------------------------//  CLASS : sc_fxnum_subref////  Proxy class for part-selection in class sc_fxnum,//  behaves like sc_bv_base.// ----------------------------------------------------------------------------// constructorinlinesc_fxnum_subref::sc_fxnum_subref( sc_fxnum& num_, int from_, int to_ )    : m_num( num_ ), m_from( from_ ), m_to( to_ ),      m_bv( *new sc_bv_base( sc_max( m_from, m_to ) -			     sc_min( m_from, m_to ) + 1 ) ){}// copy constructorinlinesc_fxnum_subref::sc_fxnum_subref( const sc_fxnum_subref& a )    : m_num( a.m_num ), m_from( a.m_from ), m_to( a.m_to ),      m_bv( *new sc_bv_base( a.m_bv ) ){}// destructorinlinesc_fxnum_subref::~sc_fxnum_subref(){    delete &m_bv;}// assignment operatorsinlinesc_fxnum_subref&sc_fxnum_subref::operator = ( const sc_fxnum_subref& a ){    if( &a != this )    {	m_bv = static_cast<sc_bv_base>( a );	set();	SC_FXNUM_OBSERVER_WRITE_( m_num )    }    return *this;}inlinesc_fxnum_subref&sc_fxnum_subref::operator = ( const sc_fxnum_fast_subref& a ){    m_bv = static_cast<sc_bv_base>( a );    set();    SC_FXNUM_OBSERVER_WRITE_( m_num )    return *this;}#define DEFN_ASN_OP_T(tp)                                                     \inline                                                                        \sc_fxnum_subref&                                                              \sc_fxnum_subref::operator = ( tp a )                                          \{                                                                             \    m_bv = a;                                                                 \    set();                                                                    \    SC_FXNUM_OBSERVER_WRITE_( m_num )                                         \    return *this;                                                             \}DEFN_ASN_OP_T(const sc_bv_base&)DEFN_ASN_OP_T(const sc_lv_base&)DEFN_ASN_OP_T(const char*)DEFN_ASN_OP_T(const bool*)DEFN_ASN_OP_T(const sc_signed&)DEFN_ASN_OP_T(const sc_unsigned&)DEFN_ASN_OP_T(const sc_int_base&)DEFN_ASN_OP_T(const sc_uint_base&)DEFN_ASN_OP_T(int64)DEFN_ASN_OP_T(uint64)DEFN_ASN_OP_T(int)DEFN_ASN_OP_T(unsigned int)DEFN_ASN_OP_T(long)DEFN_ASN_OP_T(unsigned long)DEFN_ASN_OP_T(char)#undef DEFN_ASN_OP_T#define DEFN_ASN_OP_T(op,tp)                                                  \inline                                                                        \sc_fxnum_subref&                                                              \sc_fxnum_subref::operator op ## = ( tp a )                                    \{                                                                             \    SC_FXNUM_OBSERVER_READ_( m_num )                                          \    get();                                                                    \    m_bv = m_bv op a;                                                         \    set();                                                                    \    SC_FXNUM_OBSERVER_WRITE_( m_num )                                         \    return *this;                                                             \}#define DEFN_ASN_OP(op)                                                       \inline                                                                        \sc_fxnum_subref&                                                              \sc_fxnum_subref::operator op ## = ( const sc_fxnum_subref& a )                \{                                                                             \    SC_FXNUM_OBSERVER_READ_( m_num )                                          \    get();                                                                    \    m_bv = m_bv op static_cast<sc_bv_base>( a );                              \    set();                                                                    \    SC_FXNUM_OBSERVER_WRITE_( m_num )                                         \    return *this;                                                             \}                                                                             \                                                                              \inline                                                                        \sc_fxnum_subref&                                                              \sc_fxnum_subref::operator op ## = ( const sc_fxnum_fast_subref& a )           \{                                                                             \    SC_FXNUM_OBSERVER_READ_( m_num )                                          \    get();                                                                    \    m_bv = m_bv op static_cast<sc_bv_base>( a );                              \    set();                                                                    \    SC_FXNUM_OBSERVER_WRITE_( m_num )                                         \    return *this;                                                             \}                                                                             \                                                                              \DEFN_ASN_OP_T(op,const sc_bv_base&)                                           \DEFN_ASN_OP_T(op,const sc_lv_base&)DEFN_ASN_OP(&)DEFN_ASN_OP(|)DEFN_ASN_OP(^)#undef DEFN_ASN_OP_T#undef DEFN_ASN_OP// relational operators#define DEFN_REL_OP_T(op,tp)                                                  \inline                                                                        \bool                                                                          \operator op ( const sc_fxnum_subref& a, tp b )                                \{                                                                             \    return ( static_cast<sc_bv_base>( a ) op b );                             \}                                                                             \                                                                              \inline                                                                        \bool                                                                          \operator op ( tp a, const sc_fxnum_subref& b )                                \{                                                                             \    return ( static_cast<sc_bv_base>( b ) op a );                             \}#define DEFN_REL_OP(op)                                                       \inline                                                                        \bool                                                                          \operator op ( const sc_fxnum_subref& a, const sc_fxnum_subref& b )            \{                                                                             \    return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) );  \}                                                                             \                                                                              \inline                                                                        \bool                                                                          \operator op ( const sc_fxnum_subref& a, const sc_fxnum_fast_subref& b )       \{                                                                             \    return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) );  \}                                                                             \                                                                              \DEFN_REL_OP_T(op,const sc_bv_base&)                                           \DEFN_REL_OP_T(op,const sc_lv_base&)                                           \DEFN_REL_OP_T(op,const char*)                                                 \DEFN_REL_OP_T(op,const bool*)                                                 \DEFN_REL_OP_T(op,const sc_signed&)                                            \DEFN_REL_OP_T(op,const sc_unsigned&)                                          \DEFN_REL_OP_T(op,int)                                                         \DEFN_REL_OP_T(op,unsigned int)                                                \DEFN_REL_OP_T(op,long)                                                        \DEFN_REL_OP_T(op,unsigned long)DEFN_REL_OP(==)DEFN_REL_OP(!=)#undef DEFN_REL_OP_T#undef DEFN_REL_OP// reduce functions#define DEFN_RED_FNC(fnc)                                                     \inline                                                                        \bool                                                                          \sc_fxnum_subref::fnc() const                                                  \{                                                                             \    SC_FXNUM_OBSERVER_READ_( m_num )                                          \    get();                                                                    \    return static_cast<bool>( m_bv.fnc() );                                   \}DEFN_RED_FNC(and_reduce)DEFN_RED_FNC(nand_reduce)DEFN_RED_FNC(or_reduce)DEFN_RED_FNC(nor_reduce)DEFN_RED_FNC(xor_reduce)DEFN_RED_FNC(xnor_reduce)#undef DEFN_RED_FNC// query parameterinlineintsc_fxnum_subref::length() const{    return m_bv.length();}// explicit conversionsinlineintsc_fxnum_subref::to_int() const{    SC_FXNUM_OBSERVER_READ_( m_num )    get();    return m_bv.to_int();}inlineunsigned intsc_fxnum_subref::to_uint() const{    SC_FXNUM_OBSERVER_READ_( m_num )    get();    return m_bv.to_uint();}inlinelongsc_fxnum_subref::to_long() const{    SC_FXNUM_OBSERVER_READ_( m_num )    get();    return m_bv.to_long();}inlineunsigned longsc_fxnum_subref::to_ulong() const{    SC_FXNUM_OBSERVER_READ_( m_num )    get();    return m_bv.to_ulong();}#ifdef SC_DT_DEPRECATEDinlineintsc_fxnum_subref::to_signed() const{    return to_int();}inlineunsigned intsc_fxnum_subref::to_unsigned() const{    return to_uint();}#endifinlineconst sc_stringsc_fxnum_subref::to_string() const{    get();    return m_bv.to_string();}inlineconst sc_stringsc_fxnum_subref::to_string( sc_numrep numrep ) const{    get();    return m_bv.to_string( numrep );}inlineconst sc_stringsc_fxnum_subref::to_string( sc_numrep numrep, bool w_prefix ) const{    get();    return m_bv.to_string( numrep, w_prefix );}// implicit conversioninlinesc_fxnum_subref::operator sc_bv_base () const{    SC_FXNUM_OBSERVER_READ_( m_num )    get();    return m_bv;}inlineostream&operator << ( ostream& os, const sc_fxnum_subref& a ){    a.print( os );    return os;}inlineistream&operator >> ( istream& is, sc_fxnum_subref& a ){    a.scan( is );    return is;}// ----------------------------------------------------------------------------//  CLASS : sc_fxnum_fast_subref////  Proxy class for part-selection in class sc_fxnum_fast,//  behaves like sc_bv_base.// ----------------------------------------------------------------------------// constructorinlinesc_fxnum_fast_subref::sc_fxnum_fast_subref( sc_fxnum_fast& num_,					    int from_, int to_ )    : m_num( num_ ), m_from( from_ ), m_to( to_ ),      m_bv( *new sc_bv_base( sc_max( m_from, m_to ) -			     sc_min( m_from, m_to ) + 1 ) ){}// copy constructorinlinesc_fxnum_fast_subref::sc_fxnum_fast_subref( const sc_fxnum_fast_subref& a )    : m_num( a.m_num ), m_from( a.m_from ), m_to( a.m_to ),      m_bv( *new sc_bv_base( a.m_bv ) ){}// destructorinlinesc_fxnum_fast_subref::~sc_fxnum_fast_subref(){    delete &m_bv;}// assignment operatorsinlinesc_fxnum_fast_subref&sc_fxnum_fast_subref::operator = ( const sc_fxnum_subref& a ){    m_bv = static_cast<sc_bv_base>( a );    set();    SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )    return *this;}inlinesc_fxnum_fast_subref&sc_fxnum_fast_subref::operator = ( const sc_fxnum_fast_subref& a ){    if( &a != this )    {	m_bv = static_cast<sc_bv_base>( a );	set();	SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )    }    return *this;}#define DEFN_ASN_OP_T(tp)                                                     \inline                                                                        \sc_fxnum_fast_subref&                                                         \sc_fxnum_fast_subref::operator = ( tp a )                                     \{                                                                             \    m_bv = a;                                                                 \    set();                                                                    \    SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )                                    \    return *this;                                                             \}DEFN_ASN_OP_T(const sc_bv_base&)DEFN_ASN_OP_T(const sc_lv_base&)DEFN_ASN_OP_T(const char*)DEFN_ASN_OP_T(const bool*)DEFN_ASN_OP_T(const sc_signed&)DEFN_ASN_OP_T(const sc_unsigned&)DEFN_ASN_OP_T(const sc_int_base&)DEFN_ASN_OP_T(const sc_uint_base&)DEFN_ASN_OP_T(int64)DEFN_ASN_OP_T(uint64)DEFN_ASN_OP_T(int)DEFN_ASN_OP_T(unsigned int)DEFN_ASN_OP_T(long)DEFN_ASN_OP_T(unsigned long)DEFN_ASN_OP_T(char)#undef DEFN_ASN_OP_T#define DEFN_ASN_OP_T(op,tp)                                                  \inline                                                                        \sc_fxnum_fast_subref&                                                         \sc_fxnum_fast_subref::operator op ## = ( tp a )                               \{                                                                             \    SC_FXNUM_FAST_OBSERVER_READ_( m_num )                                     \    get();                                                                    \    m_bv = m_bv op a;                          

⌨️ 快捷键说明

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