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