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 #ifndef SC_SIGNED_H
00068 #define SC_SIGNED_H
00069
00070
00071 #include "sysc/kernel/sc_object.h"
00072 #include "sysc/datatypes/misc/sc_value_base.h"
00073 #include "sysc/utils/sc_iostream.h"
00074 #include "sysc/utils/sc_temporary.h"
00075 #include "sysc/datatypes/int/sc_length_param.h"
00076 #include "sysc/datatypes/int/sc_nbdefs.h"
00077 #include "sysc/datatypes/int/sc_nbutils.h"
00078 #include "sysc/datatypes/int/sc_nbexterns.h"
00079 #include "sysc/datatypes/int/sc_unsigned.h"
00080
00081
00082 namespace sc_dt
00083 {
00084
00085
00086 class sc_signed_bitref_r;
00087 class sc_signed_bitref;
00088 class sc_signed_subref_r;
00089 class sc_signed_subref;
00090 class sc_concatref;
00091 class sc_signed;
00092
00093
00094 class sc_bv_base;
00095 class sc_lv_base;
00096 class sc_int_base;
00097 class sc_uint_base;
00098 class sc_int_subref_r;
00099 class sc_uint_subref_r;
00100 class sc_signed;
00101 class sc_unsigned;
00102 class sc_unsigned_subref_r;
00103 class sc_fxval;
00104 class sc_fxval_fast;
00105 class sc_fxnum;
00106 class sc_fxnum_fast;
00107
00108
00109
00110
00111
00112
00113
00114
00115 class sc_signed_bitref_r : public sc_value_base
00116 {
00117 friend class sc_signed;
00118
00119 protected:
00120
00121
00122
00123 sc_signed_bitref_r()
00124 {}
00125
00126 void initialize( const sc_signed* obj_p, int index_ )
00127 {
00128 m_index = index_;
00129 m_obj_p = ( CCAST<sc_signed*>( obj_p ) );
00130 }
00131
00132 public:
00133
00134
00135
00136 virtual ~sc_signed_bitref_r()
00137 {}
00138
00139
00140
00141 sc_signed_bitref_r( const sc_signed_bitref_r& a )
00142 : m_index( a.m_index ), m_obj_p( a.m_obj_p )
00143 {}
00144
00145
00146
00147 int length() const
00148 { return 1; }
00149
00150
00151
00152
00153 operator uint64 () const;
00154 bool operator ! () const;
00155 bool operator ~ () const;
00156
00157
00158
00159
00160 bool value() const
00161 { return operator uint64(); }
00162
00163 bool to_bool() const
00164 { return operator uint64(); }
00165
00166
00167
00168 virtual int concat_length(bool* xz_present_p) const
00169 { if ( xz_present_p ) *xz_present_p = false; return 1; }
00170 virtual uint64 concat_get_uint64() const
00171 { return (uint64)operator uint64(); }
00172 virtual bool concat_get_ctrl( unsigned long* dst_p, int low_i ) const
00173 {
00174 int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
00175 int word_i = low_i / BITS_PER_DIGIT;
00176 dst_p[word_i] &= ~bit_mask;
00177 return false;
00178 }
00179 virtual bool concat_get_data( unsigned long* dst_p, int low_i ) const
00180 {
00181 int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
00182 bool result;
00183 int word_i = low_i / BITS_PER_DIGIT;
00184 if ( operator uint64() )
00185 {
00186 dst_p[word_i] |= bit_mask;
00187 result = true;
00188 }
00189 else
00190 {
00191 dst_p[word_i] &= ~bit_mask;
00192 result = false;
00193 }
00194 return result;
00195 }
00196
00197
00198
00199
00200 void print( ::std::ostream& os = ::std::cout ) const
00201 { os << to_bool(); }
00202
00203 protected:
00204
00205 int m_index;
00206 sc_signed* m_obj_p;
00207
00208 private:
00209
00210
00211 const sc_signed_bitref_r& operator = ( const sc_signed_bitref_r& );
00212 };
00213
00214
00215
00216 inline
00217 ::std::ostream&
00218 operator << ( ::std::ostream&, const sc_signed_bitref_r& );
00219
00220
00221
00222
00223
00224
00225
00226
00227 class sc_signed_bitref
00228 : public sc_signed_bitref_r
00229 {
00230 friend class sc_signed;
00231 friend class sc_core::sc_vpool<sc_signed_bitref>;
00232
00233
00234
00235
00236 protected:
00237
00238 sc_signed_bitref()
00239 {}
00240
00241 public:
00242
00243
00244
00245 sc_signed_bitref( const sc_signed_bitref& a )
00246 : sc_signed_bitref_r( a )
00247 {}
00248
00249
00250
00251 const sc_signed_bitref& operator = ( const sc_signed_bitref_r& );
00252 const sc_signed_bitref& operator = ( const sc_signed_bitref& );
00253 const sc_signed_bitref& operator = ( bool );
00254
00255 const sc_signed_bitref& operator &= ( bool );
00256 const sc_signed_bitref& operator |= ( bool );
00257 const sc_signed_bitref& operator ^= ( bool );
00258
00259
00260
00261 virtual void concat_set(int64 src, int low_i);
00262 virtual void concat_set(const sc_signed& src, int low_i);
00263 virtual void concat_set(const sc_unsigned& src, int low_i);
00264 virtual void concat_set(uint64 src, int low_i);
00265
00266
00267
00268
00269 void scan( ::std::istream& is = ::std::cin );
00270
00271 protected:
00272 static sc_core::sc_vpool<sc_signed_bitref> m_pool;
00273 };
00274
00275
00276
00277 inline
00278 ::std::istream&
00279 operator >> ( ::std::istream&, sc_signed_bitref& );
00280
00281
00282
00283
00284
00285
00286
00287
00288 class sc_signed_subref_r : public sc_value_base
00289 {
00290 friend class sc_signed;
00291 friend class sc_signed_signal;
00292 friend class sc_unsigned;
00293
00294 protected:
00295
00296
00297
00298 sc_signed_subref_r()
00299 {}
00300
00301 void initialize( const sc_signed* obj_p, int left_, int right_ )
00302 {
00303 m_obj_p = ( CCAST<sc_signed*>( obj_p ));
00304 m_left = left_;
00305 m_right = right_;
00306 }
00307
00308
00309 public:
00310
00311
00312
00313 virtual ~sc_signed_subref_r()
00314 {}
00315
00316
00317
00318 sc_signed_subref_r( const sc_signed_subref_r& a )
00319 : m_left( a.m_left ), m_obj_p( a.m_obj_p ), m_right( a.m_right )
00320 {}
00321
00322
00323
00324
00325 int length() const
00326 { return m_left >= m_right ? (m_left-m_right+1) : (m_right-m_left+1 ); }
00327
00328
00329
00330
00331 operator sc_unsigned () const;
00332
00333
00334
00335
00336 int to_int() const;
00337 unsigned int to_uint() const;
00338 long to_long() const;
00339 unsigned long to_ulong() const;
00340 int64 to_int64() const;
00341 uint64 to_uint64() const;
00342 double to_double() const;
00343
00344
00345
00346
00347 const std::string to_string( sc_numrep numrep = SC_DEC ) const;
00348 const std::string to_string( sc_numrep numrep, bool w_prefix ) const;
00349
00350
00351
00352 virtual int concat_length(bool* xz_present_p) const
00353 {
00354 if ( xz_present_p ) *xz_present_p = false;
00355 return m_left - m_right + 1;
00356 }
00357 virtual uint64 concat_get_uint64() const;
00358 virtual bool concat_get_ctrl( unsigned long* dst_p, int low_i ) const;
00359 virtual bool concat_get_data( unsigned long* dst_p, int low_i ) const;
00360
00361
00362
00363 bool and_reduce() const;
00364 bool nand_reduce() const;
00365 bool or_reduce() const;
00366 bool nor_reduce() const;
00367 bool xor_reduce() const ;
00368 bool xnor_reduce() const;
00369
00370
00371
00372
00373 void print( ::std::ostream& os = ::std::cout ) const
00374 { os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }
00375
00376 protected:
00377
00378 int m_left;
00379 sc_signed* m_obj_p;
00380 int m_right;
00381
00382 private:
00383 const sc_signed_subref_r& operator = ( const sc_signed_subref_r& );
00384
00385 };
00386
00387
00388
00389 inline
00390 ::std::ostream&
00391 operator << ( ::std::ostream&, const sc_signed_subref_r& );
00392
00393
00394
00395
00396
00397
00398
00399
00400 class sc_signed_subref
00401 : public sc_signed_subref_r
00402 {
00403 friend class sc_signed;
00404 friend class sc_core::sc_vpool<sc_signed_subref>;
00405
00406
00407
00408
00409 sc_signed_subref()
00410 {}
00411
00412 public:
00413
00414
00415
00416 sc_signed_subref( const sc_signed_subref& a )
00417 : sc_signed_subref_r( a )
00418 {}
00419
00420
00421
00422
00423 const sc_signed_subref& operator = ( const sc_signed_subref_r& a );
00424 const sc_signed_subref& operator = ( const sc_signed_subref& a );
00425 const sc_signed_subref& operator = ( const sc_signed& a );
00426
00427 const sc_signed_subref& operator = ( const sc_unsigned_subref_r& a );
00428 const sc_signed_subref& operator = ( const sc_unsigned& a );
00429
00430 template< class T >
00431 const sc_signed_subref& operator = ( const sc_generic_base<T>& a )
00432 {
00433 sc_unsigned temp( length() );
00434 a->to_sc_unsigned(temp);
00435 return operator = (temp);
00436 }
00437
00438 const sc_signed_subref& operator = ( const char* a );
00439 const sc_signed_subref& operator = ( unsigned long a );
00440 const sc_signed_subref& operator = ( long a );
00441 const sc_signed_subref& operator = ( unsigned int a )
00442 { return operator = ( (unsigned long) a ); }
00443
00444 const sc_signed_subref& operator = ( int a )
00445 { return operator = ( (long) a ); }
00446
00447 const sc_signed_subref& operator = ( uint64 a );
00448 const sc_signed_subref& operator = ( int64 a );
00449 const sc_signed_subref& operator = ( double a );
00450 const sc_signed_subref& operator = ( const sc_int_base& a );
00451 const sc_signed_subref& operator = ( const sc_uint_base& a );
00452
00453
00454
00455 virtual void concat_set(int64 src, int low_i);
00456 virtual void concat_set(const sc_signed& src, int low_i);
00457 virtual void concat_set(const sc_unsigned& src, int low_i);
00458 virtual void concat_set(uint64 src, int low_i);
00459
00460
00461
00462 void scan( ::std::istream& is = ::std::cin );
00463
00464 protected:
00465 static sc_core::sc_vpool<sc_signed_subref> m_pool;
00466 };
00467
00468
00469
00470 inline
00471 ::std::istream&
00472 operator >> ( ::std::istream&, sc_signed_subref& );
00473
00474
00475
00476
00477
00478
00479
00480
00481 class sc_signed : public sc_value_base
00482 {
00483 friend class sc_concatref;
00484 friend class sc_signed_bitref_r;
00485 friend class sc_signed_bitref;
00486 friend class sc_signed_subref_r;
00487 friend class sc_signed_subref;
00488 friend class sc_unsigned;
00489 friend class sc_unsigned_subref;
00490
00491
00492 typedef bool elemtype;
00493
00494 public:
00495
00496
00497
00498 explicit sc_signed( int nb = sc_length_param().len() );
00499 sc_signed( const sc_signed& v );
00500 sc_signed( const sc_unsigned& v );
00501 template<class T>
00502 explicit sc_signed( const sc_generic_base<T>& v );
00503 explicit sc_signed( const sc_bv_base& v );
00504 explicit sc_signed( const sc_lv_base& v );
00505 explicit sc_signed( const sc_int_subref_r& v );
00506 explicit sc_signed( const sc_uint_subref_r& v );
00507 explicit sc_signed( const sc_signed_subref_r& v );
00508 explicit sc_signed( const sc_unsigned_subref_r& v );
00509
00510
00511
00512 const sc_signed& operator = (const sc_signed& v);
00513 const sc_signed& operator = (const sc_signed_subref_r& a );
00514
00515 template< class T >
00516 const sc_signed& operator = ( const sc_generic_base<T>& a )
00517 { a->to_sc_signed(*this); return *this; }
00518
00519 const sc_signed& operator = (const sc_unsigned& v);
00520 const sc_signed& operator = (const sc_unsigned_subref_r& a );
00521
00522 const sc_signed& operator = (const char* v);
00523 const sc_signed& operator = (int64 v);
00524 const sc_signed& operator = (uint64 v);
00525 const sc_signed& operator = (long v);
00526 const sc_signed& operator = (unsigned long v);
00527
00528 const sc_signed& operator = (int v)
00529 { return operator=((long) v); }
00530
00531 const sc_signed& operator = (unsigned int v)
00532 { return operator=((unsigned long) v); }
00533
00534 const sc_signed& operator = (double v);
00535 const sc_signed& operator = (const sc_int_base& v);
00536 const sc_signed& operator = (const sc_uint_base& v);
00537
00538 const sc_signed& operator = ( const sc_bv_base& );
00539 const sc_signed& operator = ( const sc_lv_base& );
00540
00541 #ifdef SC_INCLUDE_FX
00542 const sc_signed& operator = ( const sc_fxval& );
00543 const sc_signed& operator = ( const sc_fxval_fast& );
00544 const sc_signed& operator = ( const sc_fxnum& );
00545 const sc_signed& operator = ( const sc_fxnum_fast& );
00546 #endif
00547
00548
00549
00550
00551 virtual ~sc_signed()
00552 {
00553 #ifndef SC_MAX_NBITS
00554 delete [] digit;
00555 #endif
00556 }
00557
00558
00559
00560 unsigned long* get_raw() const
00561 { return digit; }
00562 virtual int concat_length(bool* xz_present_p) const
00563 { if ( xz_present_p ) *xz_present_p = false; return nbits; }
00564 virtual bool concat_get_ctrl( unsigned long* dst_p, int low_i ) const;
00565 virtual bool concat_get_data( unsigned long* dst_p, int low_i ) const;
00566 virtual uint64 concat_get_uint64() const;
00567 virtual void concat_set(int64 src, int low_i);
00568 virtual void concat_set(const sc_signed& src, int low_i);
00569 virtual void concat_set(const sc_unsigned& src, int low_i);
00570 virtual void concat_set(uint64 src, int low_i);
00571
00572
00573
00574
00575 sc_signed& operator ++ ();
00576 const sc_signed operator ++ (int);
00577
00578
00579 sc_signed& operator -- ();
00580 const sc_signed operator -- (int);
00581
00582
00583
00584
00585 inline void check_index( int i ) const
00586 { }
00587
00588 void invalid_index( int i ) const;
00589
00590 sc_signed_bitref& operator [] ( int i )
00591 {
00592 check_index(i);
00593 sc_signed_bitref* result_p =
00594 sc_signed_bitref::m_pool.allocate();
00595 result_p->initialize( this, i );
00596 return *result_p;
00597 }
00598
00599 const sc_signed_bitref_r& operator [] ( int i ) const
00600 {
00601 check_index(i);
00602 sc_signed_bitref* result_p =
00603 sc_signed_bitref::m_pool.allocate();
00604 result_p->initialize( this, i );
00605 return *result_p;
00606 }
00607
00608 sc_signed_bitref& bit( int i )
00609 {
00610 check_index(i);
00611 sc_signed_bitref* result_p =
00612 sc_signed_bitref::m_pool.allocate();
00613 result_p->initialize( this, i );
00614 return *result_p;
00615 }
00616
00617 const sc_signed_bitref_r& bit( int i ) const
00618 {
00619 check_index(i);
00620 sc_signed_bitref* result_p =
00621 sc_signed_bitref::m_pool.allocate();
00622 result_p->initialize( this, i );
00623 return *result_p;
00624 }
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636 inline void check_range( int l, int r ) const
00637 {
00638 #if 0 // Enable this when range checking is agreed to.
00639 if ( l < r )
00640 {
00641 if ( l < 0 || r >= nbits ) invalid_range(l,r);
00642 }
00643 else
00644 {
00645 if ( r < 0 || l >= nbits ) invalid_range(l,r);
00646 }
00647 #endif // 0
00648 }
00649
00650 void invalid_range( int l, int r ) const;
00651
00652 sc_signed_subref& range( int i, int j )
00653 {
00654 check_range( i, j );
00655 sc_signed_subref* result_p =
00656 sc_signed_subref::m_pool.allocate();
00657 result_p->initialize( this, i, j );
00658 return *result_p;
00659 }
00660
00661 const sc_signed_subref_r& range( int i, int j ) const
00662 {
00663 check_range( i, j );
00664 sc_signed_subref* result_p =
00665 sc_signed_subref::m_pool.allocate();
00666 result_p->initialize( this, i, j );
00667 return *result_p;
00668 }
00669
00670 sc_signed_subref& operator () ( int i, int j )
00671 {
00672 check_range( i, j );
00673 sc_signed_subref* result_p =
00674 sc_signed_subref::m_pool.allocate();
00675 result_p->initialize( this, i, j );
00676 return *result_p;
00677 }
00678
00679 const sc_signed_subref_r& operator () ( int i, int j ) const
00680 {
00681 check_range( i, j );
00682 sc_signed_subref* result_p =
00683 sc_signed_subref::m_pool.allocate();
00684 result_p->initialize( this, i, j );
00685 return *result_p;
00686 }
00687
00688
00689
00690
00691 int to_int() const;
00692 unsigned int to_uint() const;
00693 long to_long() const;
00694 unsigned long to_ulong() const;
00695 int64 to_int64() const;
00696 uint64 to_uint64() const;
00697 double to_double() const;
00698
00699 #ifdef SC_DT_DEPRECATED
00700 int to_signed() const
00701 { return to_int(); }
00702
00703 unsigned int to_unsigned() const
00704 { return to_uint(); }
00705 #endif
00706
00707
00708
00709 const std::string to_string( sc_numrep numrep = SC_DEC ) const;
00710 const std::string to_string( sc_numrep numrep, bool w_prefix ) const;
00711
00712
00713
00714
00715 void print( ::std::ostream& os = ::std::cout ) const
00716 { os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }
00717
00718 void scan( ::std::istream& is = ::std::cin );
00719
00720 void dump( ::std::ostream& os = ::std::cout ) const;
00721
00722
00723
00724 int length() const { return nbits; }
00725 bool iszero() const;
00726 bool sign() const;
00727
00728
00729
00730 bool and_reduce() const;
00731
00732 bool nand_reduce() const
00733 { return ( ! and_reduce() ); }
00734
00735 bool or_reduce() const;
00736
00737 bool nor_reduce() const
00738 { return ( ! or_reduce() ); }
00739
00740 bool xor_reduce() const;
00741
00742 bool xnor_reduce() const
00743 { return ( ! xor_reduce() ); }
00744
00745
00746 bool test(int i) const;
00747 void set(int i);
00748 void clear(int i);
00749 void set(int i, bool v)
00750 { if (v) set(i); else clear(i); }
00751 void invert(int i)
00752 { if (test(i)) clear(i); else set(i); }
00753
00754
00755 void reverse();
00756
00757
00758 void get_packed_rep(unsigned long *buf) const;
00759 void set_packed_rep(unsigned long *buf);
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794 friend sc_signed operator + (const sc_unsigned& u, const sc_signed& v);
00795 friend sc_signed operator + (const sc_signed& u, const sc_unsigned& v);
00796
00797 friend sc_signed operator + (const sc_unsigned& u, int64 v);
00798 friend sc_signed operator + (const sc_unsigned& u, long v);
00799 friend sc_signed operator + (const sc_unsigned& u, int v)
00800 { return operator+(u, (long) v); }
00801
00802 friend sc_signed operator + (int64 u, const sc_unsigned& v);
00803 friend sc_signed operator + (long u, const sc_unsigned& v);
00804 friend sc_signed operator + (int u, const sc_unsigned& v)
00805 { return operator+((long) u, v); }
00806
00807 friend sc_signed operator + (const sc_signed& u, const sc_signed& v);
00808 friend sc_signed operator + (const sc_signed& u, int64 v);
00809 friend sc_signed operator + (const sc_signed& u, uint64 v);
00810 friend sc_signed operator + (const sc_signed& u, long v);
00811 friend sc_signed operator + (const sc_signed& u, unsigned long v);
00812 friend sc_signed operator + (const sc_signed& u, int v)
00813 { return operator+(u, (long) v); }
00814 friend sc_signed operator + (const sc_signed& u, unsigned int v)
00815 { return operator+(u, (unsigned long) v); }
00816
00817 friend sc_signed operator + (int64 u, const sc_signed& v);
00818 friend sc_signed operator + (uint64 u, const sc_signed& v);
00819 friend sc_signed operator + (long u, const sc_signed& v);
00820 friend sc_signed operator + (unsigned long u, const sc_signed& v);
00821 friend sc_signed operator + (int u, const sc_signed& v)
00822 { return operator+((long) u, v); }
00823 friend sc_signed operator + (unsigned int u, const sc_signed& v)
00824 { return operator+((unsigned long) u, v); }
00825
00826 const sc_signed& operator += (const sc_signed& v);
00827 const sc_signed& operator += (const sc_unsigned& v);
00828 const sc_signed& operator += (int64 v);
00829 const sc_signed& operator += (uint64 v);
00830 const sc_signed& operator += (long v);
00831 const sc_signed& operator += (unsigned long v);
00832 const sc_signed& operator += (int v)
00833 { return operator+=((long) v); }
00834 const sc_signed& operator += (unsigned int v)
00835 { return operator+=((unsigned long) v); }
00836
00837 friend sc_signed operator + (const sc_unsigned& u, const sc_int_base& v);
00838 friend sc_signed operator + (const sc_int_base& u, const sc_unsigned& v);
00839 friend sc_signed operator + (const sc_signed& u, const sc_int_base& v);
00840 friend sc_signed operator + (const sc_signed& u, const sc_uint_base& v);
00841 friend sc_signed operator + (const sc_int_base& u, const sc_signed& v);
00842 friend sc_signed operator + (const sc_uint_base& u, const sc_signed& v);
00843 const sc_signed& operator += (const sc_int_base& v);
00844 const sc_signed& operator += (const sc_uint_base& v);
00845
00846
00847
00848 friend sc_signed operator - (const sc_unsigned& u, const sc_signed& v);
00849 friend sc_signed operator - (const sc_signed& u, const sc_unsigned& v);
00850
00851 friend sc_signed operator - (const sc_unsigned& u, const sc_unsigned& v);
00852 friend sc_signed operator - (const sc_unsigned& u, int64 v);
00853 friend sc_signed operator - (const sc_unsigned& u, uint64 v);
00854 friend sc_signed operator - (const sc_unsigned& u, long v);
00855 friend sc_signed operator - (const sc_unsigned& u, unsigned long v);
00856 friend sc_signed operator - (const sc_unsigned& u, int v)
00857 { return operator-(u, (long) v); }
00858 friend sc_signed operator - (const sc_unsigned& u, unsigned int v)
00859 { return operator-(u, (unsigned long) v); }
00860
00861 friend sc_signed operator - (int64 u, const sc_unsigned& v);
00862 friend sc_signed operator - (uint64 u, const sc_unsigned& v);
00863 friend sc_signed operator - (long u, const sc_unsigned& v);
00864 friend sc_signed operator - (unsigned long u, const sc_unsigned& v);
00865 friend sc_signed operator - (int u, const sc_unsigned& v)
00866 { return operator-((long) u, v); }
00867 friend sc_signed operator - (unsigned int u, const sc_unsigned& v)
00868 { return operator-((unsigned long) u, v); }
00869
00870 friend sc_signed operator - (const sc_signed& u, const sc_signed& v);
00871 friend sc_signed operator - (const sc_signed& u, int64 v);
00872 friend sc_signed operator - (const sc_signed& u, uint64 v);
00873 friend sc_signed operator - (const sc_signed& u, long v);
00874 friend sc_signed operator - (const sc_signed& u, unsigned long v);
00875 friend sc_signed operator - (const sc_signed& u, int v)
00876 { return operator-(u, (long) v); }
00877 friend sc_signed operator - (const sc_signed& u, unsigned int v)
00878 { return operator-(u, (unsigned long) v); }
00879
00880 friend sc_signed operator - (int64 u, const sc_signed& v);
00881 friend sc_signed operator - (uint64 u, const sc_signed& v);
00882 friend sc_signed operator - (long u, const sc_signed& v);
00883 friend sc_signed operator - (unsigned long u, const sc_signed& v);
00884 friend sc_signed operator - (int u, const sc_signed& v)
00885 { return operator-((long) u, v); }
00886 friend sc_signed operator - (unsigned int u, const sc_signed& v)
00887 { return operator-((unsigned long) u, v); }
00888
00889 const sc_signed& operator -= (const sc_signed& v);
00890 const sc_signed& operator -= (const sc_unsigned& v);
00891 const sc_signed& operator -= (int64 v);
00892 const sc_signed& operator -= (uint64 v);
00893 const sc_signed& operator -= (long v);
00894 const sc_signed& operator -= (unsigned long v);
00895 const sc_signed& operator -= (int v)
00896 { return operator -= ((long) v); }
00897 const sc_signed& operator -= (unsigned int v)
00898 { return operator -= ((unsigned long) v); }
00899
00900 friend sc_signed operator - (const sc_unsigned& u, const sc_int_base& v);
00901 friend sc_signed operator - (const sc_unsigned& u, const sc_uint_base& v);
00902 friend sc_signed operator - (const sc_int_base& u, const sc_unsigned& v);
00903 friend sc_signed operator - (const sc_uint_base& u, const sc_unsigned& v);
00904 friend sc_signed operator - (const sc_signed& u, const sc_int_base& v);
00905 friend sc_signed operator - (const sc_signed& u, const sc_uint_base& v);
00906 friend sc_signed operator - (const sc_int_base& u, const sc_signed& v);
00907 friend sc_signed operator - (const sc_uint_base& u, const sc_signed& v);
00908 const sc_signed& operator -= (const sc_int_base& v);
00909 const sc_signed& operator -= (const sc_uint_base& v);
00910
00911
00912
00913 friend sc_signed operator * (const sc_unsigned& u, const sc_signed& v);
00914 friend sc_signed operator * (const sc_signed& u, const sc_unsigned& v);
00915
00916 friend sc_signed operator * (const sc_unsigned& u, int64 v);
00917 friend sc_signed operator * (const sc_unsigned& u, long v);
00918 friend sc_signed operator * (const sc_unsigned& u, int v)
00919 { return operator*(u, (long) v); }
00920
00921 friend sc_signed operator * (int64 u, const sc_unsigned& v);
00922 friend sc_signed operator * (long u, const sc_unsigned& v);
00923 friend sc_signed operator * (int u, const sc_unsigned& v)
00924 { return operator*((long) u, v); }
00925
00926 friend sc_signed operator * (const sc_signed& u, const sc_signed& v);
00927 friend sc_signed operator * (const sc_signed& u, int64 v);
00928 friend sc_signed operator * (const sc_signed& u, uint64 v);
00929 friend sc_signed operator * (const sc_signed& u, long v);
00930 friend sc_signed operator * (const sc_signed& u, unsigned long v);
00931 friend sc_signed operator * (const sc_signed& u, int v)
00932 { return operator*(u, (long) v); }
00933 friend sc_signed operator * (const sc_signed& u, unsigned int v)
00934 { return operator*(u, (unsigned long) v); }
00935
00936 friend sc_signed operator * (int64 u, const sc_signed& v);
00937 friend sc_signed operator * (uint64 u, const sc_signed& v);
00938 friend sc_signed operator * (long u, const sc_signed& v);
00939 friend sc_signed operator * (unsigned long u, const sc_signed& v);
00940 friend sc_signed operator * (int u, const sc_signed& v)
00941 { return operator*((long) u, v); }
00942 friend sc_signed operator * (unsigned int u, const sc_signed& v)
00943 { return operator*((unsigned long) u, v); }
00944
00945 const sc_signed& operator *= (const sc_signed& v);
00946 const sc_signed& operator *= (const sc_unsigned& v);
00947 const sc_signed& operator *= (int64 v);
00948 const sc_signed& operator *= (uint64 v);
00949 const sc_signed& operator *= (long v);
00950 const sc_signed& operator *= (unsigned long v);
00951 const sc_signed& operator *= (int v)
00952 { return operator*=((long) v); }
00953 const sc_signed& operator *= (unsigned int v)
00954 { return operator*=((unsigned long) v); }
00955
00956 friend sc_signed operator * (const sc_unsigned& u, const sc_int_base& v);
00957 friend sc_signed operator * (const sc_int_base& u, const sc_unsigned& v);
00958 friend sc_signed operator * (const sc_signed& u, const sc_int_base& v);
00959 friend sc_signed operator * (const sc_signed& u, const sc_uint_base& v);
00960 friend sc_signed operator * (const sc_int_base& u, const sc_signed& v);
00961 friend sc_signed operator * (const sc_uint_base& u, const sc_signed& v);
00962 const sc_signed& operator *= (const sc_int_base& v);
00963 const sc_signed& operator *= (const sc_uint_base& v);
00964
00965
00966
00967 friend sc_signed operator / (const sc_unsigned& u, const sc_signed& v);
00968 friend sc_signed operator / (const sc_signed& u, const sc_unsigned& v);
00969
00970 friend sc_signed operator / (const sc_unsigned& u, int64 v);
00971 friend sc_signed operator / (const sc_unsigned& u, long v);
00972 friend sc_signed operator / (const sc_unsigned& u, int v)
00973 { return operator/(u, (long) v); }
00974
00975 friend sc_signed operator / (int64 u, const sc_unsigned& v);
00976 friend sc_signed operator / (long u, const sc_unsigned& v);
00977 friend sc_signed operator / (int u, const sc_unsigned& v)
00978 { return operator/((long) u, v); }
00979
00980 friend sc_signed operator / (const sc_signed& u, const sc_signed& v);
00981 friend sc_signed operator / (const sc_signed& u, int64 v);
00982 friend sc_signed operator / (const sc_signed& u, uint64 v);
00983 friend sc_signed operator / (const sc_signed& u, long v);
00984 friend sc_signed operator / (const sc_signed& u, unsigned long v);
00985 friend sc_signed operator / (const sc_signed& u, int v)
00986 { return operator/(u, (long) v); }
00987 friend sc_signed operator / (const sc_signed& u, unsigned int v)
00988 { return operator/(u, (unsigned long) v); }
00989
00990 friend sc_signed operator / (int64 u, const sc_signed& v);
00991 friend sc_signed operator / (uint64 u, const sc_signed& v);
00992 friend sc_signed operator / (long u, const sc_signed& v);
00993 friend sc_signed operator / (unsigned long u, const sc_signed& v);
00994 friend sc_signed operator / (int u, const sc_signed& v)
00995 { return operator/((long) u, v); }
00996 friend sc_signed operator / (unsigned int u, const sc_signed& v)
00997 { return operator/((unsigned long) u, v); }
00998
00999 const sc_signed& operator /= (const sc_signed& v);
01000 const sc_signed& operator /= (const sc_unsigned& v);
01001 const sc_signed& operator /= (int64 v);
01002 const sc_signed& operator /= (uint64 v);
01003 const sc_signed& operator /= (long v);
01004 const sc_signed& operator /= (unsigned long v);
01005 const sc_signed& operator /= (int v)
01006 { return operator/=((long) v); }
01007 const sc_signed& operator /= (unsigned int v)
01008 { return operator/=((unsigned long) v); }
01009
01010 friend sc_signed operator / (const sc_unsigned& u, const sc_int_base& v);
01011 friend sc_signed operator / (const sc_int_base& u, const sc_unsigned& v);
01012 friend sc_signed operator / (const sc_signed& u, const sc_int_base& v);
01013 friend sc_signed operator / (const sc_signed& u, const sc_uint_base& v);
01014 friend sc_signed operator / (const sc_int_base& u, const sc_signed& v);
01015 friend sc_signed operator / (const sc_uint_base& u, const sc_signed& v);
01016 const sc_signed& operator /= (const sc_int_base& v);
01017 const sc_signed& operator /= (const sc_uint_base& v);
01018
01019
01020
01021 friend sc_signed operator % (const sc_unsigned& u, const sc_signed& v);
01022 friend sc_signed operator % (const sc_signed& u, const sc_unsigned& v);
01023
01024 friend sc_signed operator % (const sc_unsigned& u, int64 v);
01025 friend sc_signed operator % (const sc_unsigned& u, long v);
01026 friend sc_signed operator % (const sc_unsigned& u, int v)
01027 { return operator%(u, (long) v); }
01028
01029 friend sc_signed operator % (int64 u, const sc_unsigned& v);
01030 friend sc_signed operator % (long u, const sc_unsigned& v);
01031 friend sc_signed operator % (int u, const sc_unsigned& v)
01032 { return operator%((long) u, v); }
01033
01034 friend sc_signed operator % (const sc_signed& u, const sc_signed& v);
01035 friend sc_signed operator % (const sc_signed& u, int64 v);
01036 friend sc_signed operator % (const sc_signed& u, uint64 v);
01037 friend sc_signed operator % (const sc_signed& u, long v);
01038 friend sc_signed operator % (const sc_signed& u, unsigned long v);
01039 friend sc_signed operator % (const sc_signed& u, int v)
01040 { return operator%(u, (long) v); }
01041 friend sc_signed operator % (const sc_signed& u, unsigned int v)
01042 { return operator%(u, (unsigned long) v); }
01043
01044 friend sc_signed operator % (int64 u, const sc_signed& v);
01045 friend sc_signed operator % (uint64 u, const sc_signed& v);
01046 friend sc_signed operator % (long u, const sc_signed& v);
01047 friend sc_signed operator % (unsigned long u, const sc_signed& v);
01048 friend sc_signed operator % (int u, const sc_signed& v)
01049 { return operator%((long) u, v); }
01050 friend sc_signed operator % (unsigned int u, const sc_signed& v)
01051 { return operator%((unsigned long) u, v); }
01052
01053 const sc_signed& operator %= (const sc_signed& v);
01054 const sc_signed& operator %= (const sc_unsigned& v);
01055 const sc_signed& operator %= (int64 v);
01056 const sc_signed& operator %= (uint64 v);
01057 const sc_signed& operator %= (long v);
01058 const sc_signed& operator %= (unsigned long v);
01059 const sc_signed& operator %= (int v)
01060 { return operator%=((long) v); }
01061 const sc_signed& operator %= (unsigned int v)
01062 { return operator%=((unsigned long) v); }
01063
01064 friend sc_signed operator % (const sc_unsigned& u, const sc_int_base& v);
01065 friend sc_signed operator % (const sc_int_base& u, const sc_unsigned& v);
01066 friend sc_signed operator % (const sc_signed& u, const sc_int_base& v);
01067 friend sc_signed operator % (const sc_signed& u, const sc_uint_base& v);
01068 friend sc_signed operator % (const sc_int_base& u, const sc_signed& v);
01069 friend sc_signed operator % (const sc_uint_base& u, const sc_signed& v);
01070 const sc_signed& operator %= (const sc_int_base& v);
01071 const sc_signed& operator %= (const sc_uint_base& v);
01072
01073
01074
01075
01076
01077 friend sc_signed operator & (const sc_unsigned& u, const sc_signed& v);
01078 friend sc_signed operator & (const sc_signed& u, const sc_unsigned& v);
01079
01080 friend sc_signed operator & (const sc_unsigned& u, int64 v);
01081 friend sc_signed operator & (const sc_unsigned& u, long v);
01082 friend sc_signed operator & (const sc_unsigned& u, int v)
01083 { return operator&(u, (long) v); }
01084
01085 friend sc_signed operator & (int64 u, const sc_unsigned& v);
01086 friend sc_signed operator & (long u, const sc_unsigned& v);
01087 friend sc_signed operator & (int u, const sc_unsigned& v)
01088 { return operator&((long) u, v); }
01089
01090 friend sc_signed operator & (const sc_signed& u, const sc_signed& v);
01091 friend sc_signed operator & (const sc_signed& u, int64 v);
01092 friend sc_signed operator & (const sc_signed& u, uint64 v);
01093 friend sc_signed operator & (const sc_signed& u, long v);
01094 friend sc_signed operator & (const sc_signed& u, unsigned long v);
01095 friend sc_signed operator & (const sc_signed& u, int v)
01096 { return operator&(u, (long) v); }
01097 friend sc_signed operator & (const sc_signed& u, unsigned int v)
01098 { return operator&(u, (unsigned long) v); }
01099
01100 friend sc_signed operator & (int64 u, const sc_signed& v);
01101 friend sc_signed operator & (uint64 u, const sc_signed& v);
01102 friend sc_signed operator & (long u, const sc_signed& v);
01103 friend sc_signed operator & (unsigned long u, const sc_signed& v);
01104 friend sc_signed operator & (int u, const sc_signed& v)
01105 { return operator&((long) u, v); }
01106 friend sc_signed operator & (unsigned int u, const sc_signed& v)
01107 { return operator&((unsigned long) u, v); }
01108
01109 const sc_signed& operator &= (const sc_signed& v);
01110 const sc_signed& operator &= (const sc_unsigned& v);
01111 const sc_signed& operator &= (int64 v);
01112 const sc_signed& operator &= (uint64 v);
01113 const sc_signed& operator &= (long v);
01114 const sc_signed& operator &= (unsigned long v);
01115 const sc_signed& operator &= (int v)
01116 { return operator&=((long) v); }
01117 const sc_signed& operator &= (unsigned int v)
01118 { return operator&=((unsigned long) v); }
01119
01120 friend sc_signed operator & (const sc_unsigned& u, const sc_int_base& v);
01121 friend sc_signed operator & (const sc_int_base& u, const sc_unsigned& v);
01122 friend sc_signed operator & (const sc_signed& u, const sc_int_base& v);
01123 friend sc_signed operator & (const sc_signed& u, const sc_uint_base& v);
01124 friend sc_signed operator & (const sc_int_base& u, const sc_signed& v);
01125 friend sc_signed operator & (const sc_uint_base& u, const sc_signed& v);
01126 const sc_signed& operator &= (const sc_int_base& v);
01127 const sc_signed& operator &= (const sc_uint_base& v);
01128
01129
01130
01131 friend sc_signed operator | (const sc_unsigned& u, const sc_signed& v);
01132 friend sc_signed operator | (const sc_signed& u, const sc_unsigned& v);
01133
01134 friend sc_signed operator | (const sc_unsigned& u, int64 v);
01135 friend sc_signed operator | (const sc_unsigned& u, long v);
01136 friend sc_signed operator | (const sc_unsigned& u, int v)
01137 { return operator|(u, (long) v); }
01138
01139 friend sc_signed operator | (int64 u, const sc_unsigned& v);
01140 friend sc_signed operator | (long u, const sc_unsigned& v);
01141 friend sc_signed operator | (int u, const sc_unsigned& v)
01142 { return operator|((long) u, v); }
01143
01144 friend sc_signed operator | (const sc_signed& u, const sc_signed& v);
01145 friend sc_signed operator | (const sc_signed& u, int64 v);
01146 friend sc_signed operator | (const sc_signed& u, uint64 v);
01147 friend sc_signed operator | (const sc_signed& u, long v);
01148 friend sc_signed operator | (const sc_signed& u, unsigned long v);
01149 friend sc_signed operator | (const sc_signed& u, int v)
01150 { return operator|(u, (long) v); }
01151 friend sc_signed operator | (const sc_signed& u, unsigned int v)
01152 { return operator|(u, (unsigned long) v); }
01153
01154 friend sc_signed operator | (int64 u, const sc_signed& v);
01155 friend sc_signed operator | (uint64 u, const sc_signed& v);
01156 friend sc_signed operator | (long u, const sc_signed& v);
01157 friend sc_signed operator | (unsigned long u, const sc_signed& v);
01158 friend sc_signed operator | (int u, const sc_signed& v)
01159 { return operator|((long) u, v); }
01160 friend sc_signed operator | (unsigned int u, const sc_signed& v)
01161 { return operator|((unsigned long) u, v); }
01162
01163 const sc_signed& operator |= (const sc_signed& v);
01164 const sc_signed& operator |= (const sc_unsigned& v);
01165 const sc_signed& operator |= (int64 v);
01166 const sc_signed& operator |= (uint64 v);
01167 const sc_signed& operator |= (long v);
01168 const sc_signed& operator |= (unsigned long v);
01169 const sc_signed& operator |= (int v)
01170 { return operator|=((long) v); }
01171 const sc_signed& operator |= (unsigned int v)
01172 { return operator|=((unsigned long) v); }
01173
01174 friend sc_signed operator | (const sc_unsigned& u, const sc_int_base& v);
01175 friend sc_signed operator | (const sc_int_base& u, const sc_unsigned& v);
01176 friend sc_signed operator | (const sc_signed& u, const sc_int_base& v);
01177 friend sc_signed operator | (const sc_signed& u, const sc_uint_base& v);
01178 friend sc_signed operator | (const sc_int_base& u, const sc_signed& v);
01179 friend sc_signed operator | (const sc_uint_base& u, const sc_signed& v);
01180 const sc_signed& operator |= (const sc_int_base& v);
01181 const sc_signed& operator |= (const sc_uint_base& v);
01182
01183
01184
01185 friend sc_signed operator ^ (const sc_unsigned& u, const sc_signed& v);
01186 friend sc_signed operator ^ (const sc_signed& u, const sc_unsigned& v);
01187
01188 friend sc_signed operator ^ (const sc_unsigned& u, int64 v);
01189 friend sc_signed operator ^ (const sc_unsigned& u, long v);
01190 friend sc_signed operator ^ (const sc_unsigned& u, int v)
01191 { return operator^(u, (long) v); }
01192
01193 friend sc_signed operator ^ (int64 u, const sc_unsigned& v);
01194 friend sc_signed operator ^ (long u, const sc_unsigned& v);
01195 friend sc_signed operator ^ (int u, const sc_unsigned& v)
01196 { return operator^((long) u, v); }
01197
01198 friend sc_signed operator ^ (const sc_signed& u, const sc_signed& v);
01199 friend sc_signed operator ^ (const sc_signed& u, int64 v);
01200 friend sc_signed operator ^ (const sc_signed& u, uint64 v);
01201 friend sc_signed operator ^ (const sc_signed& u, long v);
01202 friend sc_signed operator ^ (const sc_signed& u, unsigned long v);
01203 friend sc_signed operator ^ (const sc_signed& u, int v)
01204 { return operator^(u, (long) v); }
01205 friend sc_signed operator ^ (const sc_signed& u, unsigned int v)
01206 { return operator^(u, (unsigned long) v); }
01207
01208 friend sc_signed operator ^ (int64 u, const sc_signed& v);
01209 friend sc_signed operator ^ (uint64 u, const sc_signed& v);
01210 friend sc_signed operator ^ (long u, const sc_signed& v);
01211 friend sc_signed operator ^ (unsigned long u, const sc_signed& v);
01212 friend sc_signed operator ^ (int u, const sc_signed& v)
01213 { return operator^((long) u, v); }
01214 friend sc_signed operator ^ (unsigned int u, const sc_signed& v)
01215 { return operator^((unsigned long) u, v); }
01216
01217 const sc_signed& operator ^= (const sc_signed& v);
01218 const sc_signed& operator ^= (const sc_unsigned& v);
01219 const sc_signed& operator ^= (int64 v);
01220 const sc_signed& operator ^= (uint64 v);
01221 const sc_signed& operator ^= (long v);
01222 const sc_signed& operator ^= (unsigned long v);
01223 const sc_signed& operator ^= (int v)
01224 { return operator^=((long) v); }
01225 const sc_signed& operator ^= (unsigned int v)
01226 { return operator^=((unsigned long) v); }
01227
01228 friend sc_signed operator ^ (const sc_unsigned& u, const sc_int_base& v);
01229 friend sc_signed operator ^ (const sc_int_base& u, const sc_unsigned& v);
01230 friend sc_signed operator ^ (const sc_signed& u, const sc_int_base& v);
01231 friend sc_signed operator ^ (const sc_signed& u, const sc_uint_base& v);
01232 friend sc_signed operator ^ (const sc_int_base& u, const sc_signed& v);
01233 friend sc_signed operator ^ (const sc_uint_base& u, const sc_signed& v);
01234 const sc_signed& operator ^= (const sc_int_base& v);
01235 const sc_signed& operator ^= (const sc_uint_base& v);
01236
01237
01238
01239
01240
01241 friend sc_unsigned operator << (const sc_unsigned& u, const sc_signed& v);
01242 friend sc_signed operator << (const sc_signed& u, const sc_unsigned& v);
01243
01244 friend sc_signed operator << (const sc_signed& u, const sc_signed& v);
01245 friend sc_signed operator << (const sc_signed& u, int64 v);
01246 friend sc_signed operator << (const sc_signed& u, uint64 v);
01247 friend sc_signed operator << (const sc_signed& u, long v);
01248 friend sc_signed operator << (const sc_signed& u, unsigned long v);
01249 friend sc_signed operator << (const sc_signed& u, int v)
01250 { return operator<<(u, (long) v); }
01251 friend sc_signed operator << (const sc_signed& u, unsigned int v)
01252 { return operator<<(u, (unsigned long) v); }
01253
01254 const sc_signed& operator <<= (const sc_signed& v);
01255 const sc_signed& operator <<= (const sc_unsigned& v);
01256 const sc_signed& operator <<= (int64 v);
01257 const sc_signed& operator <<= (uint64 v);
01258 const sc_signed& operator <<= (long v);
01259 const sc_signed& operator <<= (unsigned long v);
01260 const sc_signed& operator <<= (int v)
01261 { return operator<<=((long) v); }
01262 const sc_signed& operator <<= (unsigned int v)
01263 { return operator<<=((unsigned long) v); }
01264
01265 friend sc_signed operator << (const sc_signed& u, const sc_int_base& v);
01266 friend sc_signed operator << (const sc_signed& u, const sc_uint_base& v);
01267 const sc_signed& operator <<= (const sc_int_base& v);
01268 const sc_signed& operator <<= (const sc_uint_base& v);
01269
01270
01271
01272 friend sc_unsigned operator >> (const sc_unsigned& u, const sc_signed& v);
01273 friend sc_signed operator >> (const sc_signed& u, const sc_unsigned& v);
01274
01275 friend sc_signed operator >> (const sc_signed& u, const sc_signed& v);
01276 friend sc_signed operator >> (const sc_signed& u, int64 v);
01277 friend sc_signed operator >> (const sc_signed& u, uint64 v);
01278 friend sc_signed operator >> (const sc_signed& u, long v);
01279 friend sc_signed operator >> (const sc_signed& u, unsigned long v);
01280 friend sc_signed operator >> (const sc_signed& u, int v)
01281 { return operator>>(u, (long) v); }
01282 friend sc_signed operator >> (const sc_signed& u, unsigned int v)
01283 { return operator>>(u, (unsigned long) v); }
01284
01285 const sc_signed& operator >>= (const sc_signed& v);
01286 const sc_signed& operator >>= (const sc_unsigned& v);
01287 const sc_signed& operator >>= (int64 v);
01288 const sc_signed& operator >>= (uint64 v);
01289 const sc_signed& operator >>= (long v);
01290 const sc_signed& operator >>= (unsigned long v);
01291 const sc_signed& operator >>= (int v)
01292 { return operator>>=((long) v); }
01293 const sc_signed& operator >>= (unsigned int v)
01294 { return operator>>=((unsigned long) v); }
01295
01296 friend sc_signed operator >> (const sc_signed& u, const sc_int_base& v);
01297 friend sc_signed operator >> (const sc_signed& u, const sc_uint_base& v);
01298 const sc_signed& operator >>= (const sc_int_base& v);
01299 const sc_signed& operator >>= (const sc_uint_base& v);
01300
01301
01302 friend sc_signed operator + (const sc_signed& u);
01303 friend sc_signed operator - (const sc_signed& u);
01304 friend sc_signed operator - (const sc_unsigned& u);
01305
01306
01307
01308
01309
01310 friend bool operator == (const sc_unsigned& u, const sc_signed& v);
01311 friend bool operator == (const sc_signed& u, const sc_unsigned& v);
01312
01313 friend bool operator == (const sc_signed& u, const sc_signed& v);
01314 friend bool operator == (const sc_signed& u, int64 v);
01315 friend bool operator == (const sc_signed& u, uint64 v);
01316 friend bool operator == (const sc_signed& u, long v);
01317 friend bool operator == (const sc_signed& u, unsigned long v);
01318 friend bool operator == (const sc_signed& u, int v)
01319 { return operator==(u, (long) v); }
01320 friend bool operator == (const sc_signed& u, unsigned int v)
01321 { return operator==(u, (unsigned long) v); }
01322
01323 friend bool operator == (int64 u, const sc_signed& v);
01324 friend bool operator == (uint64 u, const sc_signed& v);
01325 friend bool operator == (long u, const sc_signed& v);
01326 friend bool operator == (unsigned long u, const sc_signed& v);
01327 friend bool operator == (int u, const sc_signed& v)
01328 { return operator==((long) u, v); }
01329 friend bool operator == (unsigned int u, const sc_signed& v)
01330 { return operator==((unsigned long) u, v); }
01331
01332 friend bool operator == (const sc_signed& u, const sc_int_base& v);
01333 friend bool operator == (const sc_signed& u, const sc_uint_base& v);
01334 friend bool operator == (const sc_int_base& u, const sc_signed& v);
01335 friend bool operator == (const sc_uint_base& u, const sc_signed& v);
01336
01337
01338
01339 friend bool operator != (const sc_unsigned& u, const sc_signed& v);
01340 friend bool operator != (const sc_signed& u, const sc_unsigned& v);
01341
01342 friend bool operator != (const sc_signed& u, const sc_signed& v);
01343 friend bool operator != (const sc_signed& u, int64 v);
01344 friend bool operator != (const sc_signed& u, uint64 v);
01345 friend bool operator != (const sc_signed& u, long v);
01346 friend bool operator != (const sc_signed& u, unsigned long v);
01347 friend bool operator != (const sc_signed& u, int v)
01348 { return operator!=(u, (long) v); }
01349 friend bool operator != (const sc_signed& u, unsigned int v)
01350 { return operator!=(u, (unsigned long) v); }
01351
01352 friend bool operator != (int64 u, const sc_signed& v);
01353 friend bool operator != (uint64 u, const sc_signed& v);
01354 friend bool operator != (long u, const sc_signed& v);
01355 friend bool operator != (unsigned long u, const sc_signed& v);
01356 friend bool operator != (int u, const sc_signed& v)
01357 { return operator!=((long) u, v); }
01358 friend bool operator != (unsigned int u, const sc_signed& v)
01359 { return operator!=((unsigned long) u, v); }
01360
01361 friend bool operator != (const sc_signed& u, const sc_int_base& v);
01362 friend bool operator != (const sc_signed& u, const sc_uint_base& v);
01363 friend bool operator != (const sc_int_base& u, const sc_signed& v);
01364 friend bool operator != (const sc_uint_base& u, const sc_signed& v);
01365
01366
01367
01368 friend bool operator < (const sc_unsigned& u, const sc_signed& v);
01369 friend bool operator < (const sc_signed& u, const sc_unsigned& v);
01370
01371 friend bool operator < (const sc_signed& u, const sc_signed& v);
01372 friend bool operator < (const sc_signed& u, int64 v);
01373 friend bool operator < (const sc_signed& u, uint64 v);
01374 friend bool operator < (const sc_signed& u, long v);
01375 friend bool operator < (const sc_signed& u, unsigned long v);
01376 friend bool operator < (const sc_signed& u, int v)
01377 { return operator<(u, (long) v); }
01378 friend bool operator < (const sc_signed& u, unsigned int v)
01379 { return operator<(u, (unsigned long) v); }
01380
01381 friend bool operator < (int64 u, const sc_signed& v);
01382 friend bool operator < (uint64 u, const sc_signed& v);
01383 friend bool operator < (long u, const sc_signed& v);
01384 friend bool operator < (unsigned long u, const sc_signed& v);
01385 friend bool operator < (int u, const sc_signed& v)
01386 { return operator<((long) u, v); }
01387 friend bool operator < (unsigned int u, const sc_signed& v)
01388 { return operator<((unsigned long) u, v); }
01389
01390 friend bool operator < (const sc_signed& u, const sc_int_base& v);
01391 friend bool operator < (const sc_signed& u, const sc_uint_base& v);
01392 friend bool operator < (const sc_int_base& u, const sc_signed& v);
01393 friend bool operator < (const sc_uint_base& u, const sc_signed& v);
01394
01395
01396
01397 friend bool operator <= (const sc_unsigned& u, const sc_signed& v);
01398 friend bool operator <= (const sc_signed& u, const sc_unsigned& v);
01399
01400 friend bool operator <= (const sc_signed& u, const sc_signed& v);
01401 friend bool operator <= (const sc_signed& u, int64 v);
01402 friend bool operator <= (const sc_signed& u, uint64 v);
01403 friend bool operator <= (const sc_signed& u, long v);
01404 friend bool operator <= (const sc_signed& u, unsigned long v);
01405 friend bool operator <= (const sc_signed& u, int v)
01406 { return operator<=(u, (long) v); }
01407 friend bool operator <= (const sc_signed& u, unsigned int v)
01408 { return operator<=(u, (unsigned long) v); }
01409
01410 friend bool operator <= (int64 u, const sc_signed& v);
01411 friend bool operator <= (uint64 u, const sc_signed& v);
01412 friend bool operator <= (long u, const sc_signed& v);
01413 friend bool operator <= (unsigned long u, const sc_signed& v);
01414 friend bool operator <= (int u, const sc_signed& v)
01415 { return operator<=((long) u, v); }
01416 friend bool operator <= (unsigned int u, const sc_signed& v)
01417 { return operator<=((unsigned long) u, v); }
01418
01419 friend bool operator <= (const sc_signed& u, const sc_int_base& v);
01420 friend bool operator <= (const sc_signed& u, const sc_uint_base& v);
01421 friend bool operator <= (const sc_int_base& u, const sc_signed& v);
01422 friend bool operator <= (const sc_uint_base& u, const sc_signed& v);
01423
01424
01425
01426 friend bool operator > (const sc_unsigned& u, const sc_signed& v);
01427 friend bool operator > (const sc_signed& u, const sc_unsigned& v);
01428
01429 friend bool operator > (const sc_signed& u, const sc_signed& v);
01430 friend bool operator > (const sc_signed& u, int64 v);
01431 friend bool operator > (const sc_signed& u, uint64 v);
01432 friend bool operator > (const sc_signed& u, long v);
01433 friend bool operator > (const sc_signed& u, unsigned long v);
01434 friend bool operator > (const sc_signed& u, int v)
01435 { return operator>(u, (long) v); }
01436 friend bool operator > (const sc_signed& u, unsigned int v)
01437 { return operator>(u, (unsigned long) v); }
01438
01439 friend bool operator > (int64 u, const sc_signed& v);
01440 friend bool operator > (uint64 u, const sc_signed& v);
01441 friend bool operator > (long u, const sc_signed& v);
01442 friend bool operator > (unsigned long u, const sc_signed& v);
01443 friend bool operator > (int u, const sc_signed& v)
01444 { return operator>((long) u, v); }
01445 friend bool operator > (unsigned int u, const sc_signed& v)
01446 { return operator>((unsigned long) u, v); }
01447
01448 friend bool operator > (const sc_signed& u, const sc_int_base& v);
01449 friend bool operator > (const sc_signed& u, const sc_uint_base& v);
01450 friend bool operator > (const sc_int_base& u, const sc_signed& v);
01451 friend bool operator > (const sc_uint_base& u, const sc_signed& v);
01452
01453
01454
01455 friend bool operator >= (const sc_unsigned& u, const sc_signed& v);
01456 friend bool operator >= (const sc_signed& u, const sc_unsigned& v);
01457
01458 friend bool operator >= (const sc_signed& u, const sc_signed& v);
01459 friend bool operator >= (const sc_signed& u, int64 v);
01460 friend bool operator >= (const sc_signed& u, uint64 v);
01461 friend bool operator >= (const sc_signed& u, long v);
01462 friend bool operator >= (const sc_signed& u, unsigned long v);
01463 friend bool operator >= (const sc_signed& u, int v)
01464 { return operator>=(u, (long) v); }
01465 friend bool operator >= (const sc_signed& u, unsigned int v)
01466 { return operator>=(u, (unsigned long) v); }
01467
01468 friend bool operator >= (int64 u, const sc_signed& v);
01469 friend bool operator >= (uint64 u, const sc_signed& v);
01470 friend bool operator >= (long u, const sc_signed& v);
01471 friend bool operator >= (unsigned long u, const sc_signed& v);
01472 friend bool operator >= (int u, const sc_signed& v)
01473 { return operator>=((long) u, v); }
01474 friend bool operator >= (unsigned int u, const sc_signed& v)
01475 { return operator>=((unsigned long) u, v); }
01476
01477 friend bool operator >= (const sc_signed& u, const sc_int_base& v);
01478 friend bool operator >= (const sc_signed& u, const sc_uint_base& v);
01479 friend bool operator >= (const sc_int_base& u, const sc_signed& v);
01480 friend bool operator >= (const sc_uint_base& u, const sc_signed& v);
01481
01482
01483 friend sc_signed operator ~ (const sc_signed& u);
01484
01485
01486 friend sc_signed add_signed_friend(small_type us,
01487 int unb,
01488 int und,
01489 const unsigned long *ud,
01490 small_type vs,
01491 int vnb,
01492 int vnd,
01493 const unsigned long *vd);
01494
01495 friend sc_signed sub_signed_friend(small_type us,
01496 int unb,
01497 int und,
01498 const unsigned long *ud,
01499 small_type vs,
01500 int vnb,
01501 int vnd,
01502 const unsigned long *vd);
01503
01504 friend sc_signed mul_signed_friend(small_type s,
01505 int unb,
01506 int und,
01507 const unsigned long *ud,
01508 int vnb,
01509 int vnd,
01510 const unsigned long *vd);
01511
01512 friend sc_signed div_signed_friend(small_type s,
01513 int unb,
01514 int und,
01515 const unsigned long *ud,
01516 int vnb,
01517 int vnd,
01518 const unsigned long *vd);
01519
01520 friend sc_signed mod_signed_friend(small_type us,
01521 int unb,
01522 int und,
01523 const unsigned long *ud,
01524 int vnb,
01525 int vnd,
01526 const unsigned long *vd);
01527
01528 friend sc_signed and_signed_friend(small_type us,
01529 int unb,
01530 int und,
01531 const unsigned long *ud,
01532 small_type vs,
01533 int vnb,
01534 int vnd,
01535 const unsigned long *vd);
01536
01537 friend sc_signed or_signed_friend(small_type us,
01538 int unb,
01539 int und,
01540 const unsigned long *ud,
01541 small_type vs,
01542 int vnb,
01543 int vnd,
01544 const unsigned long *vd);
01545
01546 friend sc_signed xor_signed_friend(small_type us,
01547 int unb,
01548 int und,
01549 const unsigned long *ud,
01550 small_type vs,
01551 int vnb,
01552 int vnd,
01553 const unsigned long *vd);
01554
01555 private:
01556
01557 small_type sgn;
01558 int nbits;
01559 int ndigits;
01560
01561 #ifdef SC_MAX_NBITS
01562 unsigned long digit[DIV_CEIL(SC_MAX_NBITS)];
01563 #else
01564 unsigned long *digit;
01565 #endif
01566
01567
01568
01569
01570 sc_signed(const sc_signed& v, small_type s);
01571 sc_signed(const sc_unsigned& v, small_type s);
01572
01573
01574 sc_signed(small_type s, int nb, int nd,
01575 unsigned long *d, bool alloc = true);
01576
01577
01578 sc_signed(const sc_signed* u, int l, int r);
01579 sc_signed(const sc_unsigned* u, int l, int r);
01580
01581
01582
01583 small_type default_sign() const
01584 { return SC_NOSIGN; }
01585
01586 int num_bits(int nb) const { return nb; }
01587
01588 bool check_if_outside(int bit_num) const;
01589
01590 void copy_digits(int nb, int nd, const unsigned long *d)
01591 { copy_digits_signed(sgn, nbits, ndigits, digit, nb, nd, d); }
01592
01593 void makezero()
01594 { sgn = make_zero(ndigits, digit); }
01595
01596
01597
01598 void convert_2C_to_SM()
01599 { sgn = convert_signed_2C_to_SM(nbits, ndigits, digit); }
01600
01601 void convert_SM_to_2C_to_SM()
01602 { sgn = convert_signed_SM_to_2C_to_SM(sgn, nbits, ndigits, digit); }
01603
01604 void convert_SM_to_2C()
01605 { convert_signed_SM_to_2C(sgn, ndigits, digit); }
01606
01607 };
01608
01609
01610
01611 inline
01612 ::std::ostream&
01613 operator << ( ::std::ostream&, const sc_signed& );
01614
01615 inline
01616 ::std::istream&
01617 operator >> ( ::std::istream&, sc_signed& );
01618
01619
01620
01621 inline
01622 ::std::ostream&
01623 operator << ( ::std::ostream& os, const sc_signed_bitref_r& a )
01624 {
01625 a.print( os );
01626 return os;
01627 }
01628
01629
01630 inline
01631 ::std::istream&
01632 operator >> ( ::std::istream& is, sc_signed_bitref& a )
01633 {
01634 a.scan( is );
01635 return is;
01636 }
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648 inline bool sc_signed_subref_r::and_reduce() const
01649 {
01650 const sc_signed* target_p = m_obj_p;
01651 for ( int i = m_right; i <= m_left; i++ )
01652 if ( !target_p->test(i) ) return false;
01653 return true;
01654 }
01655
01656 inline bool sc_signed_subref_r::nand_reduce() const
01657 {
01658 return !and_reduce();
01659 }
01660
01661 inline bool sc_signed_subref_r::or_reduce() const
01662 {
01663 const sc_signed* target_p = m_obj_p;
01664 for ( int i = m_right; i <= m_left; i++ )
01665 if ( target_p->test(i) ) return true;
01666 return false;
01667 }
01668
01669 inline bool sc_signed_subref_r::nor_reduce() const
01670 {
01671 return !or_reduce();
01672 }
01673
01674 inline bool sc_signed_subref_r::xor_reduce() const
01675 {
01676 int odd;
01677 const sc_signed* target_p = m_obj_p;
01678 odd = 0;
01679 for ( int i = m_right; i <= m_left; i++ )
01680 if ( target_p->test(i) ) odd = ~odd;
01681 return odd ? true : false;
01682 }
01683
01684 inline bool sc_signed_subref_r::xnor_reduce() const
01685 {
01686 return !xor_reduce();
01687 }
01688
01689 inline
01690 ::std::ostream&
01691 operator << ( ::std::ostream& os, const sc_signed_subref_r& a )
01692 {
01693 a.print( os );
01694 return os;
01695 }
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706 inline
01707 const sc_signed_subref&
01708 sc_signed_subref::operator = ( const char* a )
01709 {
01710 sc_signed aa( length() );
01711 return ( *this = aa = a );
01712 }
01713
01714
01715
01716
01717 inline
01718 ::std::istream&
01719 operator >> ( ::std::istream& is, sc_signed_subref& a )
01720 {
01721 a.scan( is );
01722 return is;
01723 }
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733 template<class T>
01734 sc_signed::sc_signed( const sc_generic_base<T>& v )
01735 {
01736 int nb = v->length();
01737 sgn = default_sign();
01738 if( nb > 0 ) {
01739 nbits = num_bits( nb );
01740 } else {
01741 char msg[BUFSIZ];
01742 sprintf( msg,
01743 "sc_unsigned( sc_generic_base<T> ) : nb = %d is not valid", nb);
01744 SC_REPORT_ERROR( sc_core::SC_ID_INIT_FAILED_, msg );
01745 }
01746 ndigits = DIV_CEIL(nbits);
01747 # ifdef SC_MAX_NBITS
01748 test_bound(nb);
01749 # else
01750 digit = new unsigned long[ndigits];
01751 # endif
01752 makezero();
01753 v->to_sc_signed(*this);
01754 }
01755
01756
01757
01758 inline
01759 ::std::ostream&
01760 operator << ( ::std::ostream& os, const sc_signed& a )
01761 {
01762 a.print( os );
01763 return os;
01764 }
01765
01766 inline
01767 ::std::istream&
01768 operator >> ( ::std::istream& is, sc_signed& a )
01769 {
01770 a.scan( is );
01771 return is;
01772 }
01773
01774
01775 }
01776
01777
01778 #endif