sc_bit.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2006 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.4 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_bit.h -- Bit class.
00021 
00022   Original Author: Stan Y. Liao, Synopsys, Inc.
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033 
00034  *****************************************************************************/
00035 
00036 // $Log: sc_bit.h,v $
00037 // Revision 1.1.1.1  2006/12/15 20:31:36  acg
00038 // SystemC 2.2
00039 //
00040 // Revision 1.5  2006/04/12 20:17:52  acg
00041 //  Andy Goodrich: enabled deprecation message for sc_bit.
00042 //
00043 // Revision 1.4  2006/01/24 20:50:55  acg
00044 // Andy Goodrich: added warnings indicating that sc_bit is deprecated and that
00045 // the C bool data type should be used in its place.
00046 //
00047 // Revision 1.3  2006/01/13 18:53:53  acg
00048 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
00049 // the source.
00050 //
00051 
00052 #ifndef SC_BIT_H
00053 #define SC_BIT_H
00054 
00055 
00056 #include "sysc/datatypes/int/sc_nbdefs.h"
00057 #include "sysc/utils/sc_iostream.h"
00058 
00059 
00060 namespace sc_dt
00061 {
00062 
00063 // classes defined in this module
00064 class sc_bit;
00065 
00066 // forward class declarations
00067 class sc_logic;
00068 
00069 extern void sc_deprecated_sc_bit();
00070 
00071 // friend operator declarations
00072 
00073     // relational operators and functions
00074 
00075     // MANDATORY
00076 
00077     inline bool operator == ( const sc_bit& a, const sc_bit& b );
00078     inline bool operator == ( const sc_bit& a, int b );
00079     inline bool operator == ( const sc_bit& a, bool b );
00080     inline bool operator == ( const sc_bit& a, char b );
00081     inline bool operator == ( int a, const sc_bit& b );
00082     inline bool operator == ( bool a, const sc_bit& b );
00083     inline bool operator == ( char a, const sc_bit& b );
00084 
00085     // OPTIONAL
00086 
00087     inline bool equal( const sc_bit& a, const sc_bit& b );
00088     inline bool equal( const sc_bit& a, int b );
00089     inline bool equal( const sc_bit& a, bool b );
00090     inline bool equal( const sc_bit& a, char b );
00091     inline bool equal( int a, const sc_bit& b );
00092     inline bool equal( bool a, const sc_bit& b );
00093     inline bool equal( char a, const sc_bit& b );
00094 
00095     // MANDATORY
00096 
00097     inline bool operator != ( const sc_bit& a, const sc_bit& b );
00098     inline bool operator != ( const sc_bit& a, int b );
00099     inline bool operator != ( const sc_bit& a, bool b );
00100     inline bool operator != ( const sc_bit& a, char b );
00101     inline bool operator != ( int a, const sc_bit& b );
00102     inline bool operator != ( bool a, const sc_bit& b );
00103     inline bool operator != ( char a, const sc_bit& b );
00104 
00105     // OPTIONAL
00106 
00107     inline bool not_equal( const sc_bit& a, const sc_bit& b );
00108     inline bool not_equal( const sc_bit& a, int b );
00109     inline bool not_equal( const sc_bit& a, bool b );
00110     inline bool not_equal( const sc_bit& a, char b );
00111     inline bool not_equal( int a, const sc_bit& b );
00112     inline bool not_equal( bool a, const sc_bit& b );
00113     inline bool not_equal( char a, const sc_bit& b );
00114 
00115 
00116     // bitwise operators and functions
00117 
00118     // bitwise complement
00119 
00120     // MANDATORY
00121 
00122     inline const sc_bit operator ~ ( const sc_bit& a );
00123 
00124     // OPTIONAL
00125 
00126     inline const sc_bit b_not( const sc_bit& a );
00127 
00128     // RECOMMENDED
00129 
00130     inline void b_not( sc_bit& r, const sc_bit& a );
00131 
00132 
00133     // bitwise or
00134 
00135     // MANDATORY
00136 
00137     inline const sc_bit operator | ( const sc_bit& a, const sc_bit& b );
00138     inline const sc_bit operator | ( const sc_bit& a, int b );
00139     inline const sc_bit operator | ( const sc_bit& a, bool b );
00140     inline const sc_bit operator | ( const sc_bit& a, char b );
00141     inline const sc_bit operator | ( int a, const sc_bit& b );
00142     inline const sc_bit operator | ( bool a, const sc_bit& b );
00143     inline const sc_bit operator | ( char a, const sc_bit& b );
00144 
00145     // OPTIONAL
00146 
00147     inline const sc_bit b_or( const sc_bit& a, const sc_bit& b );
00148     inline const sc_bit b_or( const sc_bit& a, int b );
00149     inline const sc_bit b_or( const sc_bit& a, bool b );
00150     inline const sc_bit b_or( const sc_bit& a, char b );
00151     inline const sc_bit b_or( int a, const sc_bit& b );
00152     inline const sc_bit b_or( bool a, const sc_bit& b );
00153     inline const sc_bit b_or( char a, const sc_bit& b );
00154 
00155     // RECOMMENDED
00156 
00157     inline void b_or( sc_bit& r, const sc_bit& a, const sc_bit& b );
00158     inline void b_or( sc_bit& r, const sc_bit& a, int b );
00159     inline void b_or( sc_bit& r, const sc_bit& a, bool b );
00160     inline void b_or( sc_bit& r, const sc_bit& a, char b );
00161     inline void b_or( sc_bit& r, int a, const sc_bit& b );
00162     inline void b_or( sc_bit& r, bool a, const sc_bit& b );
00163     inline void b_or( sc_bit& r, char a, const sc_bit& b );
00164 
00165 
00166     // bitwise and
00167 
00168     // MANDATORY
00169 
00170     inline const sc_bit operator & ( const sc_bit& a, const sc_bit& b );
00171     inline const sc_bit operator & ( const sc_bit& a, int b );
00172     inline const sc_bit operator & ( const sc_bit& a, bool b );
00173     inline const sc_bit operator & ( const sc_bit& a, char b );
00174     inline const sc_bit operator & ( int a, const sc_bit& b );
00175     inline const sc_bit operator & ( bool a, const sc_bit& b );
00176     inline const sc_bit operator & ( char a, const sc_bit& b );
00177     // OPTIONAL
00178 
00179     inline const sc_bit b_and( const sc_bit& a, const sc_bit& b );
00180     inline const sc_bit b_and( const sc_bit& a, int b );
00181     inline const sc_bit b_and( const sc_bit& a, bool b );
00182     inline const sc_bit b_and( const sc_bit& a, char b );
00183     inline const sc_bit b_and( int a, const sc_bit& b );
00184     inline const sc_bit b_and( bool a, const sc_bit& b );
00185     inline const sc_bit b_and( char a, const sc_bit& b );
00186 
00187     // RECOMMENDED
00188 
00189     inline void b_and( sc_bit& r, const sc_bit& a, const sc_bit& b );
00190     inline void b_and( sc_bit& r, const sc_bit& a, int b );
00191     inline void b_and( sc_bit& r, const sc_bit& a, bool b );
00192     inline void b_and( sc_bit& r, const sc_bit& a, char b );
00193     inline void b_and( sc_bit& r, int a, const sc_bit& b );
00194     inline void b_and( sc_bit& r, bool a, const sc_bit& b );
00195     inline void b_and( sc_bit& r, char a, const sc_bit& b );
00196 
00197 
00198     // bitwise exor
00199 
00200     // MANDATORY
00201 
00202     inline const sc_bit operator ^ ( const sc_bit& a, const sc_bit& b );
00203     inline const sc_bit operator ^ ( const sc_bit& a, int b );
00204     inline const sc_bit operator ^ ( const sc_bit& a, bool b );
00205     inline const sc_bit operator ^ ( const sc_bit& a, char b );
00206     inline const sc_bit operator ^ ( int a, const sc_bit& b );
00207     inline const sc_bit operator ^ ( bool a, const sc_bit& b );
00208     inline const sc_bit operator ^ ( char a, const sc_bit& b );
00209 
00210     // OPTIONAL
00211 
00212     inline const sc_bit b_xor( const sc_bit& a, const sc_bit& b );
00213     inline const sc_bit b_xor( const sc_bit& a, int b );
00214     inline const sc_bit b_xor( const sc_bit& a, bool b );
00215     inline const sc_bit b_xor( const sc_bit& a, char b );
00216     inline const sc_bit b_xor( int a, const sc_bit& b );
00217     inline const sc_bit b_xor( bool a, const sc_bit& b );
00218     inline const sc_bit b_xor( char a, const sc_bit& b );
00219 
00220     // RECOMMENDED
00221 
00222     inline void b_xor( sc_bit& r, const sc_bit& a, const sc_bit& b );
00223     inline void b_xor( sc_bit& r, const sc_bit& a, int b );
00224     inline void b_xor( sc_bit& r, const sc_bit& a, bool b );
00225     inline void b_xor( sc_bit& r, const sc_bit& a, char b );
00226     inline void b_xor( sc_bit& r, int a, const sc_bit& b );
00227     inline void b_xor( sc_bit& r, bool a, const sc_bit& b );
00228     inline void b_xor( sc_bit& r, char a, const sc_bit& b );
00229 
00230 
00231 // ----------------------------------------------------------------------------
00232 //  CLASS : sc_bit
00233 //
00234 //  Bit class.
00235 //  Note: VSIA compatibility indicated.
00236 // ----------------------------------------------------------------------------
00237 
00238 class sc_bit
00239 {
00240     // support methods
00241 
00242     static void invalid_value( char );
00243     static void invalid_value( int );
00244 
00245     static bool to_value( char c )
00246     {
00247         if( c != '0' && c != '1' ) {
00248         invalid_value( c );
00249         }
00250         return ( c == '0' ? false : true );
00251     }
00252 
00253     static bool to_value( int i )
00254     {
00255         if( i != 0 && i != 1 ) {
00256         invalid_value( i );
00257         }
00258         return ( i == 0 ? false : true );
00259     }
00260 
00261 public:
00262 
00263     // constructors
00264     // MANDATORY
00265 
00266     sc_bit()
00267     : m_val( false )
00268     {
00269         sc_deprecated_sc_bit();
00270     }
00271 
00272     explicit sc_bit( uint64 a )
00273     : m_val( a )
00274     {
00275         sc_deprecated_sc_bit();
00276     }
00277 
00278     explicit sc_bit( bool a )
00279     : m_val( a )
00280     {
00281         sc_deprecated_sc_bit();
00282     }
00283 
00284     explicit sc_bit( int a )
00285     : m_val( to_value( a ) )
00286     {
00287         sc_deprecated_sc_bit();
00288     }
00289 
00290     explicit sc_bit( char a )
00291     : m_val( to_value( a ) )
00292     {
00293         sc_deprecated_sc_bit();
00294     }
00295 
00296     explicit sc_bit( const sc_logic& a );  // non-VSIA
00297 
00298 
00299     // copy constructor
00300     // MANDATORY
00301 
00302     sc_bit( const sc_bit& a )
00303     : m_val( a.m_val )
00304     {}
00305 
00306 
00307     // destructor
00308     // MANDATORY
00309 
00310     ~sc_bit()
00311     {}
00312 
00313 
00314     // assignment operators
00315     // MANDATORY
00316 
00317     sc_bit& operator = ( const sc_bit& b )
00318     { m_val = b.m_val; return *this; }
00319 
00320     sc_bit& operator = ( int64 b )
00321     { return ( *this = sc_bit( (int)b ) ); }
00322 
00323     sc_bit& operator = ( uint64 b )
00324     { return ( *this = sc_bit( (int)b ) ); }
00325 
00326     sc_bit& operator = ( long b )
00327     { return ( *this = sc_bit( (int)b ) ); }
00328 
00329     sc_bit& operator = ( unsigned long b )
00330     { return ( *this = sc_bit( (int)b ) ); }
00331 
00332     sc_bit& operator = ( int b )
00333     { return ( *this = sc_bit( b ) ); }
00334 
00335     sc_bit& operator = ( bool b )
00336     { return ( *this = sc_bit( b ) ); }
00337 
00338     sc_bit& operator = ( char b )
00339     { return ( *this = sc_bit( b ) ); }
00340 
00341     sc_bit& operator = ( const sc_logic& b );  // non-VSIA
00342 
00343 
00344     // bitwise assignment operators
00345 
00346     sc_bit& operator &= ( const sc_bit& b )
00347     { m_val = ( m_val && b.m_val ); return *this; }
00348 
00349     sc_bit& operator &= ( int b )
00350     { return ( *this &= sc_bit( b ) ); }
00351 
00352     sc_bit& operator &= ( bool b )
00353     { return ( *this &= sc_bit( b ) ); }
00354 
00355     sc_bit& operator &= ( char b )
00356     { return ( *this &= sc_bit( b ) ); }
00357 
00358 
00359     sc_bit& operator |= ( const sc_bit& b )
00360     { m_val = ( m_val || b.m_val ); return *this; }
00361 
00362     sc_bit& operator |= ( int b )
00363     { return ( *this |= sc_bit( b ) ); }
00364 
00365     sc_bit& operator |= ( bool b )
00366     { return ( *this |= sc_bit( b ) ); }
00367 
00368     sc_bit& operator |= ( char b )
00369     { return ( *this |= sc_bit( b ) ); }
00370 
00371 
00372     sc_bit& operator ^= ( const sc_bit& b )
00373     { m_val = ( m_val != b.m_val ); return *this; }
00374 
00375     sc_bit& operator ^= ( int b )
00376     { return ( *this ^= sc_bit( b ) ); }
00377 
00378     sc_bit& operator ^= ( bool b )
00379     { return ( *this ^= sc_bit( b ) ); }
00380 
00381     sc_bit& operator ^= ( char b )
00382     { return ( *this ^= sc_bit( b ) ); }
00383 
00384 
00385     // conversions
00386     // MANDATORY
00387 
00388     // implicit conversion to bool
00389 
00390     operator bool () const
00391     { return m_val; }
00392 
00393     bool operator ! () const  // non-VSIA
00394     { return ! m_val; }
00395 
00396 
00397     // explicit conversions
00398 
00399     bool to_bool() const  // non-VSIA
00400     { return m_val; }
00401 
00402     char to_char() const
00403     { return ( m_val ? '1' : '0' ); }
00404 
00405 
00406     // relational operators and functions
00407 
00408     // MANDATORY
00409 
00410     friend bool operator == ( const sc_bit& a, const sc_bit& b )
00411         { return ( a.m_val == b.m_val ); }
00412 
00413     friend bool operator == ( const sc_bit& a, int b )
00414         { return ( a == sc_bit( b ) ); }
00415 
00416     friend bool operator == ( const sc_bit& a, bool b )
00417         { return ( a == sc_bit( b ) ); }
00418 
00419     friend bool operator == ( const sc_bit& a, char b )
00420         { return ( a == sc_bit( b ) ); }
00421 
00422     friend bool operator == ( int a, const sc_bit& b )
00423     { return ( sc_bit( a ) == b ); }
00424 
00425     friend bool operator == ( bool a, const sc_bit& b )
00426     { return ( sc_bit( a ) == b ); }
00427 
00428     friend bool operator == ( char a, const sc_bit& b )
00429     { return ( sc_bit( a ) == b ); }
00430 
00431     // OPTIONAL
00432 
00433     friend bool equal( const sc_bit& a, const sc_bit& b )
00434         { return ( a == b ); }
00435 
00436     friend bool equal( const sc_bit& a, int b )
00437         { return ( a == b ); }
00438 
00439     friend bool equal( const sc_bit& a, bool b )
00440         { return ( a == b ); }
00441 
00442     friend bool equal( const sc_bit& a, char b )
00443         { return ( a == b ); }
00444 
00445     friend bool equal( int a, const sc_bit& b )
00446         { return ( a == b ); }
00447 
00448     friend bool equal( bool a, const sc_bit& b )
00449         { return ( a == b ); }
00450 
00451     friend bool equal( char a, const sc_bit& b )
00452         { return ( a == b ); }
00453 
00454     // MANDATORY
00455 
00456     friend bool operator != ( const sc_bit& a, const sc_bit& b )
00457         { return ( a.m_val != b.m_val ); }
00458 
00459     friend bool operator != ( const sc_bit& a, int b )
00460         { return ( a != sc_bit( b ) ); }
00461 
00462     friend bool operator != ( const sc_bit& a, bool b )
00463         { return ( a != sc_bit( b ) ); }
00464 
00465     friend bool operator != ( const sc_bit& a, char b )
00466         { return ( a != sc_bit( b ) ); }
00467 
00468     friend bool operator != ( int a, const sc_bit& b )
00469         { return ( sc_bit( a ) != b ); }
00470 
00471     friend bool operator != ( bool a, const sc_bit& b )
00472         { return ( sc_bit( a ) != b ); }
00473 
00474     friend bool operator != ( char a, const sc_bit& b )
00475         { return ( sc_bit( a ) != b ); }
00476 
00477     // OPTIONAL
00478 
00479     friend bool not_equal( const sc_bit& a, const sc_bit& b )
00480         { return ( a != b ); }
00481 
00482     friend bool not_equal( const sc_bit& a, int b )
00483         { return ( a != b ); }
00484 
00485     friend bool not_equal( const sc_bit& a, bool b )
00486         { return ( a != b ); }
00487 
00488     friend bool not_equal( const sc_bit& a, char b )
00489         { return ( a != b ); }
00490 
00491     friend bool not_equal( int a, const sc_bit& b )
00492         { return ( a != b ); }
00493 
00494     friend bool not_equal( bool a, const sc_bit& b )
00495         { return ( a != b ); }
00496 
00497     friend bool not_equal( char a, const sc_bit& b )
00498         { return ( a != b ); }
00499 
00500 
00501     // bitwise operators and functions
00502 
00503     // bitwise complement
00504 
00505     // MANDATORY
00506 
00507     friend const sc_bit operator ~ ( const sc_bit& a )
00508         { return sc_bit( ! a.m_val ); }
00509 
00510     // RECOMMENDED
00511 
00512     sc_bit& b_not()
00513         { m_val = ( ! m_val ); return *this; }
00514 
00515     // OPTIONAL
00516 
00517     friend const sc_bit b_not( const sc_bit& a )
00518         { return ( ~ a ); }
00519 
00520     // RECOMMENDED
00521 
00522     friend void b_not( sc_bit& r, const sc_bit& a )
00523         { r = ( ~ a ); }
00524 
00525 
00526     // bitwise or
00527 
00528     // MANDATORY
00529 
00530     friend const sc_bit operator | ( const sc_bit& a, const sc_bit& b )
00531         { return sc_bit( a.m_val || b.m_val ); }
00532 
00533     friend const sc_bit operator | ( const sc_bit& a, int b )
00534         { return ( a | sc_bit( b ) ); }
00535 
00536     friend const sc_bit operator | ( const sc_bit& a, bool b )
00537         { return ( a | sc_bit( b ) ); }
00538 
00539     friend const sc_bit operator | ( const sc_bit& a, char b )
00540         { return ( a | sc_bit( b ) ); }
00541 
00542     friend const sc_bit operator | ( int a, const sc_bit& b )
00543     { return ( sc_bit( a ) | b ); }
00544 
00545     friend const sc_bit operator | ( bool a, const sc_bit& b )
00546     { return ( sc_bit( a ) | b ); }
00547 
00548     friend const sc_bit operator | ( char a, const sc_bit& b )
00549     { return ( sc_bit( a ) | b ); }
00550 
00551     // OPTIONAL
00552 
00553     friend const sc_bit b_or( const sc_bit& a, const sc_bit& b )
00554         { return ( a | b ); }
00555 
00556     friend const sc_bit b_or( const sc_bit& a, int b )
00557         { return ( a | b ); }
00558 
00559     friend const sc_bit b_or( const sc_bit& a, bool b )
00560         { return ( a | b ); }
00561 
00562     friend const sc_bit b_or( const sc_bit& a, char b )
00563         { return ( a | b ); }
00564 
00565     friend const sc_bit b_or( int a, const sc_bit& b )
00566         { return ( a | b ); }
00567 
00568     friend const sc_bit b_or( bool a, const sc_bit& b )
00569         { return ( a | b ); }
00570 
00571     friend const sc_bit b_or( char a, const sc_bit& b )
00572         { return ( a | b ); }
00573 
00574     // RECOMMENDED
00575 
00576     friend void b_or( sc_bit& r, const sc_bit& a, const sc_bit& b )
00577         { r = ( a | b ); }
00578 
00579     friend void b_or( sc_bit& r, const sc_bit& a, int b )
00580         { r = ( a | b ); }
00581 
00582     friend void b_or( sc_bit& r, const sc_bit& a, bool b )
00583         { r = ( a | b ); }
00584 
00585     friend void b_or( sc_bit& r, const sc_bit& a, char b )
00586         { r = ( a | b ); }
00587 
00588     friend void b_or( sc_bit& r, int a, const sc_bit& b )
00589         { r = ( a | b ); }
00590 
00591     friend void b_or( sc_bit& r, bool a, const sc_bit& b )
00592         { r = ( a | b ); }
00593 
00594     friend void b_or( sc_bit& r, char a, const sc_bit& b )
00595         { r = ( a | b ); }
00596 
00597 
00598     // bitwise and
00599 
00600     // MANDATORY
00601 
00602     friend const sc_bit operator & ( const sc_bit& a, const sc_bit& b )
00603     { return sc_bit( a.m_val && b.m_val ); }
00604 
00605     friend const sc_bit operator & ( const sc_bit& a, int b )
00606     { return ( a & sc_bit( b ) ); }
00607 
00608     friend const sc_bit operator & ( const sc_bit& a, bool b )
00609     { return ( a & sc_bit( b ) ); }
00610 
00611     friend const sc_bit operator & ( const sc_bit& a, char b )
00612     { return ( a & sc_bit( b ) ); }
00613 
00614     friend const sc_bit operator & ( int a, const sc_bit& b )
00615     { return ( sc_bit( a ) & b ); }
00616 
00617     friend const sc_bit operator & ( bool a, const sc_bit& b )
00618     { return ( sc_bit( a ) & b ); }
00619 
00620     friend const sc_bit operator & ( char a, const sc_bit& b )
00621     { return ( sc_bit( a ) & b ); }
00622 
00623     // OPTIONAL
00624 
00625     friend const sc_bit b_and( const sc_bit& a, const sc_bit& b )
00626     { return ( a & b ); }
00627 
00628     friend const sc_bit b_and( const sc_bit& a, int b )
00629     { return ( a & b ); }
00630 
00631     friend const sc_bit b_and( const sc_bit& a, bool b )
00632     { return ( a & b ); }
00633 
00634     friend const sc_bit b_and( const sc_bit& a, char b )
00635     { return ( a & b ); }
00636 
00637     friend const sc_bit b_and( int a, const sc_bit& b )
00638     { return ( a & b ); }
00639 
00640     friend const sc_bit b_and( bool a, const sc_bit& b )
00641     { return ( a & b ); }
00642 
00643     friend const sc_bit b_and( char a, const sc_bit& b )
00644     { return ( a & b ); }
00645 
00646     // RECOMMENDED
00647 
00648     friend void b_and( sc_bit& r, const sc_bit& a, const sc_bit& b )
00649     { r = ( a & b ); }
00650 
00651     friend void b_and( sc_bit& r, const sc_bit& a, int b )
00652     { r = ( a & b ); }
00653 
00654     friend void b_and( sc_bit& r, const sc_bit& a, bool b )
00655     { r = ( a & b ); }
00656 
00657     friend void b_and( sc_bit& r, const sc_bit& a, char b )
00658     { r = ( a & b ); }
00659 
00660     friend void b_and( sc_bit& r, int a, const sc_bit& b )
00661     { r = ( a & b ); }
00662 
00663     friend void b_and( sc_bit& r, bool a, const sc_bit& b )
00664     { r = ( a & b ); }
00665 
00666     friend void b_and( sc_bit& r, char a, const sc_bit& b )
00667     { r = ( a & b ); }
00668 
00669 
00670     // bitwise exor
00671 
00672     // MANDATORY
00673 
00674     friend const sc_bit operator ^ ( const sc_bit& a, const sc_bit& b )
00675     { return sc_bit( a.m_val != b.m_val ); }
00676 
00677     friend const sc_bit operator ^ ( const sc_bit& a, int b )
00678     { return ( a ^ sc_bit( b ) ); }
00679 
00680     friend const sc_bit operator ^ ( const sc_bit& a, bool b )
00681     { return ( a ^ sc_bit( b ) ); }
00682 
00683     friend const sc_bit operator ^ ( const sc_bit& a, char b )
00684     { return ( a ^ sc_bit( b ) ); }
00685 
00686     friend const sc_bit operator ^ ( int a, const sc_bit& b )
00687     { return ( sc_bit( a ) ^ b ); }
00688 
00689     friend const sc_bit operator ^ ( bool a, const sc_bit& b )
00690     { return ( sc_bit( a ) ^ b ); }
00691 
00692     friend const sc_bit operator ^ ( char a, const sc_bit& b )
00693     { return ( sc_bit( a ) ^ b ); }
00694 
00695     // OPTIONAL
00696 
00697     friend const sc_bit b_xor( const sc_bit& a, const sc_bit& b )
00698     { return ( a ^ b ); }
00699 
00700     friend const sc_bit b_xor( const sc_bit& a, int b )
00701     { return ( a ^ b ); }
00702 
00703     friend const sc_bit b_xor( const sc_bit& a, bool b )
00704     { return ( a ^ b ); }
00705 
00706     friend const sc_bit b_xor( const sc_bit& a, char b )
00707     { return ( a ^ b ); }
00708 
00709     friend const sc_bit b_xor( int a, const sc_bit& b )
00710     { return ( a ^ b ); }
00711 
00712     friend const sc_bit b_xor( bool a, const sc_bit& b )
00713     { return ( a ^ b ); }
00714 
00715     friend const sc_bit b_xor( char a, const sc_bit& b )
00716     { return ( a ^ b ); }
00717 
00718     // RECOMMENDED
00719 
00720     friend void b_xor( sc_bit& r, const sc_bit& a, const sc_bit& b )
00721     { r = ( a ^ b ); }
00722 
00723     friend void b_xor( sc_bit& r, const sc_bit& a, int b )
00724     { r = ( a ^ b ); }
00725 
00726     friend void b_xor( sc_bit& r, const sc_bit& a, bool b )
00727     { r = ( a ^ b ); }
00728 
00729     friend void b_xor( sc_bit& r, const sc_bit& a, char b )
00730     { r = ( a ^ b ); }
00731 
00732     friend void b_xor( sc_bit& r, int a, const sc_bit& b )
00733     { r = ( a ^ b ); }
00734 
00735     friend void b_xor( sc_bit& r, bool a, const sc_bit& b )
00736     { r = ( a ^ b ); }
00737 
00738     friend void b_xor( sc_bit& r, char a, const sc_bit& b )
00739     { r = ( a ^ b ); }
00740 
00741 
00742     // other methods
00743 
00744     void print( ::std::ostream& os = ::std::cout ) const
00745     { os << to_bool(); }
00746 
00747     void scan( ::std::istream& = ::std::cin );
00748 
00749 private:
00750 
00751     bool m_val;
00752 };
00753 
00754 
00755 // ----------------------------------------------------------------------------
00756 
00757 inline
00758 ::std::ostream&
00759 operator << ( ::std::ostream& os, const sc_bit& a )
00760 {
00761     a.print( os );
00762     return os;
00763 }
00764 
00765 inline
00766 ::std::istream&
00767 operator >> ( ::std::istream& is, sc_bit& a )
00768 {
00769     a.scan( is );
00770     return is;
00771 }
00772 
00773 } // namespace sc_dt
00774 
00775 
00776 #endif
00777 
00778 // Taf!

Generated on Wed Jan 21 15:32:07 2009 for SystemC by  doxygen 1.5.5