00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 #ifndef SC_INT_BASE_H
00072 #define SC_INT_BASE_H
00073 
00074 #include "sysc/kernel/sc_object.h"
00075 #include "sysc/datatypes/misc/sc_value_base.h"
00076 #include "sysc/datatypes/int/sc_int_ids.h"
00077 #include "sysc/datatypes/int/sc_length_param.h"
00078 #include "sysc/datatypes/int/sc_nbdefs.h"
00079 #include "sysc/datatypes/int/sc_uint_base.h"
00080 #include "sysc/utils/sc_iostream.h"
00081 #include "sysc/utils/sc_temporary.h"
00082 
00083 
00084 namespace sc_dt
00085 {
00086 
00087 class sc_concatref;
00088 
00089 
00090 class sc_int_bitref_r;
00091 class sc_int_bitref;
00092 class sc_int_subref_r;
00093 class sc_int_subref;
00094 class sc_int_base;
00095 class sc_signed_subref_r;
00096 class sc_unsigned_subref_r;
00097 
00098 
00099 class sc_bv_base;
00100 class sc_lv_base;
00101 class sc_signed;
00102 class sc_unsigned;
00103 class sc_fxval;
00104 class sc_fxval_fast;
00105 class sc_fxnum;
00106 class sc_fxnum_fast;
00107 
00108 
00109 extern const uint_type mask_int[SC_INTWIDTH][SC_INTWIDTH];
00110 
00111 
00112     
00113 
00114     inline bool operator == ( const sc_int_base& a, const sc_int_base& b );
00115 
00116     inline bool operator != ( const sc_int_base& a, const sc_int_base& b );
00117 
00118     inline bool operator <  ( const sc_int_base& a, const sc_int_base& b );
00119 
00120     inline bool operator <= ( const sc_int_base& a, const sc_int_base& b );
00121 
00122     inline bool operator >  ( const sc_int_base& a, const sc_int_base& b );
00123 
00124     inline bool operator >= ( const sc_int_base& a, const sc_int_base& b );
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 class sc_int_bitref_r : public sc_value_base
00134 {
00135     friend class sc_int_base;
00136 
00137 protected:
00138 
00139     
00140 
00141     sc_int_bitref_r() : sc_value_base(), m_index(), m_obj_p()
00142         {}
00143 
00144     
00145 
00146     void initialize( const sc_int_base* obj_p, int index_ )
00147     {
00148         m_obj_p = (sc_int_base*)obj_p;
00149         m_index = index_;
00150     }
00151 
00152 public:
00153 
00154     
00155 
00156     sc_int_bitref_r( const sc_int_bitref_r& a ) :
00157         sc_value_base(a), m_index(a.m_index), m_obj_p(a.m_obj_p)
00158         {}
00159 
00160     
00161 
00162     virtual ~sc_int_bitref_r()
00163         {}
00164 
00165     
00166 
00167     int length() const
00168         { return 1; }
00169 
00170 #ifdef SC_DT_DEPRECATED
00171     int bitwidth() const
00172         { return length(); }
00173 #endif
00174 
00175     
00176 
00177     virtual int concat_length( bool *xz_present_p ) const
00178         { if (xz_present_p) *xz_present_p = false; return 1; }
00179     virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const
00180         {
00181             int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
00182             int word_i = low_i / BITS_PER_DIGIT;
00183 
00184             dst_p[word_i] &= ~bit_mask;
00185             return false;
00186         }
00187     virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const
00188         {
00189             bool non_zero;
00190             int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
00191             int word_i = low_i / BITS_PER_DIGIT;
00192 
00193             if ( operator uint64() )
00194             {
00195                 dst_p[word_i] |= bit_mask;
00196                 non_zero = true;
00197             }
00198             else
00199             {
00200                 dst_p[word_i] &= ~bit_mask;
00201                 non_zero = false;
00202             }
00203             return non_zero;
00204         }
00205     virtual uint64 concat_get_uint64() const
00206         { return operator uint64(); }
00207 
00208 
00209 
00210 
00211     
00212 
00213     operator uint64 () const;
00214     bool operator ! () const;
00215     bool operator ~ () const;
00216 
00217 
00218     
00219 
00220     uint64 value() const
00221         { return operator uint64(); }
00222 
00223     bool to_bool() const
00224         { return operator uint64(); }
00225 
00226 
00227     
00228 
00229     void print( ::std::ostream& os = ::std::cout ) const
00230         { os << to_bool(); }
00231 
00232 protected:
00233     int          m_index;
00234     sc_int_base* m_obj_p;
00235 
00236 private:
00237 
00238     
00239     sc_int_bitref_r& operator = ( const sc_int_bitref_r& );
00240 };
00241 
00242 
00243 inline
00244 ::std::ostream&
00245 operator << ( ::std::ostream&, const sc_int_bitref_r& );
00246 
00247 
00248 
00249 
00250 
00251 
00252 
00253 
00254 class sc_int_bitref
00255     : public sc_int_bitref_r
00256 {
00257     friend class sc_int_base;
00258     friend class sc_core::sc_vpool<sc_int_bitref>;
00259 
00260 
00261     
00262 
00263     sc_int_bitref() : sc_int_bitref_r()
00264       {}
00265 
00266 
00267 public:
00268 
00269     
00270 
00271     sc_int_bitref( const sc_int_bitref& a ) : sc_int_bitref_r( a )
00272       {}
00273 
00274     
00275 
00276     sc_int_bitref& operator = ( const sc_int_bitref_r& b );
00277     sc_int_bitref& operator = ( const sc_int_bitref& b );
00278     sc_int_bitref& operator = ( bool b );
00279 
00280     sc_int_bitref& operator &= ( bool b );
00281     sc_int_bitref& operator |= ( bool b );
00282     sc_int_bitref& operator ^= ( bool b );
00283 
00284         
00285 
00286     virtual void concat_set(int64 src, int low_i);
00287     virtual void concat_set(const sc_signed& src, int low_i);
00288     virtual void concat_set(const sc_unsigned& src, int low_i);
00289     virtual void concat_set(uint64 src, int low_i);
00290 
00291 
00292     
00293 
00294     void scan( ::std::istream& is = ::std::cin );
00295 
00296 public:
00297     static sc_core::sc_vpool<sc_int_bitref> m_pool;
00298 
00299 };
00300 
00301 
00302 
00303 inline
00304 ::std::istream&
00305 operator >> ( ::std::istream&, sc_int_bitref& );
00306 
00307 
00308 
00309 
00310 
00311 
00312 
00313 
00314 class sc_int_subref_r : public sc_value_base
00315 {
00316     friend class sc_int_base;
00317     friend class sc_int_signal;
00318     friend class sc_int_subref;
00319 
00320 protected:
00321 
00322     
00323 
00324     sc_int_subref_r() : sc_value_base(), m_left(0), m_obj_p(0), m_right(0)
00325         {}
00326 
00327     
00328 
00329     void initialize( const sc_int_base* obj_p, int left_i, int right_i )
00330     {
00331         m_obj_p = (sc_int_base*)obj_p;
00332         m_left = left_i;
00333         m_right = right_i;
00334     }
00335 
00336 
00337 public:
00338     
00339 
00340     sc_int_subref_r( const sc_int_subref_r& a ) :
00341         sc_value_base(a), m_left( a.m_left ), m_obj_p( a.m_obj_p ), 
00342         m_right( a.m_right )
00343         {}
00344 
00345     
00346 
00347     virtual ~sc_int_subref_r()
00348         {}
00349 
00350     
00351 
00352     int length() const
00353         { return ( m_left - m_right + 1 ); }
00354 
00355 #ifdef SC_DT_DEPRECATED
00356     int bitwidth() const
00357         { return length(); }
00358 #endif
00359 
00360     
00361 
00362     virtual int concat_length(bool* xz_present_p) const
00363         { if ( xz_present_p ) *xz_present_p = false; return length(); }
00364     virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const;
00365     virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const;
00366     virtual uint64 concat_get_uint64() const
00367     {
00368         int    len = length();
00369         uint64 val = operator uint_type();
00370         if ( len < 64 )
00371             return (uint64)(val & ~((uint_type)-1 << len));
00372         else
00373             return (uint64)val;
00374     }
00375 
00376     
00377 
00378     bool and_reduce() const;
00379 
00380     bool nand_reduce() const
00381         { return ( ! and_reduce() ); }
00382 
00383     bool or_reduce() const;
00384 
00385     bool nor_reduce() const
00386         { return ( ! or_reduce() ); }
00387 
00388     bool xor_reduce() const;
00389 
00390     bool xnor_reduce() const
00391         { return ( ! xor_reduce() ); }
00392 
00393 
00394     
00395 
00396     operator uint_type () const;
00397 
00398 
00399     
00400 
00401     uint_type value() const
00402         { return operator uint_type(); }
00403 
00404 
00405     int           to_int() const;
00406     unsigned int  to_uint() const;
00407     long          to_long() const;
00408     unsigned long to_ulong() const;
00409     int64         to_int64() const;
00410     uint64        to_uint64() const;
00411     double        to_double() const;
00412 
00413 
00414     
00415 
00416     const std::string to_string( sc_numrep numrep = SC_DEC ) const;
00417     const std::string to_string( sc_numrep numrep, bool w_prefix ) const;
00418 
00419 
00420     
00421 
00422     void print( ::std::ostream& os = ::std::cout ) const
00423         { os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }
00424 
00425 protected:
00426 
00427     int          m_left;
00428     sc_int_base* m_obj_p;
00429     int          m_right;
00430 
00431 private:
00432     const sc_int_subref_r& operator = ( const sc_int_subref_r& );
00433 };
00434 
00435 
00436 
00437 inline
00438 ::std::ostream&
00439 operator << ( ::std::ostream&, const sc_int_subref_r& );
00440 
00441 
00442 
00443 
00444 
00445 
00446 
00447 
00448 class sc_int_subref
00449     : public sc_int_subref_r
00450 {
00451     friend class sc_int_base;
00452     friend class sc_core::sc_vpool<sc_int_subref>;
00453 
00454 
00455 protected:
00456 
00457     
00458     sc_int_subref() : sc_int_subref_r()
00459         {}
00460 
00461 public:
00462 
00463     
00464 
00465     sc_int_subref( const sc_int_subref& a ) : sc_int_subref_r( a )
00466         {}
00467 
00468     
00469 
00470     sc_int_subref& operator = ( int_type v );
00471     sc_int_subref& operator = ( const sc_int_base& a );
00472 
00473     sc_int_subref& operator = ( const sc_int_subref_r& a )
00474         { return operator = ( a.operator uint_type() ); }
00475 
00476     sc_int_subref& operator = ( const sc_int_subref& a )
00477         { return operator = ( a.operator uint_type() ); }
00478 
00479     template< class T >
00480     sc_int_subref& operator = ( const sc_generic_base<T>& a )
00481         { return operator = ( a->to_int64() ); }
00482 
00483     sc_int_subref& operator = ( const char* a );
00484 
00485     sc_int_subref& operator = ( unsigned long a )
00486         { return operator = ( (int_type) a ); }
00487 
00488     sc_int_subref& operator = ( long a )
00489         { return operator = ( (int_type) a ); }
00490 
00491     sc_int_subref& operator = ( unsigned int a )
00492         { return operator = ( (int_type) a ); }
00493 
00494     sc_int_subref& operator = ( int a )
00495         { return operator = ( (int_type) a ); }
00496 
00497     sc_int_subref& operator = ( uint64 a )
00498         { return operator = ( (int_type) a ); }
00499 
00500     sc_int_subref& operator = ( double a )
00501         { return operator = ( (int_type) a ); }
00502 
00503     sc_int_subref& operator = ( const sc_signed& );
00504     sc_int_subref& operator = ( const sc_unsigned& );
00505     sc_int_subref& operator = ( const sc_bv_base& );
00506     sc_int_subref& operator = ( const sc_lv_base& );
00507 
00508         
00509 
00510     virtual void concat_set(int64 src, int low_i);
00511     virtual void concat_set(const sc_signed& src, int low_i);
00512     virtual void concat_set(const sc_unsigned& src, int low_i);
00513     virtual void concat_set(uint64 src, int low_i);
00514 
00515     
00516 
00517     void scan( ::std::istream& is = ::std::cin );
00518 
00519 public:
00520     static sc_core::sc_vpool<sc_int_subref> m_pool;
00521 
00522 };
00523 
00524 
00525 
00526 inline
00527 ::std::istream&
00528 operator >> ( ::std::istream&, sc_int_subref& );
00529 
00530 
00531 
00532 
00533 
00534 
00535 
00536 
00537 class sc_int_base : public sc_value_base
00538 {
00539     friend class sc_int_bitref_r;
00540     friend class sc_int_bitref;
00541     friend class sc_int_subref_r;
00542     friend class sc_int_subref;
00543 
00544 
00545     
00546 
00547     void invalid_length() const;
00548     void invalid_index( int i ) const;
00549     void invalid_range( int l, int r ) const;
00550 
00551     void check_length() const
00552         { if( m_len <= 0 || m_len > SC_INTWIDTH ) { invalid_length(); } }
00553 
00554     void check_index( int i ) const
00555         { if( i < 0 || i >= m_len ) { invalid_index( i ); } }
00556 
00557     void check_range( int l, int r ) const
00558         { if( r < 0 || l >= m_len || l < r ) { invalid_range( l, r ); } }
00559 
00560     void check_value() const;
00561 
00562     void extend_sign()
00563         {
00564 #ifdef DEBUG_SYSTEMC
00565             check_value();
00566 #endif
00567             m_val = ( m_val << m_ulen >> m_ulen );
00568         }
00569 
00570 public:
00571 
00572     
00573 
00574     explicit sc_int_base( int w = sc_length_param().len() )
00575         : m_val( 0 ), m_len( w ), m_ulen( SC_INTWIDTH - m_len )
00576         { check_length(); }
00577 
00578     sc_int_base( int_type v, int w )
00579         : m_val( v ), m_len( w ), m_ulen( SC_INTWIDTH - m_len )
00580         { check_length(); extend_sign(); }
00581 
00582     sc_int_base( const sc_int_base& a )
00583         : sc_value_base(a), m_val( a.m_val ), m_len( a.m_len ), 
00584           m_ulen( a.m_ulen )
00585         {}
00586 
00587     explicit sc_int_base( const sc_int_subref_r& a )
00588         : m_val( a ), m_len( a.length() ), m_ulen( SC_INTWIDTH - m_len )
00589         { extend_sign(); }
00590 
00591     template< class T >
00592     explicit sc_int_base( const sc_generic_base<T>& a ) :
00593         m_val( a->to_int64() ), m_len( a->length() ),
00594         m_ulen( SC_INTWIDTH - m_len )
00595         { check_length(); extend_sign(); }
00596 
00597     explicit sc_int_base( const sc_signed& a );
00598     explicit sc_int_base( const sc_unsigned& a );
00599     explicit sc_int_base( const sc_bv_base& v );
00600     explicit sc_int_base( const sc_lv_base& v );
00601     explicit sc_int_base( const sc_uint_subref_r& v );
00602     explicit sc_int_base( const sc_signed_subref_r& v );
00603     explicit sc_int_base( const sc_unsigned_subref_r& v );
00604 
00605 
00606 
00607     
00608 
00609     virtual ~sc_int_base()
00610         {}
00611 
00612     
00613 
00614     sc_int_base& operator = ( int_type v )
00615         { m_val = v; extend_sign(); return *this; }
00616 
00617     sc_int_base& operator = ( const sc_int_base& a )
00618         { m_val = a.m_val; extend_sign(); return *this; }
00619 
00620     sc_int_base& operator = ( const sc_int_subref_r& a )
00621         { m_val = a; extend_sign(); return *this; }
00622 
00623     template<class T>
00624     sc_int_base& operator = ( const sc_generic_base<T>& a )
00625         { m_val = a->to_int64(); extend_sign(); return *this; }
00626 
00627     sc_int_base& operator = ( const sc_signed& a );
00628     sc_int_base& operator = ( const sc_unsigned& a );
00629 
00630 #ifdef SC_INCLUDE_FX
00631     sc_int_base& operator = ( const sc_fxval& a );
00632     sc_int_base& operator = ( const sc_fxval_fast& a );
00633     sc_int_base& operator = ( const sc_fxnum& a );
00634     sc_int_base& operator = ( const sc_fxnum_fast& a );
00635 #endif
00636 
00637     sc_int_base& operator = ( const sc_bv_base& a );
00638     sc_int_base& operator = ( const sc_lv_base& a );
00639 
00640     sc_int_base& operator = ( const char* a );
00641 
00642     sc_int_base& operator = ( unsigned long a )
00643         { m_val = a; extend_sign(); return *this; }
00644 
00645     sc_int_base& operator = ( long a )
00646         { m_val = a; extend_sign(); return *this; }
00647 
00648     sc_int_base& operator = ( unsigned int a )
00649         { m_val = a; extend_sign(); return *this; }
00650 
00651     sc_int_base& operator = ( int a )
00652         { m_val = a; extend_sign(); return *this; }
00653 
00654     sc_int_base& operator = ( uint64 a )
00655         { m_val = a; extend_sign(); return *this; }
00656 
00657     sc_int_base& operator = ( double a )
00658         { m_val = (int_type) a; extend_sign(); return *this; }
00659 
00660 
00661     
00662 
00663     sc_int_base& operator += ( int_type v )
00664         { m_val += v; extend_sign(); return *this; }
00665 
00666     sc_int_base& operator -= ( int_type v )
00667         { m_val -= v; extend_sign(); return *this; }
00668 
00669     sc_int_base& operator *= ( int_type v )
00670         { m_val *= v; extend_sign(); return *this; }
00671 
00672     sc_int_base& operator /= ( int_type v )
00673         { m_val /= v; extend_sign(); return *this; }
00674 
00675     sc_int_base& operator %= ( int_type v )
00676         { m_val %= v; extend_sign(); return *this; }
00677 
00678 
00679     
00680 
00681     sc_int_base& operator &= ( int_type v )
00682         { m_val &= v; extend_sign(); return *this; }
00683 
00684     sc_int_base& operator |= ( int_type v )
00685         { m_val |= v; extend_sign(); return *this; }
00686 
00687     sc_int_base& operator ^= ( int_type v )
00688         { m_val ^= v; extend_sign(); return *this; }
00689 
00690 
00691     sc_int_base& operator <<= ( int_type v )
00692         { m_val <<= v; extend_sign(); return *this; }
00693 
00694     sc_int_base& operator >>= ( int_type v )
00695         { m_val >>= v;  return *this; }
00696 
00697 
00698     
00699 
00700     sc_int_base& operator ++ () 
00701         { ++ m_val; extend_sign(); return *this; }
00702 
00703     const sc_int_base operator ++ ( int ) 
00704         { sc_int_base tmp( *this ); ++ m_val; extend_sign(); return tmp; }
00705 
00706     sc_int_base& operator -- () 
00707         { -- m_val; extend_sign(); return *this; }
00708 
00709     const sc_int_base operator -- ( int ) 
00710         { sc_int_base tmp( *this ); -- m_val; extend_sign(); return tmp; }
00711 
00712 
00713     
00714 
00715     friend bool operator == ( const sc_int_base& a, const sc_int_base& b )
00716         { return a.m_val == b.m_val; }
00717 
00718     friend bool operator != ( const sc_int_base& a, const sc_int_base& b )
00719         { return a.m_val != b.m_val; }
00720 
00721     friend bool operator <  ( const sc_int_base& a, const sc_int_base& b )
00722         { return a.m_val < b.m_val; }
00723 
00724     friend bool operator <= ( const sc_int_base& a, const sc_int_base& b )
00725         { return a.m_val <= b.m_val; }
00726 
00727     friend bool operator >  ( const sc_int_base& a, const sc_int_base& b )
00728         { return a.m_val > b.m_val; }
00729 
00730     friend bool operator >= ( const sc_int_base& a, const sc_int_base& b )
00731         { return a.m_val >= b.m_val; }
00732 
00733 
00734     
00735 
00736     sc_int_bitref&         operator [] ( int i );
00737     const sc_int_bitref_r& operator [] ( int i ) const;
00738 
00739     sc_int_bitref&         bit( int i );
00740     const sc_int_bitref_r& bit( int i ) const;
00741 
00742 
00743     
00744 
00745     sc_int_subref&         operator () ( int left, int right );
00746     const sc_int_subref_r& operator () ( int left, int right ) const;
00747 
00748     sc_int_subref&         range( int left, int right );
00749     const sc_int_subref_r& range( int left, int right ) const;
00750 
00751 
00752     
00753 
00754     bool test( int i ) const
00755         { return ( 0 != (m_val & (UINT_ONE << i)) ); }
00756 
00757     void set( int i )
00758         { m_val |= (UINT_ONE << i); }
00759 
00760     void set( int i, bool v )
00761         { v ? m_val |= (UINT_ONE << i) : m_val &= ~(UINT_ONE << i); }
00762 
00763 
00764     
00765 
00766     int length() const
00767         { return m_len; }
00768 
00769 #ifdef SC_DT_DEPRECATED
00770     int bitwidth() const
00771         { return length(); }
00772 #endif
00773 
00774     
00775 
00776     virtual int concat_length(bool* xz_present_p) const
00777         { if ( xz_present_p ) *xz_present_p = false; return length(); }
00778     virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const;
00779     virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const;
00780     virtual uint64 concat_get_uint64() const
00781         {
00782             if ( m_len < 64 )
00783                 return (uint64)(m_val & ~((uint_type)-1 << m_len));
00784             else
00785                 return (uint64)m_val;
00786         }
00787     virtual void concat_set(int64 src, int low_i);
00788     virtual void concat_set(const sc_signed& src, int low_i);
00789     virtual void concat_set(const sc_unsigned& src, int low_i);
00790     virtual void concat_set(uint64 src, int low_i);
00791 
00792 
00793     
00794 
00795     bool and_reduce() const;
00796 
00797     bool nand_reduce() const
00798         { return ( ! and_reduce() ); }
00799 
00800     bool or_reduce() const;
00801 
00802     bool nor_reduce() const
00803         { return ( ! or_reduce() ); }
00804 
00805     bool xor_reduce() const;
00806 
00807     bool xnor_reduce() const
00808         { return ( ! xor_reduce() ); }
00809 
00810 
00811     
00812 
00813     operator int_type() const
00814         { return m_val; }
00815 
00816 
00817     
00818 
00819     int_type value() const
00820         { return operator int_type(); }
00821 
00822 
00823     int to_int() const
00824         { return (int) m_val; }
00825 
00826     unsigned int to_uint() const
00827         { return (unsigned int) m_val; }
00828 
00829     long to_long() const
00830         { return (long) m_val; }
00831 
00832     unsigned long to_ulong() const
00833         { return (unsigned long) m_val; }
00834 
00835     int64 to_int64() const
00836         { return (int64) m_val; }
00837 
00838     uint64 to_uint64() const
00839         { return (uint64) m_val; }
00840 
00841     double to_double() const
00842         { return (double) m_val; }
00843 
00844 
00845 #ifndef _32BIT_
00846     long long_low() const
00847         { return (long) (m_val & UINT64_32ONES); }
00848 
00849     long long_high() const
00850         { return (long) ((m_val >> 32) & UINT64_32ONES); }
00851 #endif
00852 
00853 
00854     
00855 
00856     const std::string to_string( sc_numrep numrep = SC_DEC ) const;
00857     const std::string to_string( sc_numrep numrep, bool w_prefix ) const;
00858 
00859 
00860     
00861 
00862     void print( ::std::ostream& os = ::std::cout ) const
00863         { os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }
00864 
00865     void scan( ::std::istream& is = ::std::cin );
00866 
00867 protected:
00868 
00869     int_type m_val;   
00870     int      m_len;   
00871     int      m_ulen;  
00872 };
00873 
00874 
00875 
00876 inline
00877 ::std::ostream&
00878 operator << ( ::std::ostream&, const sc_int_base& );
00879 
00880 inline
00881 ::std::istream&
00882 operator >> ( ::std::istream&, sc_int_base& );
00883 
00884 
00885 
00886 
00887 
00888 
00889 
00890 
00891 
00892 
00893 
00894 inline
00895 sc_int_bitref_r::operator uint64 () const
00896 {
00897     return m_obj_p->test( m_index );
00898 }
00899 
00900 inline
00901 bool
00902 sc_int_bitref_r::operator ! () const
00903 {
00904     return ! m_obj_p->test( m_index );
00905 }
00906 
00907 inline
00908 bool
00909 sc_int_bitref_r::operator ~ () const
00910 {
00911     return ! m_obj_p->test( m_index );
00912 }
00913 
00914 
00915 
00916 inline
00917 ::std::ostream&
00918 operator << ( ::std::ostream& os, const sc_int_bitref_r& a )
00919 {
00920     a.print( os );
00921     return os;
00922 }
00923 
00924 
00925 
00926 
00927 
00928 
00929 
00930 
00931 
00932 
00933 inline
00934 sc_int_bitref&
00935 sc_int_bitref::operator = ( const sc_int_bitref_r& b )
00936 {
00937     m_obj_p->set( m_index, (bool) b );
00938     m_obj_p->extend_sign();
00939     return *this;
00940 }
00941 
00942 inline
00943 sc_int_bitref&
00944 sc_int_bitref::operator = ( const sc_int_bitref& b )
00945 {
00946     m_obj_p->set( m_index, (bool) b );
00947     m_obj_p->extend_sign();
00948     return *this;
00949 }
00950 
00951 inline
00952 sc_int_bitref&
00953 sc_int_bitref::operator = ( bool b )
00954 {
00955     m_obj_p->set( m_index, b );
00956     m_obj_p->extend_sign();
00957     return *this;
00958 }
00959 
00960 
00961 inline
00962 sc_int_bitref&
00963 sc_int_bitref::operator &= ( bool b )
00964 {
00965     if( ! b ) {
00966         m_obj_p->set( m_index, b );
00967         m_obj_p->extend_sign();
00968     }
00969     return *this;
00970 }
00971 
00972 inline
00973 sc_int_bitref&
00974 sc_int_bitref::operator |= ( bool b )
00975 {
00976     if( b ) {
00977         m_obj_p->set( m_index, b );
00978         m_obj_p->extend_sign();
00979     }
00980     return *this;
00981 }
00982 
00983 inline
00984 sc_int_bitref&
00985 sc_int_bitref::operator ^= ( bool b )
00986 {
00987     if( b ) {
00988         m_obj_p->m_val ^= (UINT_ONE << m_index);
00989         m_obj_p->extend_sign();
00990     }
00991     return *this;
00992 }
00993 
00994 
00995 
00996 inline
00997 ::std::istream&
00998 operator >> ( ::std::istream& is, sc_int_bitref& a )
00999 {
01000     a.scan( is );
01001     return is;
01002 }
01003 
01004 
01005 
01006 
01007 
01008 
01009 
01010 
01011 
01012 
01013 inline
01014 sc_int_subref_r::operator uint_type() const
01015 {
01016     uint_type  val = m_obj_p->m_val;
01017     int uleft = SC_INTWIDTH - (m_left + 1);
01018     int uright = uleft + m_right;
01019     return ( val << uleft >> uright );
01020 }
01021 
01022 
01023 
01024 
01025 inline
01026 bool
01027 sc_int_subref_r::and_reduce() const
01028 {
01029     sc_int_base a( *this );
01030     return a.and_reduce();
01031 }
01032 
01033 inline
01034 bool
01035 sc_int_subref_r::or_reduce() const
01036 {
01037     sc_int_base a( *this );
01038     return a.or_reduce();
01039 }
01040 
01041 inline
01042 bool
01043 sc_int_subref_r::xor_reduce() const
01044 {
01045     sc_int_base a( *this );
01046     return a.xor_reduce();
01047 }
01048 
01049 
01050 
01051 
01052 inline
01053 int
01054 sc_int_subref_r::to_int() const
01055 {
01056         int result = static_cast<int>(operator uint_type());
01057         return result;
01058 }
01059 
01060 inline
01061 unsigned int
01062 sc_int_subref_r::to_uint() const
01063 {
01064         unsigned int result = static_cast<unsigned int>(operator uint_type());
01065         return result;
01066 }
01067 
01068 inline
01069 long
01070 sc_int_subref_r::to_long() const
01071 {
01072         long result = static_cast<long>(operator uint_type());
01073         return result;
01074 }
01075 
01076 inline
01077 unsigned long
01078 sc_int_subref_r::to_ulong() const
01079 {
01080         unsigned long result = static_cast<unsigned long>(operator uint_type());
01081         return result;
01082 }
01083 
01084 inline
01085 int64
01086 sc_int_subref_r::to_int64() const
01087 {
01088         int64 result = operator uint_type();
01089         return result;
01090 }
01091 
01092 inline
01093 uint64
01094 sc_int_subref_r::to_uint64() const
01095 {
01096         uint64 result = operator uint_type();
01097         return result;
01098 }
01099 
01100 inline
01101 double
01102 sc_int_subref_r::to_double() const
01103 {
01104         double result = static_cast<double>(operator uint_type());
01105         return result;
01106 }
01107 
01108 
01109 
01110 
01111 inline
01112 const std::string
01113 sc_int_subref_r::to_string( sc_numrep numrep ) const
01114 {
01115         sc_uint_base a(length());
01116     a = operator uint_type();
01117     return a.to_string( numrep );
01118 }
01119 
01120 inline
01121 const std::string
01122 sc_int_subref_r::to_string( sc_numrep numrep, bool w_prefix ) const
01123 {
01124         sc_uint_base a(length());
01125     a = operator uint_type();
01126     return a.to_string( numrep, w_prefix );
01127 }
01128 
01129 
01130 
01131 
01132 inline
01133 bool
01134 and_reduce( const sc_int_subref_r& a )
01135 {
01136     return a.and_reduce();
01137 }
01138 
01139 inline
01140 bool
01141 nand_reduce( const sc_int_subref_r& a )
01142 {
01143     return a.nand_reduce();
01144 }
01145 
01146 inline
01147 bool
01148 or_reduce( const sc_int_subref_r& a )
01149 {
01150     return a.or_reduce();
01151 }
01152 
01153 inline
01154 bool
01155 nor_reduce( const sc_int_subref_r& a )
01156 {
01157     return a.nor_reduce();
01158 }
01159 
01160 inline
01161 bool
01162 xor_reduce( const sc_int_subref_r& a )
01163 {
01164     return a.xor_reduce();
01165 }
01166 
01167 inline
01168 bool
01169 xnor_reduce( const sc_int_subref_r& a )
01170 {
01171     return a.xnor_reduce();
01172 }
01173 
01174 
01175 
01176 inline
01177 ::std::ostream&
01178 operator << ( ::std::ostream& os, const sc_int_subref_r& a )
01179 {
01180     a.print( os );
01181     return os;
01182 }
01183 
01184 
01185 
01186 
01187 
01188 
01189 
01190 
01191 
01192 
01193 inline
01194 sc_int_subref&
01195 sc_int_subref::operator = ( const sc_int_base& a )
01196 {
01197     return operator = ( a.operator int_type() );
01198 }
01199 
01200 inline
01201 sc_int_subref&
01202 sc_int_subref::operator = ( const char* a )
01203 {
01204     sc_int_base aa( length() );
01205     return ( *this = aa = a );
01206 }
01207 
01208 
01209 
01210 inline
01211 ::std::istream&
01212 operator >> ( ::std::istream& is, sc_int_subref& a )
01213 {
01214     a.scan( is );
01215     return is;
01216 }
01217 
01218 
01219 
01220 
01221 
01222 
01223 
01224 
01225 
01226 
01227 inline
01228 sc_int_bitref&
01229 sc_int_base::operator [] ( int i )
01230 {
01231     check_index( i );
01232     sc_int_bitref* result_p = sc_int_bitref::m_pool.allocate();
01233     result_p->initialize(this, i);
01234     return *result_p;
01235 }
01236 
01237 inline
01238 const sc_int_bitref_r&
01239 sc_int_base::operator [] ( int i ) const
01240 {
01241     check_index( i );
01242     sc_int_bitref* result_p = sc_int_bitref::m_pool.allocate();
01243     result_p->initialize(this, i);
01244     return *result_p;
01245 }
01246 
01247 
01248 inline
01249 sc_int_bitref&
01250 sc_int_base::bit( int i )
01251 {
01252     check_index( i );
01253     sc_int_bitref* result_p = sc_int_bitref::m_pool.allocate();
01254     result_p->initialize(this, i);
01255     return *result_p;
01256 }
01257 
01258 inline
01259 const sc_int_bitref_r&
01260 sc_int_base::bit( int i ) const
01261 {
01262     check_index( i );
01263     sc_int_bitref* result_p = sc_int_bitref::m_pool.allocate();
01264     result_p->initialize(this, i);
01265     return *result_p;
01266 }
01267 
01268 
01269 
01270 
01271 inline
01272 sc_int_subref&
01273 sc_int_base::operator () ( int left, int right )
01274 {
01275     check_range( left, right );
01276     sc_int_subref* result_p = sc_int_subref::m_pool.allocate();
01277     result_p->initialize(this, left, right);
01278     return *result_p;
01279 }
01280 
01281 inline
01282 const sc_int_subref_r&
01283 sc_int_base::operator () ( int left, int right ) const
01284 {
01285     check_range( left, right );
01286     sc_int_subref* result_p = sc_int_subref::m_pool.allocate();
01287     result_p->initialize(this, left, right);
01288     return *result_p;
01289 }
01290 
01291 
01292 inline
01293 sc_int_subref&
01294 sc_int_base::range( int left, int right )
01295 {
01296     check_range( left, right );
01297     sc_int_subref* result_p = sc_int_subref::m_pool.allocate();
01298     result_p->initialize(this, left, right);
01299     return *result_p;
01300 }
01301 
01302 inline
01303 const sc_int_subref_r&
01304 sc_int_base::range( int left, int right ) const
01305 {
01306     check_range( left, right );
01307     sc_int_subref* result_p = sc_int_subref::m_pool.allocate();
01308     result_p->initialize(this, left, right);
01309     return *result_p;
01310 }
01311 
01312 
01313 
01314 
01315 inline
01316 bool
01317 and_reduce( const sc_int_base& a )
01318 {
01319     return a.and_reduce();
01320 }
01321 
01322 inline
01323 bool
01324 nand_reduce( const sc_int_base& a )
01325 {
01326     return a.nand_reduce();
01327 }
01328 
01329 inline
01330 bool
01331 or_reduce( const sc_int_base& a )
01332 {
01333     return a.or_reduce();
01334 }
01335 
01336 inline
01337 bool
01338 nor_reduce( const sc_int_base& a )
01339 {
01340     return a.nor_reduce();
01341 }
01342 
01343 inline
01344 bool
01345 xor_reduce( const sc_int_base& a )
01346 {
01347     return a.xor_reduce();
01348 }
01349 
01350 inline
01351 bool
01352 xnor_reduce( const sc_int_base& a )
01353 {
01354     return a.xnor_reduce();
01355 }
01356 
01357 
01358 
01359 inline
01360 ::std::ostream&
01361 operator << ( ::std::ostream& os, const sc_int_base& a )
01362 {
01363     a.print( os );
01364     return os;
01365 }
01366 
01367 inline
01368 ::std::istream&
01369 operator >> ( ::std::istream& is, sc_int_base& a )
01370 {
01371     a.scan( is );
01372     return is;
01373 }
01374 
01375 } 
01376 
01377 
01378 #endif
01379 
01380