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