src/sysc/datatypes/bit/sc_lv_base.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2005 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.4 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_lv_base.h -- Arbitrary size logic vector class.
00021 
00022   Original Author: Gene Bushuyev, Synopsys, Inc.
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033         Andy Goodrich, Forte Design Systems
00034           Fixed bug in clean_tail for sizes that are modulo 32, which caused
00035           zeroing of values.
00036 
00037  *****************************************************************************/
00038 
00039 #ifndef SC_LV_BASE_H
00040 #define SC_LV_BASE_H
00041 
00042 
00043 #include "sysc/datatypes/bit/sc_bit_ids.h"
00044 #include "sysc/datatypes/bit/sc_bv_base.h"
00045 #include "sysc/datatypes/bit/sc_logic.h"
00046 #include "sysc/datatypes/int/sc_length_param.h"
00047 
00048 
00049 namespace sc_dt
00050 {
00051 
00052 // classes defined in this module
00053 class sc_lv_base;
00054 
00055 
00056 // ----------------------------------------------------------------------------
00057 //  CLASS : sc_lv_base
00058 //
00059 //  Arbitrary size logic vector base class.
00060 // ----------------------------------------------------------------------------
00061 
00062 class sc_lv_base
00063     : public sc_proxy<sc_lv_base>
00064 {
00065     friend class sc_bv_base;
00066 
00067 
00068     void init( int length_, const sc_logic& init_value = SC_LOGIC_X );
00069 
00070     void assign_from_string( const std::string& );
00071 
00072 public:
00073 
00074     // typedefs
00075 
00076     typedef sc_proxy<sc_lv_base> base_type;
00077 
00078 
00079     // constructors
00080 
00081     explicit sc_lv_base( int length_ = sc_length_param().len() )
00082         : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
00083         { init( length_ ); }
00084 
00085     explicit sc_lv_base( const sc_logic& a,
00086                          int length_ = sc_length_param().len()  )
00087         : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
00088         { init( length_, a ); }
00089 
00090     sc_lv_base( const char* a );
00091 
00092     sc_lv_base( const char* a, int length_ );
00093 
00094     template <class X>
00095     sc_lv_base( const sc_proxy<X>& a )
00096         : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
00097         { init( a.back_cast().length() ); base_type::assign_( a ); }
00098 
00099     sc_lv_base( const sc_lv_base& a );
00100 
00101 #ifdef SC_DT_DEPRECATED
00102 
00103     explicit sc_lv_base( const sc_unsigned& a )
00104         : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
00105         { init( a.length() ); base_type::assign_( a ); }
00106 
00107     explicit sc_lv_base( const sc_signed& a )
00108         : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
00109         { init( a.length() ); base_type::assign_( a ); }
00110 
00111     explicit sc_lv_base( const sc_uint_base& a )
00112         : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
00113         { init( a.length() ); base_type::assign_( a ); }
00114 
00115     explicit sc_lv_base( const sc_int_base& a )
00116         : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
00117         { init( a.length() ); base_type::assign_( a ); }
00118 
00119 #endif
00120 
00121 
00122     // destructor
00123 
00124     virtual ~sc_lv_base()
00125         { if( m_data != 0 ) delete [] m_data; }
00126 
00127 
00128     // assignment operators
00129 
00130     template <class X>
00131     sc_lv_base& operator = ( const sc_proxy<X>& a )
00132         { assign_p_( *this, a ); return *this; }
00133 
00134     sc_lv_base& operator = ( const sc_lv_base& a )
00135         { assign_p_( *this, a ); return *this; }
00136 
00137     sc_lv_base& operator = ( const char* a );
00138 
00139     sc_lv_base& operator = ( const bool* a )
00140         { base_type::assign_( a ); return *this; }
00141 
00142     sc_lv_base& operator = ( const sc_logic* a )
00143         { base_type::assign_( a ); return *this; }
00144 
00145     sc_lv_base& operator = ( const sc_unsigned& a )
00146         { base_type::assign_( a ); return *this; }
00147 
00148     sc_lv_base& operator = ( const sc_signed& a )
00149         { base_type::assign_( a ); return *this; }
00150 
00151     sc_lv_base& operator = ( const sc_uint_base& a )
00152         { base_type::assign_( a ); return *this; }
00153 
00154     sc_lv_base& operator = ( const sc_int_base& a )
00155         { base_type::assign_( a ); return *this; }
00156 
00157     sc_lv_base& operator = ( unsigned long a )
00158         { base_type::assign_( a ); return *this; }
00159 
00160     sc_lv_base& operator = ( long a )
00161         { base_type::assign_( a ); return *this; }
00162 
00163     sc_lv_base& operator = ( unsigned int a )
00164         { base_type::assign_( a ); return *this; }
00165 
00166     sc_lv_base& operator = ( int a )
00167         { base_type::assign_( a ); return *this; }
00168 
00169     sc_lv_base& operator = ( uint64 a )
00170         { base_type::assign_( a ); return *this; }
00171 
00172     sc_lv_base& operator = ( int64 a )
00173         { base_type::assign_( a ); return *this; }
00174 
00175 
00176 #if 0
00177 
00178     // bitwise complement
00179 
00180     sc_lv_base& b_not()
00181         { return sc_proxy<sc_lv_base>::b_not(); }
00182 
00183     const sc_lv_base operator ~ () const
00184         { sc_lv_base a( *this ); return a.b_not(); }
00185 
00186 
00187     // bitwise left shift
00188 
00189     sc_lv_base& operator <<= ( int n )
00190         { return sc_proxy<sc_lv_base>::operator <<= ( n ); }
00191 
00192     const sc_lv_base operator << ( int n ) const
00193         { sc_lv_base a( *this ); return ( a <<= n ); }
00194 
00195 
00196     // bitwise right shift
00197 
00198     sc_lv_base& operator >>= ( int n )
00199         { return sc_proxy<sc_lv_base>::operator >>= ( n ); }
00200 
00201     const sc_lv_base operator >> ( int n ) const
00202         { sc_lv_base a( *this ); return ( a >>= n ); }
00203 
00204 
00205     // bitwise left rotate
00206 
00207     sc_lv_base& lrotate( int n )
00208         { return sc_proxy<sc_lv_base>::lrotate( n ); }
00209 
00210 
00211     // bitwise right rotate
00212 
00213     sc_lv_base& rrotate( int n )
00214         { return sc_proxy<sc_lv_base>::rrotate( n ); }
00215 
00216 #endif
00217 
00218 
00219     // common methods
00220 
00221     int length() const
00222         { return m_len; }
00223 
00224     int size() const
00225         { return m_size; }
00226 
00227     sc_logic_value_t get_bit( int i ) const;
00228     void set_bit( int i, sc_logic_value_t value );
00229 
00230     unsigned long get_word( int wi ) const
00231         { return m_data[wi]; }
00232 
00233     void set_word( int wi, unsigned long w )
00234         { m_data[wi] = w; }
00235          
00236 
00237     unsigned long get_cword( int wi ) const
00238         { return m_ctrl[wi]; }
00239 
00240     void set_cword( int wi, unsigned long w )
00241         { m_ctrl[wi] = w; }
00242 
00243     void clean_tail();
00244 
00245 
00246     // other methods
00247 
00248     bool is_01() const;
00249 
00250 protected:
00251 
00252     int            m_len;   // length in bits
00253     int            m_size;  // size of the data array
00254     unsigned long* m_data;  // data array
00255     unsigned long* m_ctrl;  // dito (control part)
00256 };
00257 
00258 
00259 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00260 
00261 #if 0
00262 
00263 // bitwise left rotate
00264 
00265 inline
00266 const sc_lv_base
00267 lrotate( const sc_lv_base& x, int n )
00268 {
00269     sc_lv_base a( x );
00270     return a.lrotate( n );
00271 }
00272 
00273 
00274 // bitwise right rotate
00275 
00276 inline
00277 const sc_lv_base
00278 rrotate( const sc_lv_base& x, int n )
00279 {
00280     sc_lv_base a( x );
00281     return a.rrotate( n );
00282 }
00283 
00284 #endif
00285 
00286 
00287 inline
00288 sc_logic_value_t
00289 sc_lv_base::get_bit( int i ) const
00290 {
00291     int wi = i / UL_SIZE;
00292     int bi = i % UL_SIZE;
00293     return sc_logic_value_t( m_data[wi] >> bi & UL_ONE |
00294                              m_ctrl[wi] >> bi << 1 & UL_TWO );
00295 }
00296 
00297 inline
00298 void
00299 sc_lv_base::set_bit( int i, sc_logic_value_t value )
00300 {
00301     int wi = i / UL_SIZE; // word index
00302     int bi = i % UL_SIZE; // bit index
00303     unsigned long mask = UL_ONE << bi;
00304     m_data[wi] |= mask; // set bit to 1
00305     m_ctrl[wi] |= mask; // set bit to 1
00306     m_data[wi] &= value << bi | ~mask;
00307     m_ctrl[wi] &= value >> 1 << bi | ~mask;
00308 }
00309 
00310 
00311 inline
00312 void
00313 sc_lv_base::clean_tail()
00314 {
00315     int wi = m_size - 1;
00316     int bi = m_len % UL_SIZE;
00317     unsigned long mask = ~UL_ZERO >> (UL_SIZE - bi);
00318         if ( mask )
00319         {
00320                 m_data[wi] &= mask;
00321                 m_ctrl[wi] &= mask;
00322         }
00323 }
00324 
00325 
00326 // ----------------------------------------------------------------------------
00327 //  CLASS TEMPLATE : sc_proxy
00328 //
00329 //  Base class template for bit/logic vector classes.
00330 //  (Barton/Nackmann implementation)
00331 // ----------------------------------------------------------------------------
00332 
00333 // bitwise operators and functions
00334 
00335 // bitwise complement
00336 
00337 template <class X>
00338 inline
00339 const sc_lv_base
00340 sc_proxy<X>::operator ~ () const
00341 {
00342     sc_lv_base a( back_cast() );
00343     return a.b_not();
00344 }
00345 
00346 
00347 // bitwise and
00348 
00349 template <class X, class Y>
00350 inline
00351 X&
00352 operator &= ( sc_proxy<X>& px, const sc_proxy<Y>& py )
00353 {
00354     X& x = px.back_cast();
00355     sc_lv_base a( x.length() );
00356     a = py.back_cast();
00357     return b_and_assign_( x, a );
00358 }
00359 
00360 
00361 #define DEFN_BITWISE_AND_ASN_OP_T(tp)                                         \
00362 template <class X>                                                            \
00363 inline                                                                        \
00364 X&                                                                            \
00365 sc_proxy<X>::operator &= ( tp b )                                             \
00366 {                                                                             \
00367     X& x = back_cast();                                                       \
00368     sc_lv_base a( x.length() );                                               \
00369     a = b;                                                                    \
00370     return b_and_assign_( x, a );                                             \
00371 }
00372 
00373 DEFN_BITWISE_AND_ASN_OP_T(const char*)
00374 DEFN_BITWISE_AND_ASN_OP_T(const bool*)
00375 DEFN_BITWISE_AND_ASN_OP_T(const sc_logic*)
00376 DEFN_BITWISE_AND_ASN_OP_T(const sc_unsigned&)
00377 DEFN_BITWISE_AND_ASN_OP_T(const sc_signed&)
00378 DEFN_BITWISE_AND_ASN_OP_T(unsigned long)
00379 DEFN_BITWISE_AND_ASN_OP_T(long)
00380 DEFN_BITWISE_AND_ASN_OP_T(uint64)
00381 DEFN_BITWISE_AND_ASN_OP_T(int64)
00382 
00383 #undef DEFN_BITWISE_AND_ASN_OP_T
00384 
00385 
00386 template <class X, class Y>
00387 inline
00388 const sc_lv_base
00389 operator & ( const sc_proxy<X>& px, const sc_proxy<Y>& py )
00390 {
00391     sc_lv_base a( px.back_cast() );
00392     return ( a &= py.back_cast() );
00393 }
00394 
00395 
00396 #define DEFN_BITWISE_AND_OP_T_A(tp)                                           \
00397 template <class X>                                                            \
00398 inline                                                                        \
00399 const sc_lv_base                                                              \
00400 sc_proxy<X>::operator & ( tp b ) const                                        \
00401 {                                                                             \
00402     sc_lv_base a( back_cast() );                                              \
00403     return ( a &= b );                                                        \
00404 }
00405 
00406 DEFN_BITWISE_AND_OP_T_A(const char*)
00407 DEFN_BITWISE_AND_OP_T_A(const bool*)
00408 DEFN_BITWISE_AND_OP_T_A(const sc_logic*)
00409 DEFN_BITWISE_AND_OP_T_A(const sc_unsigned&)
00410 DEFN_BITWISE_AND_OP_T_A(const sc_signed&)
00411 DEFN_BITWISE_AND_OP_T_A(const sc_uint_base&)
00412 DEFN_BITWISE_AND_OP_T_A(const sc_int_base&)
00413 DEFN_BITWISE_AND_OP_T_A(unsigned long)
00414 DEFN_BITWISE_AND_OP_T_A(long)
00415 DEFN_BITWISE_AND_OP_T_A(unsigned int)
00416 DEFN_BITWISE_AND_OP_T_A(int)
00417 DEFN_BITWISE_AND_OP_T_A(uint64)
00418 DEFN_BITWISE_AND_OP_T_A(int64)
00419 
00420 #undef DEFN_BITWISE_AND_OP_T_A
00421 
00422 
00423 #define DEFN_BITWISE_AND_OP_T_B(tp)                                           \
00424 template <class X>                                                            \
00425 inline                                                                        \
00426 const sc_lv_base                                                              \
00427 operator & ( tp b, const sc_proxy<X>& px )                                    \
00428 {                                                                             \
00429     return ( px & b );                                                        \
00430 }
00431 
00432 DEFN_BITWISE_AND_OP_T_B(const char*)
00433 DEFN_BITWISE_AND_OP_T_B(const bool*)
00434 DEFN_BITWISE_AND_OP_T_B(const sc_logic*)
00435 DEFN_BITWISE_AND_OP_T_B(const sc_unsigned&)
00436 DEFN_BITWISE_AND_OP_T_B(const sc_signed&)
00437 DEFN_BITWISE_AND_OP_T_B(const sc_uint_base&)
00438 DEFN_BITWISE_AND_OP_T_B(const sc_int_base&)
00439 DEFN_BITWISE_AND_OP_T_B(unsigned long)
00440 DEFN_BITWISE_AND_OP_T_B(long)
00441 DEFN_BITWISE_AND_OP_T_B(unsigned int)
00442 DEFN_BITWISE_AND_OP_T_B(int)
00443 DEFN_BITWISE_AND_OP_T_B(uint64)
00444 DEFN_BITWISE_AND_OP_T_B(int64)
00445 
00446 #undef DEFN_BITWISE_AND_OP_T_B
00447 
00448 
00449 // bitwise or
00450 
00451 template <class X, class Y>
00452 inline
00453 X&
00454 operator |= ( sc_proxy<X>& px, const sc_proxy<Y>& py )
00455 {
00456     X& x = px.back_cast();
00457     sc_lv_base a( x.length() );
00458     a = py.back_cast();
00459     return b_or_assign_( x, a );
00460 }
00461 
00462 
00463 #define DEFN_BITWISE_OR_ASN_OP_T(tp)                                          \
00464 template <class X>                                                            \
00465 inline                                                                        \
00466 X&                                                                            \
00467 sc_proxy<X>::operator |= ( tp b )                                             \
00468 {                                                                             \
00469     X& x = back_cast();                                                       \
00470     sc_lv_base a( x.length() );                                               \
00471     a = b;                                                                    \
00472     return b_or_assign_( x, a );                                              \
00473 }
00474 
00475 DEFN_BITWISE_OR_ASN_OP_T(const char*)
00476 DEFN_BITWISE_OR_ASN_OP_T(const bool*)
00477 DEFN_BITWISE_OR_ASN_OP_T(const sc_logic*)
00478 DEFN_BITWISE_OR_ASN_OP_T(const sc_unsigned&)
00479 DEFN_BITWISE_OR_ASN_OP_T(const sc_signed&)
00480 DEFN_BITWISE_OR_ASN_OP_T(unsigned long)
00481 DEFN_BITWISE_OR_ASN_OP_T(long)
00482 DEFN_BITWISE_OR_ASN_OP_T(uint64)
00483 DEFN_BITWISE_OR_ASN_OP_T(int64)
00484 
00485 #undef DEFN_BITWISE_OR_ASN_OP_T
00486 
00487 
00488 template <class X, class Y>
00489 inline
00490 const sc_lv_base
00491 operator | ( const sc_proxy<X>& px, const sc_proxy<Y>& py )
00492 {
00493     sc_lv_base a( px.back_cast() );
00494     return ( a |= py.back_cast() );
00495 }
00496 
00497 
00498 #define DEFN_BITWISE_OR_OP_T_A(tp)                                            \
00499 template <class X>                                                            \
00500 inline                                                                        \
00501 const sc_lv_base                                                              \
00502 sc_proxy<X>::operator | ( tp b ) const                                        \
00503 {                                                                             \
00504     sc_lv_base a( back_cast() );                                              \
00505     return ( a |= b );                                                        \
00506 }
00507 
00508 DEFN_BITWISE_OR_OP_T_A(const char*)
00509 DEFN_BITWISE_OR_OP_T_A(const bool*)
00510 DEFN_BITWISE_OR_OP_T_A(const sc_logic*)
00511 DEFN_BITWISE_OR_OP_T_A(const sc_unsigned&)
00512 DEFN_BITWISE_OR_OP_T_A(const sc_signed&)
00513 DEFN_BITWISE_OR_OP_T_A(const sc_uint_base&)
00514 DEFN_BITWISE_OR_OP_T_A(const sc_int_base&)
00515 DEFN_BITWISE_OR_OP_T_A(unsigned long)
00516 DEFN_BITWISE_OR_OP_T_A(long)
00517 DEFN_BITWISE_OR_OP_T_A(unsigned int)
00518 DEFN_BITWISE_OR_OP_T_A(int)
00519 DEFN_BITWISE_OR_OP_T_A(uint64)
00520 DEFN_BITWISE_OR_OP_T_A(int64)
00521 
00522 #undef DEFN_BITWISE_OR_OP_T_A
00523 
00524 
00525 #define DEFN_BITWISE_OR_OP_T_B(tp)                                           \
00526 template <class X>                                                            \
00527 inline                                                                        \
00528 const sc_lv_base                                                              \
00529 operator | ( tp b, const sc_proxy<X>& px )                                    \
00530 {                                                                             \
00531     return ( px | b );                                                        \
00532 }
00533 
00534 DEFN_BITWISE_OR_OP_T_B(const char*)
00535 DEFN_BITWISE_OR_OP_T_B(const bool*)
00536 DEFN_BITWISE_OR_OP_T_B(const sc_logic*)
00537 DEFN_BITWISE_OR_OP_T_B(const sc_unsigned&)
00538 DEFN_BITWISE_OR_OP_T_B(const sc_signed&)
00539 DEFN_BITWISE_OR_OP_T_B(const sc_uint_base&)
00540 DEFN_BITWISE_OR_OP_T_B(const sc_int_base&)
00541 DEFN_BITWISE_OR_OP_T_B(unsigned long)
00542 DEFN_BITWISE_OR_OP_T_B(long)
00543 DEFN_BITWISE_OR_OP_T_B(unsigned int)
00544 DEFN_BITWISE_OR_OP_T_B(int)
00545 DEFN_BITWISE_OR_OP_T_B(uint64)
00546 DEFN_BITWISE_OR_OP_T_B(int64)
00547 
00548 #undef DEFN_BITWISE_OR_OP_T_B
00549 
00550 
00551 // bitwise xor
00552 
00553 template <class X, class Y>
00554 inline
00555 X&
00556 operator ^= ( sc_proxy<X>& px, const sc_proxy<Y>& py )
00557 {
00558     X& x = px.back_cast();
00559     sc_lv_base a( x.length() );
00560     a = py.back_cast();
00561     return b_xor_assign_( x, a );
00562 }
00563 
00564 
00565 #define DEFN_BITWISE_XOR_ASN_OP_T(tp)                                         \
00566 template <class X>                                                            \
00567 inline                                                                        \
00568 X&                                                                            \
00569 sc_proxy<X>::operator ^= ( tp b )                                             \
00570 {                                                                             \
00571     X& x = back_cast();                                                       \
00572     sc_lv_base a( x.length() );                                               \
00573     a = b;                                                                    \
00574     return b_xor_assign_( x, a );                                             \
00575 }
00576 
00577 DEFN_BITWISE_XOR_ASN_OP_T(const char*)
00578 DEFN_BITWISE_XOR_ASN_OP_T(const bool*)
00579 DEFN_BITWISE_XOR_ASN_OP_T(const sc_logic*)
00580 DEFN_BITWISE_XOR_ASN_OP_T(const sc_unsigned&)
00581 DEFN_BITWISE_XOR_ASN_OP_T(const sc_signed&)
00582 DEFN_BITWISE_XOR_ASN_OP_T(unsigned long)
00583 DEFN_BITWISE_XOR_ASN_OP_T(long)
00584 DEFN_BITWISE_XOR_ASN_OP_T(uint64)
00585 DEFN_BITWISE_XOR_ASN_OP_T(int64)
00586 
00587 #undef DEFN_BITWISE_XOR_ASN_OP_T
00588 
00589 
00590 template <class X, class Y>
00591 inline
00592 const sc_lv_base
00593 operator ^ ( const sc_proxy<X>& px, const sc_proxy<Y>& py )
00594 {
00595     sc_lv_base a( px.back_cast() );
00596     return ( a ^= py.back_cast() );
00597 }
00598 
00599 
00600 #define DEFN_BITWISE_XOR_OP_T_A(tp)                                           \
00601 template <class X>                                                            \
00602 inline                                                                        \
00603 const sc_lv_base                                                              \
00604 sc_proxy<X>::operator ^ ( tp b ) const                                        \
00605 {                                                                             \
00606     sc_lv_base a( back_cast() );                                              \
00607     return ( a ^= b );                                                        \
00608 }
00609 
00610 DEFN_BITWISE_XOR_OP_T_A(const char*)
00611 DEFN_BITWISE_XOR_OP_T_A(const bool*)
00612 DEFN_BITWISE_XOR_OP_T_A(const sc_logic*)
00613 DEFN_BITWISE_XOR_OP_T_A(const sc_unsigned&)
00614 DEFN_BITWISE_XOR_OP_T_A(const sc_signed&)
00615 DEFN_BITWISE_XOR_OP_T_A(const sc_uint_base&)
00616 DEFN_BITWISE_XOR_OP_T_A(const sc_int_base&)
00617 DEFN_BITWISE_XOR_OP_T_A(unsigned long)
00618 DEFN_BITWISE_XOR_OP_T_A(long)
00619 DEFN_BITWISE_XOR_OP_T_A(unsigned int)
00620 DEFN_BITWISE_XOR_OP_T_A(int)
00621 DEFN_BITWISE_XOR_OP_T_A(uint64)
00622 DEFN_BITWISE_XOR_OP_T_A(int64)
00623 
00624 #undef DEFN_BITWISE_XOR_OP_T_A
00625 
00626 
00627 #define DEFN_BITWISE_XOR_OP_T_B(tp)                                           \
00628 template <class X>                                                            \
00629 inline                                                                        \
00630 const sc_lv_base                                                              \
00631 operator ^ ( tp b, const sc_proxy<X>& px )                                    \
00632 {                                                                             \
00633     return ( px ^ b );                                                        \
00634 }
00635 
00636 DEFN_BITWISE_XOR_OP_T_B(const char*)
00637 DEFN_BITWISE_XOR_OP_T_B(const bool*)
00638 DEFN_BITWISE_XOR_OP_T_B(const sc_logic*)
00639 DEFN_BITWISE_XOR_OP_T_B(const sc_unsigned&)
00640 DEFN_BITWISE_XOR_OP_T_B(const sc_signed&)
00641 DEFN_BITWISE_XOR_OP_T_B(const sc_uint_base&)
00642 DEFN_BITWISE_XOR_OP_T_B(const sc_int_base&)
00643 DEFN_BITWISE_XOR_OP_T_B(unsigned long)
00644 DEFN_BITWISE_XOR_OP_T_B(long)
00645 DEFN_BITWISE_XOR_OP_T_B(unsigned int)
00646 DEFN_BITWISE_XOR_OP_T_B(int)
00647 DEFN_BITWISE_XOR_OP_T_B(uint64)
00648 DEFN_BITWISE_XOR_OP_T_B(int64)
00649 
00650 #undef DEFN_BITWISE_XOR_OP_T_B
00651 
00652 
00653 // bitwise left shift
00654 
00655 template <class X>
00656 inline
00657 const sc_lv_base
00658 sc_proxy<X>::operator << ( int n ) const
00659 {
00660     sc_lv_base a( back_cast().length()+n );
00661         a = back_cast();
00662     return ( a <<= n );
00663 }
00664 
00665 
00666 // bitwise right shift
00667 
00668 template <class X>
00669 inline
00670 const sc_lv_base
00671 sc_proxy<X>::operator >> ( int n ) const
00672 {
00673     sc_lv_base a( back_cast() );
00674     return ( a >>= n );
00675 }
00676 
00677 
00678 // bitwise left rotate
00679 
00680 template <class X>
00681 inline
00682 X&
00683 sc_proxy<X>::lrotate( int n )
00684 {
00685     X& x = back_cast();
00686     if( n < 0 ) {
00687         char msg[BUFSIZ];
00688         sprintf( msg,
00689                  "left rotate operation is only allowed with positive "
00690                  "rotate values, rotate value = %d", n );
00691         SC_REPORT_ERROR( sc_core::SC_ID_OUT_OF_BOUNDS_, msg );
00692     }
00693     int len = x.length();
00694     n %= len;
00695     // x = (x << n) | (x >> (len - n));
00696     sc_lv_base a( x << n );
00697     sc_lv_base b( x >> (len - n) );
00698     int sz = x.size();
00699     for( int i = 0; i < sz; ++ i ) {
00700         x.set_word( i, a.get_word( i ) | b.get_word( i ) );
00701         x.set_cword( i, a.get_cword( i ) | b.get_cword( i ) );
00702     }
00703     x.clean_tail();
00704     return x;
00705 }
00706 
00707 template <class X>
00708 inline
00709 const sc_lv_base
00710 lrotate( const sc_proxy<X>& x, int n )
00711 {
00712     sc_lv_base a( x.back_cast() );
00713     return a.lrotate( n );
00714 }
00715 
00716 
00717 // bitwise right rotate
00718 
00719 template <class X>
00720 inline
00721 X&
00722 sc_proxy<X>::rrotate( int n )
00723 {
00724     X& x = back_cast();
00725     if( n < 0 ) {
00726         char msg[BUFSIZ];
00727         sprintf( msg,
00728                  "right rotate operation is only allowed with positive "
00729                  "rotate values, rotate value = %d", n );
00730         SC_REPORT_ERROR( sc_core::SC_ID_OUT_OF_BOUNDS_, msg );
00731     }
00732     int len = x.length();
00733     n %= len;
00734     // x = (x >> n) | (x << (len - n));
00735     sc_lv_base a( x >> n );
00736     sc_lv_base b( x << (len - n) );
00737     int sz = x.size();
00738     for( int i = 0; i < sz; ++ i ) {
00739         x.set_word( i, a.get_word( i ) | b.get_word( i ) );
00740         x.set_cword( i, a.get_cword( i ) | b.get_cword( i ) );
00741     }
00742     x.clean_tail();
00743     return x;
00744 }
00745 
00746 template <class X>
00747 inline
00748 const sc_lv_base
00749 rrotate( const sc_proxy<X>& x, int n )
00750 {
00751     sc_lv_base a( x.back_cast() );
00752     return a.rrotate( n );
00753 }
00754 
00755 
00756 // bitwise reverse
00757 
00758 template <class X>
00759 inline
00760 const sc_lv_base
00761 reverse( const sc_proxy<X>& x )
00762 {
00763     sc_lv_base a( x.back_cast() );
00764     return a.reverse();
00765 }
00766 
00767 
00768 // relational operators
00769 
00770 template <class X, class Y>
00771 inline
00772 bool
00773 operator == ( const sc_proxy<X>& px, const sc_proxy<Y>& py )
00774 {
00775     const X& x = px.back_cast();
00776     const Y& y = py.back_cast();
00777     int x_len = x.length();
00778     int y_len = y.length();
00779     if( x_len != y_len ) {
00780         return false;
00781     }
00782     int sz = x.size();
00783     for( int i = 0; i < sz; ++ i ) {
00784         if( x.get_word( i ) != y.get_word( i ) ||
00785             x.get_cword( i ) != y.get_cword( i ) ) {
00786             return false;
00787         }
00788     }
00789     return true;
00790 }
00791 
00792 
00793 #define DEFN_REL_OP_T(tp)                                                     \
00794 template <class X>                                                            \
00795 inline                                                                        \
00796 bool                                                                          \
00797 sc_proxy<X>::operator == ( tp b ) const                                       \
00798 {                                                                             \
00799     const X& x = back_cast();                                                 \
00800     sc_lv_base y( x.length() );                                               \
00801     y = b;                                                                    \
00802     return ( x == y );                                                        \
00803 }
00804 
00805 DEFN_REL_OP_T(const char*)
00806 DEFN_REL_OP_T(const bool*)
00807 DEFN_REL_OP_T(const sc_logic*)
00808 DEFN_REL_OP_T(const sc_unsigned&)
00809 DEFN_REL_OP_T(const sc_signed&)
00810 DEFN_REL_OP_T(const sc_uint_base&)
00811 DEFN_REL_OP_T(const sc_int_base&)
00812 DEFN_REL_OP_T(unsigned long)
00813 DEFN_REL_OP_T(long)
00814 DEFN_REL_OP_T(unsigned int)
00815 DEFN_REL_OP_T(int)
00816 DEFN_REL_OP_T(uint64)
00817 DEFN_REL_OP_T(int64)
00818 
00819 #undef DEFN_REL_OP_T
00820 
00821 
00822 // ----------------------------------------------------------------------------
00823 //  CLASS TEMPLATE : sc_bitref_r<X>
00824 //
00825 //  Proxy class for sc_proxy bit selection (r-value only).
00826 // ----------------------------------------------------------------------------
00827 
00828 // r-value concatenation operators and functions
00829 
00830 template <class T>
00831 inline
00832 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
00833 operator , ( sc_bitref_r<T> a, const char* b )
00834 {
00835     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
00836         *a.clone(), *new sc_lv_base( b ), 3 );
00837 }
00838 
00839 template <class T>
00840 inline
00841 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
00842 operator , ( const char* a, sc_bitref_r<T> b )
00843 {
00844     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
00845         *new sc_lv_base( a ), *b.clone(), 3 );
00846 }
00847 
00848 template <class T>
00849 inline
00850 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
00851 operator , ( sc_bitref_r<T> a, const sc_logic& b )
00852 {
00853     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
00854         *a.clone(), *new sc_lv_base( b, 1 ) );
00855 }
00856 
00857 template <class T>
00858 inline
00859 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
00860 operator , ( const sc_logic& a, sc_bitref_r<T> b )
00861 {
00862     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
00863         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
00864 }
00865 
00866 template <class T>
00867 inline
00868 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
00869 operator , ( sc_bitref_r<T> a, bool b )
00870 {
00871     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
00872         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ) );
00873 }
00874 
00875 template <class T>
00876 inline
00877 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
00878 operator , ( bool a, sc_bitref_r<T> b )
00879 {
00880     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
00881         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
00882 }
00883 
00884 
00885 template <class T>
00886 inline
00887 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
00888 concat( sc_bitref_r<T> a, const char* b )
00889 {
00890     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
00891         *a.clone(), *new sc_lv_base( b ), 3 );
00892 }
00893 
00894 template <class T>
00895 inline
00896 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
00897 concat( const char* a, sc_bitref_r<T> b )
00898 {
00899     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
00900         *new sc_lv_base( a ), *b.clone(), 3 );
00901 }
00902 
00903 template <class T>
00904 inline
00905 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
00906 concat( sc_bitref_r<T> a, const sc_logic& b )
00907 {
00908     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
00909         *a.clone(), *new sc_lv_base( b, 1 ) );
00910 }
00911 
00912 template <class T>
00913 inline
00914 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
00915 concat( const sc_logic& a, sc_bitref_r<T> b )
00916 {
00917     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
00918         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
00919 }
00920 
00921 template <class T>
00922 inline
00923 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
00924 concat( sc_bitref_r<T> a, bool b )
00925 {
00926     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
00927         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ) );
00928 }
00929 
00930 template <class T>
00931 inline
00932 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
00933 concat( bool a, sc_bitref_r<T> b )
00934 {
00935     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
00936         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
00937 }
00938 
00939 
00940 #ifdef SC_DT_MIXED_COMMA_OPERATORS
00941 
00942 template <class T>
00943 inline
00944 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
00945 operator , ( sc_bitref<T> a, const char* b )
00946 {
00947     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
00948         *a.clone(), *new sc_lv_base( b ), 3 );
00949 }
00950 
00951 template <class T>
00952 inline
00953 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
00954 operator , ( const char* a, sc_bitref<T> b )
00955 {
00956     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
00957         *new sc_lv_base( a ), *b.clone(), 3 );
00958 }
00959 
00960 template <class T>
00961 inline
00962 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
00963 operator , ( sc_bitref<T> a, const sc_logic& b )
00964 {
00965     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
00966         *a.clone(), *new sc_lv_base( b, 1 ) );
00967 }
00968 
00969 template <class T>
00970 inline
00971 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
00972 operator , ( const sc_logic& a, sc_bitref<T> b )
00973 {
00974     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
00975         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
00976 }
00977 
00978 template <class T>
00979 inline
00980 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
00981 operator , ( sc_bitref<T> a, bool b )
00982 {
00983     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
00984         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ) );
00985 }
00986 
00987 template <class T>
00988 inline
00989 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
00990 operator , ( bool a, sc_bitref<T> b )
00991 {
00992     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
00993         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
00994 }
00995 
00996 
00997 template <class T>
00998 inline
00999 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
01000 concat( sc_bitref<T> a, const char* b )
01001 {
01002     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
01003         *a.clone(), *new sc_lv_base( b ), 3 );
01004 }
01005 
01006 template <class T>
01007 inline
01008 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
01009 concat( const char* a, sc_bitref<T> b )
01010 {
01011     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
01012         *new sc_lv_base( a ), *b.clone(), 3 );
01013 }
01014 
01015 template <class T>
01016 inline
01017 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
01018 concat( sc_bitref<T> a, const sc_logic& b )
01019 {
01020     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
01021         *a.clone(), *new sc_lv_base( b, 1 ) );
01022 }
01023 
01024 template <class T>
01025 inline
01026 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
01027 concat( const sc_logic& a, sc_bitref<T> b )
01028 {
01029     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
01030         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
01031 }
01032 
01033 template <class T>
01034 inline
01035 sc_concref_r<sc_bitref_r<T>,sc_lv_base>
01036 concat( sc_bitref<T> a, bool b )
01037 {
01038     return sc_concref_r<sc_bitref_r<T>,sc_lv_base>(
01039         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ) );
01040 }
01041 
01042 template <class T>
01043 inline
01044 sc_concref_r<sc_lv_base,sc_bitref_r<T> >
01045 concat( bool a, sc_bitref<T> b )
01046 {
01047     return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
01048         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
01049 }
01050 
01051 #endif
01052 
01053 
01054 // ----------------------------------------------------------------------------
01055 //  CLASS TEMPLATE : sc_subref_r<X>
01056 //
01057 //  Proxy class for sc_proxy part selection (r-value only).
01058 // ----------------------------------------------------------------------------
01059 
01060 // r-value concatenation operators and functions
01061 
01062 template <class T>
01063 inline
01064 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01065 operator , ( sc_subref_r<T> a, const char* b )
01066 {
01067     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01068         *a.clone(), *new sc_lv_base( b ), 3 );
01069 }
01070 
01071 template <class T>
01072 inline
01073 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01074 operator , ( const char* a, sc_subref_r<T> b )
01075 {
01076     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01077         *new sc_lv_base( a ), *b.clone(), 3 );
01078 }
01079 
01080 template <class T>
01081 inline
01082 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01083 operator , ( sc_subref_r<T> a, const sc_logic& b )
01084 {
01085     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01086         *a.clone(), *new sc_lv_base( b, 1 ), 3 );
01087 }
01088 
01089 template <class T>
01090 inline
01091 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01092 operator , ( const sc_logic& a, sc_subref_r<T> b )
01093 {
01094     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01095         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
01096 }
01097 
01098 template <class T>
01099 inline
01100 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01101 operator , ( sc_subref_r<T> a, bool b )
01102 {
01103     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01104         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ), 3 );
01105 }
01106 
01107 template <class T>
01108 inline
01109 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01110 operator , ( bool a, sc_subref_r<T> b )
01111 {
01112     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01113         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
01114 }
01115 
01116 
01117 template <class T>
01118 inline
01119 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01120 concat( sc_subref_r<T> a, const char* b )
01121 {
01122     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01123         *a.clone(), *new sc_lv_base( b ), 3 );
01124 }
01125 
01126 template <class T>
01127 inline
01128 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01129 concat( const char* a, sc_subref_r<T> b )
01130 {
01131     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01132         *new sc_lv_base( a ), *b.clone(), 3 );
01133 }
01134 
01135 template <class T>
01136 inline
01137 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01138 concat( sc_subref_r<T> a, const sc_logic& b )
01139 {
01140     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01141         *a.clone(), *new sc_lv_base( b, 1 ), 3 );
01142 }
01143 
01144 template <class T>
01145 inline
01146 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01147 concat( const sc_logic& a, sc_subref_r<T> b )
01148 {
01149     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01150         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
01151 }
01152 
01153 template <class T>
01154 inline
01155 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01156 concat( sc_subref_r<T> a, bool b )
01157 {
01158     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01159         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ), 3 );
01160 }
01161 
01162 template <class T>
01163 inline
01164 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01165 concat( bool a, sc_subref_r<T> b )
01166 {
01167     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01168         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
01169 }
01170 
01171 
01172 #ifdef SC_DT_MIXED_COMMA_OPERATORS
01173 
01174 template <class T>
01175 inline
01176 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01177 operator , ( sc_subref<T> a, const char* b )
01178 {
01179     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01180         *a.clone(), *new sc_lv_base( b ), 3 );
01181 }
01182 
01183 template <class T>
01184 inline
01185 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01186 operator , ( const char* a, sc_subref<T> b )
01187 {
01188     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01189         *new sc_lv_base( a ), *b.clone(), 3 );
01190 }
01191 
01192 template <class T>
01193 inline
01194 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01195 operator , ( sc_subref<T> a, const sc_logic& b )
01196 {
01197     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01198         *a.clone(), *new sc_lv_base( b, 1 ), 3 );
01199 }
01200 
01201 template <class T>
01202 inline
01203 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01204 operator , ( const sc_logic& a, sc_subref<T> b )
01205 {
01206     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01207         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
01208 }
01209 
01210 template <class T>
01211 inline
01212 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01213 operator , ( sc_subref<T> a, bool b )
01214 {
01215     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01216         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ), 3 );
01217 }
01218 
01219 template <class T>
01220 inline
01221 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01222 operator , ( bool a, sc_subref<T> b )
01223 {
01224     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01225         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
01226 }
01227 
01228 
01229 template <class T>
01230 inline
01231 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01232 concat( sc_subref<T> a, const char* b )
01233 {
01234     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01235         *a.clone(), *new sc_lv_base( b ), 3 );
01236 }
01237 
01238 template <class T>
01239 inline
01240 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01241 concat( const char* a, sc_subref<T> b )
01242 {
01243     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01244         *new sc_lv_base( a ), *b.clone(), 3 );
01245 }
01246 
01247 template <class T>
01248 inline
01249 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01250 concat( sc_subref<T> a, const sc_logic& b )
01251 {
01252     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01253         *a.clone(), *new sc_lv_base( b, 1 ), 3 );
01254 }
01255 
01256 template <class T>
01257 inline
01258 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01259 concat( const sc_logic& a, sc_subref<T> b )
01260 {
01261     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01262         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
01263 }
01264 
01265 template <class T>
01266 inline
01267 sc_concref_r<sc_subref_r<T>,sc_lv_base>
01268 concat( sc_subref<T> a, bool b )
01269 {
01270     return sc_concref_r<sc_subref_r<T>,sc_lv_base>(
01271         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ), 3 );
01272 }
01273 
01274 template <class T>
01275 inline
01276 sc_concref_r<sc_lv_base,sc_subref_r<T> >
01277 concat( bool a, sc_subref<T> b )
01278 {
01279     return sc_concref_r<sc_lv_base,sc_subref_r<T> >(
01280         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
01281 }
01282 
01283 #endif
01284 
01285 
01286 // ----------------------------------------------------------------------------
01287 //  CLASS TEMPLATE : sc_subref<X>
01288 //
01289 //  Proxy class for sc_proxy part selection (r-value and l-value).
01290 // ----------------------------------------------------------------------------
01291 
01292 template <class X>
01293 inline
01294 sc_subref<X>&
01295 sc_subref<X>::operator = ( const sc_subref_r<X>& b )
01296 {
01297     sc_lv_base t( b ); // (partial) self assignment protection
01298     int len = sc_min( this->length(), t.length() );
01299     if( ! this->reversed() ) {
01300         for( int i = len - 1; i >= 0; -- i ) {
01301             this->m_obj.set_bit( this->m_lo + i, t[i].value() );
01302         }
01303     } else {
01304         for( int i = len - 1; i >= 0; -- i ) {
01305             this->m_obj.set_bit( this->m_lo - i, t[i].value() );
01306         }
01307     }
01308     return *this;
01309 }
01310 
01311 template <class X>
01312 inline
01313 sc_subref<X>&
01314 sc_subref<X>::operator = ( const sc_subref<X>& b )
01315 {
01316     sc_lv_base t( b ); // (partial) self assignment protection
01317     int len = sc_min( this->length(), t.length() );
01318     if( ! this->reversed() ) {
01319         for( int i = len - 1; i >= 0; -- i ) {
01320             this->m_obj.set_bit( this->m_lo + i, t[i].value() );
01321         }
01322     } else {
01323         for( int i = len - 1; i >= 0; -- i ) {
01324             this->m_obj.set_bit( this->m_lo - i, t[i].value() );
01325         }
01326     }
01327     return *this;
01328 }
01329 
01330 
01331 // ----------------------------------------------------------------------------
01332 //  CLASS TEMPLATE : sc_concref_r<X,Y>
01333 //
01334 //  Proxy class for sc_proxy concatenation (r-value only).
01335 // ----------------------------------------------------------------------------
01336 
01337 // r-value concatenation operators and functions
01338 
01339 template <class T1, class T2>
01340 inline
01341 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01342 operator , ( sc_concref_r<T1,T2> a, const char* b )
01343 {
01344     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01345         *a.clone(), *new sc_lv_base( b ), 3 );
01346 }
01347 
01348 template <class T1, class T2>
01349 inline
01350 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01351 operator , ( const char* a, sc_concref_r<T1,T2> b )
01352 {
01353     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01354         *new sc_lv_base( a ), *b.clone(), 3 );
01355 }
01356 
01357 template <class T1, class T2>
01358 inline
01359 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01360 operator , ( sc_concref_r<T1,T2> a, const sc_logic& b )
01361 {
01362     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01363         *a.clone(), *new sc_lv_base( b, 1 ), 3 );
01364 }
01365 
01366 template <class T1, class T2>
01367 inline
01368 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01369 operator , ( const sc_logic& a, sc_concref_r<T1,T2> b )
01370 {
01371     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01372         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
01373 }
01374 
01375 template <class T1, class T2>
01376 inline
01377 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01378 operator , ( sc_concref_r<T1,T2> a, bool b )
01379 {
01380     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01381         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ), 3 );
01382 }
01383 
01384 template <class T1, class T2>
01385 inline
01386 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01387 operator , ( bool a, sc_concref_r<T1,T2> b )
01388 {
01389     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01390         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
01391 }
01392 
01393 
01394 template <class T1, class T2>
01395 inline
01396 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01397 concat( sc_concref_r<T1,T2> a, const char* b )
01398 {
01399     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01400         *a.clone(), *new sc_lv_base( b ), 3 );
01401 }
01402 
01403 template <class T1, class T2>
01404 inline
01405 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01406 concat( const char* a, sc_concref_r<T1,T2> b )
01407 {
01408     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01409         *new sc_lv_base( a ), *b.clone(), 3 );
01410 }
01411 
01412 template <class T1, class T2>
01413 inline
01414 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01415 concat( sc_concref_r<T1,T2> a, const sc_logic& b )
01416 {
01417     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01418         *a.clone(), *new sc_lv_base( b, 1 ), 3 );
01419 }
01420 
01421 template <class T1, class T2>
01422 inline
01423 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01424 concat( const sc_logic& a, sc_concref_r<T1,T2> b )
01425 {
01426     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01427         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
01428 }
01429 
01430 template <class T1, class T2>
01431 inline
01432 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01433 concat( sc_concref_r<T1,T2> a, bool b )
01434 {
01435     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01436         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ), 3 );
01437 }
01438 
01439 template <class T1, class T2>
01440 inline
01441 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01442 concat( bool a, sc_concref_r<T1,T2> b )
01443 {
01444     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01445         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
01446 }
01447 
01448 
01449 #ifdef SC_DT_MIXED_COMMA_OPERATORS
01450 
01451 template <class T1, class T2>
01452 inline
01453 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01454 operator , ( sc_concref<T1,T2> a, const char* b )
01455 {
01456     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01457         *a.clone(), *new sc_lv_base( b ), 3 );
01458 }
01459 
01460 template <class T1, class T2>
01461 inline
01462 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01463 operator , ( const char* a, sc_concref<T1,T2> b )
01464 {
01465     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01466         *new sc_lv_base( a ), *b.clone(), 3 );
01467 }
01468 
01469 template <class T1, class T2>
01470 inline
01471 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01472 operator , ( sc_concref<T1,T2> a, const sc_logic& b )
01473 {
01474     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01475         *a.clone(), *new sc_lv_base( b, 1 ), 3 );
01476 }
01477 
01478 template <class T1, class T2>
01479 inline
01480 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01481 operator , ( const sc_logic& a, sc_concref<T1,T2> b )
01482 {
01483     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01484         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
01485 }
01486 
01487 template <class T1, class T2>
01488 inline
01489 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01490 operator , ( sc_concref<T1,T2> a, bool b )
01491 {
01492     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01493         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ), 3 );
01494 }
01495 
01496 template <class T1, class T2>
01497 inline
01498 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01499 operator , ( bool a, sc_concref<T1,T2> b )
01500 {
01501     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01502         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
01503 }
01504 
01505 
01506 template <class T1, class T2>
01507 inline
01508 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01509 concat( sc_concref<T1,T2> a, const char* b )
01510 {
01511     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01512         *a.clone(), *new sc_lv_base( b ), 3 );
01513 }
01514 
01515 template <class T1, class T2>
01516 inline
01517 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01518 concat( const char* a, sc_concref<T1,T2> b )
01519 {
01520     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01521         *new sc_lv_base( a ), *b.clone(), 3 );
01522 }
01523 
01524 template <class T1, class T2>
01525 inline
01526 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01527 concat( sc_concref<T1,T2> a, const sc_logic& b )
01528 {
01529     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01530         *a.clone(), *new sc_lv_base( b, 1 ), 3 );
01531 }
01532 
01533 template <class T1, class T2>
01534 inline
01535 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01536 concat( const sc_logic& a, sc_concref<T1,T2> b )
01537 {
01538     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01539         *new sc_lv_base( a, 1 ), *b.clone(), 3 );
01540 }
01541 
01542 template <class T1, class T2>
01543 inline
01544 sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
01545 concat( sc_concref<T1,T2> a, bool b )
01546 {
01547     return sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>(
01548         *a.clone(), *new sc_lv_base( sc_logic( b ), 1 ), 3 );
01549 }
01550 
01551 template <class T1, class T2>
01552 inline
01553 sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
01554 concat( bool a, sc_concref<T1,T2> b )
01555 {
01556     return sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >(
01557         *new sc_lv_base( sc_logic( a ), 1 ), *b.clone(), 3 );
01558 }
01559 
01560 #endif
01561 
01562 
01563 // ----------------------------------------------------------------------------
01564 //  CLASS TEMPLATE : sc_proxy<T>
01565 //
01566 //  Base class template for bit/logic vector classes.
01567 //  (Barton/Nackmann implementation)
01568 // ----------------------------------------------------------------------------
01569 
01570 // r-value concatenation operators and functions
01571 
01572 template <class T>
01573 inline
01574 sc_concref_r<T,sc_lv_base>
01575 operator , ( const sc_proxy<T>& a, const char* b )
01576 {
01577     return sc_concref_r<T,sc_lv_base>(
01578         a.back_cast(), *new sc_lv_base( b ), 2 );
01579 }
01580 
01581 template <class T>
01582 inline
01583 sc_concref_r<sc_lv_base,T>
01584 operator , ( const char* a, const sc_proxy<T>& b )
01585 {
01586     return sc_concref_r<sc_lv_base,T>(
01587         *new sc_lv_base( a ), b.back_cast(), 1 );
01588 }
01589 
01590 template <class T>
01591 inline
01592 sc_concref_r<T,sc_lv_base>
01593 operator , ( const sc_proxy<T>& a, const sc_logic& b )
01594 {
01595     return sc_concref_r<T,sc_lv_base>(
01596         a.back_cast(), *new sc_lv_base( b, 1 ), 2 );
01597 }
01598 
01599 template <class T>
01600 inline
01601 sc_concref_r<sc_lv_base,T>
01602 operator , ( const sc_logic& a, const sc_proxy<T>& b )
01603 {
01604     return sc_concref_r<sc_lv_base,T>(
01605         *new sc_lv_base( a, 1 ), b.back_cast(), 1 );
01606 }
01607 
01608 template <class T>
01609 inline
01610 sc_concref_r<T,sc_lv_base>
01611 operator , ( const sc_proxy<T>& a, bool b )
01612 {
01613     return sc_concref_r<T,sc_lv_base>(
01614         a.back_cast(), *new sc_lv_base( sc_logic( b ), 1 ), 2 );
01615 }
01616 
01617 template <class T>
01618 inline
01619 sc_concref_r<sc_lv_base,T>
01620 operator , ( bool a, const sc_proxy<T>& b )
01621 {
01622     return sc_concref_r<sc_lv_base,T>(
01623         *new sc_lv_base( sc_logic( a ), 1 ), b.back_cast(), 1 );
01624 }
01625 
01626 
01627 template <class T>
01628 inline
01629 sc_concref_r<T,sc_lv_base>
01630 concat( const sc_proxy<T>& a, const char* b )
01631 {
01632     return sc_concref_r<T,sc_lv_base>(
01633         a.back_cast(), *new sc_lv_base( b ), 2 );
01634 }
01635 
01636 template <class T>
01637 inline
01638 sc_concref_r<sc_lv_base,T>
01639 concat( const char* a, const sc_proxy<T>& b )
01640 {
01641     return sc_concref_r<sc_lv_base,T>(
01642         *new sc_lv_base( a ), b.back_cast(), 1 );
01643 }
01644 
01645 template <class T>
01646 inline
01647 sc_concref_r<T,sc_lv_base>
01648 concat( const sc_proxy<T>& a, const sc_logic& b )
01649 {
01650     return sc_concref_r<T,sc_lv_base>(
01651         a.back_cast(), *new sc_lv_base( b, 1 ), 2 );
01652 }
01653 
01654 template <class T>
01655 inline
01656 sc_concref_r<sc_lv_base,T>
01657 concat( const sc_logic& a, const sc_proxy<T>& b )
01658 {
01659     return sc_concref_r<sc_lv_base,T>(
01660         *new sc_lv_base( a, 1 ), b.back_cast(), 1 );
01661 }
01662 
01663 template <class T>
01664 inline
01665 sc_concref_r<T,sc_lv_base>
01666 concat( const sc_proxy<T>& a, bool b )
01667 {
01668     return sc_concref_r<T,sc_lv_base>(
01669         a.back_cast(), *new sc_lv_base( sc_logic( b ), 1 ), 2 );
01670 }
01671 
01672 template <class T>
01673 inline
01674 sc_concref_r<sc_lv_base,T>
01675 concat( bool a, const sc_proxy<T>& b )
01676 {
01677     return sc_concref_r<sc_lv_base,T>(
01678         *new sc_lv_base( sc_logic( a ), 1 ), b.back_cast(), 1 );
01679 }
01680 
01681 
01682 #ifdef SC_DT_MIXED_COMMA_OPERATORS
01683 
01684 template <class T>
01685 inline
01686 sc_concref_r<T,sc_lv_base>
01687 operator , ( sc_proxy<T>& a, const char* b )
01688 {
01689     return sc_concref_r<T,sc_lv_base>(
01690         a.back_cast(), *new sc_lv_base( b ), 2 );
01691 }
01692 
01693 template <class T>
01694 inline
01695 sc_concref_r<sc_lv_base,T>
01696 operator , ( const char* a, sc_proxy<T>& b )
01697 {
01698     return sc_concref_r<sc_lv_base,T>(
01699         *new sc_lv_base( a ), b.back_cast(), 1 );
01700 }
01701 
01702 template <class T>
01703 inline
01704 sc_concref_r<T,sc_lv_base>
01705 operator , ( sc_proxy<T>& a, const sc_logic& b )
01706 {
01707     return sc_concref_r<T,sc_lv_base>(
01708         a.back_cast(), *new sc_lv_base( b, 1 ), 2 );
01709 }
01710 
01711 template <class T>
01712 inline
01713 sc_concref_r<sc_lv_base,T>
01714 operator , ( const sc_logic& a, sc_proxy<T>& b )
01715 {
01716     return sc_concref_r<sc_lv_base,T>(
01717         *new sc_lv_base( a, 1 ), b.back_cast(), 1 );
01718 }
01719 
01720 template <class T>
01721 inline
01722 sc_concref_r<T,sc_lv_base>
01723 operator , ( sc_proxy<T>& a, bool b )
01724 {
01725     return sc_concref_r<T,sc_lv_base>(
01726         a.back_cast(), *new sc_lv_base( sc_logic( b ), 1 ), 2 );
01727 }
01728 
01729 template <class T>
01730 inline
01731 sc_concref_r<sc_lv_base,T>
01732 operator , ( bool a, sc_proxy<T>& b )
01733 {
01734     return sc_concref_r<sc_lv_base,T>(
01735         *new sc_lv_base( sc_logic( a ), 1 ), b.back_cast(), 1 );
01736 }
01737 
01738 
01739 template <class T>
01740 inline
01741 sc_concref_r<T,sc_lv_base>
01742 concat( sc_proxy<T>& a, const char* b )
01743 {
01744     return sc_concref_r<T,sc_lv_base>(
01745         a.back_cast(), *new sc_lv_base( b ), 2 );
01746 }
01747 
01748 template <class T>
01749 inline
01750 sc_concref_r<sc_lv_base,T>
01751 concat( const char* a, sc_proxy<T>& b )
01752 {
01753     return sc_concref_r<sc_lv_base,T>(
01754         *new sc_lv_base( a ), b.back_cast(), 1 );
01755 }
01756 
01757 template <class T>
01758 inline
01759 sc_concref_r<T,sc_lv_base>
01760 concat( sc_proxy<T>& a, const sc_logic& b )
01761 {
01762     return sc_concref_r<T,sc_lv_base>(
01763         a.back_cast(), *new sc_lv_base( b, 1 ), 2 );
01764 }
01765 
01766 template <class T>
01767 inline
01768 sc_concref_r<sc_lv_base,T>
01769 concat( const sc_logic& a, sc_proxy<T>& b )
01770 {
01771     return sc_concref_r<sc_lv_base,T>(
01772         *new sc_lv_base( a, 1 ), b.back_cast(), 1 );
01773 }
01774 
01775 template <class T>
01776 inline
01777 sc_concref_r<T,sc_lv_base>
01778 concat( sc_proxy<T>& a, bool b )
01779 {
01780     return sc_concref_r<T,sc_lv_base>(
01781         a.back_cast(), *new sc_lv_base( sc_logic( b ), 1 ), 2 );
01782 }
01783 
01784 template <class T>
01785 inline
01786 sc_concref_r<sc_lv_base,T>
01787 concat( bool a, sc_proxy<T>& b )
01788 {
01789     return sc_concref_r<sc_lv_base,T>(
01790         *new sc_lv_base( sc_logic( a ), 1 ), b.back_cast(), 1 );
01791 }
01792 
01793 #endif
01794 
01795 } // namespace sc_dt
01796 
01797 
01798 #endif

Generated on Wed Apr 25 13:53:26 2007 for SystemC by  doxygen 1.5.1