sc_signed_bitref.inc

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-2005 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.3 (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_signed_bitref.h -- Proxy class that is declared in sc_signed.h.
00021 
00022   Original Author: Ali Dasdan, 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 
00037 // ----------------------------------------------------------------------------
00038 //  CLASS : sc_signed_bitref_r
00039 //
00040 //  Proxy class for sc_signed bit selection (r-value only).
00041 // ----------------------------------------------------------------------------
00042 
00043 // implicit conversion to uint64
00044 
00045 sc_signed_bitref_r::operator uint64 () const
00046 {
00047     return m_obj_p->test( m_index );
00048 }
00049 
00050 bool
00051 sc_signed_bitref_r::operator ! () const
00052 {
00053     return ( ! m_obj_p->test( m_index ) );
00054 }
00055 
00056 bool
00057 sc_signed_bitref_r::operator ~ () const
00058 {
00059     return ( ! m_obj_p->test( m_index ) );
00060 }
00061 
00062 
00063 // ----------------------------------------------------------------------------
00064 //  CLASS : sc_signed_bitref
00065 //
00066 //  Proxy class for sc_signed bit selection (r-value and l-value).
00067 // ----------------------------------------------------------------------------
00068 
00069 // assignment operators
00070 
00071 const sc_signed_bitref&
00072 sc_signed_bitref::operator = ( const sc_signed_bitref_r& b )
00073 {
00074     m_obj_p->set( m_index, (bool) b );
00075     return *this;
00076 }
00077 
00078 const sc_signed_bitref&
00079 sc_signed_bitref::operator = ( const sc_signed_bitref& b )
00080 {
00081     m_obj_p->set( m_index, (bool) b );
00082     return *this;
00083 }
00084 
00085 const sc_signed_bitref&
00086 sc_signed_bitref::operator = ( bool b )
00087 {
00088     m_obj_p->set( m_index, b );
00089     return *this;
00090 }
00091 
00092 
00093 const sc_signed_bitref&
00094 sc_signed_bitref::operator &= ( bool b )
00095 {
00096     if( ! b ) {
00097     m_obj_p->clear( m_index );
00098     }
00099     return *this;
00100 }
00101 
00102 const sc_signed_bitref&
00103 sc_signed_bitref::operator |= ( bool b )
00104 {
00105     if( b ) {
00106     m_obj_p->set( m_index );
00107     }
00108     return *this;
00109 }
00110 
00111 const sc_signed_bitref&
00112 sc_signed_bitref::operator ^= ( bool b )
00113 {
00114     if( b ) {
00115     m_obj_p->invert( m_index );
00116     }
00117     return *this;
00118 }
00119 
00120 // #### OPTIMIZE
00121 void sc_signed_bitref::concat_set(int64 src, int low_i)  
00122 {    
00123     bool value = 1 & ((low_i < 64) ? (src >> low_i) : (src >> 63));
00124     m_obj_p->set(low_i, value);
00125 }
00126 
00127 void sc_signed_bitref::concat_set(const sc_signed& src, int low_i)
00128 {
00129     if ( low_i < src.length() )
00130         m_obj_p->set(low_i, src.test(low_i));
00131     else
00132         m_obj_p->set(low_i, src<0);
00133 }       
00134 
00135 void sc_signed_bitref::concat_set(const sc_unsigned& src, int low_i)
00136 {
00137     if ( low_i < src.length() )
00138         m_obj_p->set(low_i, src.test(low_i));
00139     else
00140         m_obj_p->set(low_i, 0);
00141 }
00142 
00143 void sc_signed_bitref::concat_set(uint64 src, int low_i)
00144 {
00145     bool value = 1 & ((low_i < 64) ? (src >> low_i) : 0);
00146     m_obj_p->set(low_i, value);
00147 }
00148 
00149 
00150 // other methods
00151 
00152 void
00153 sc_signed_bitref::scan( ::std::istream& is )
00154 {
00155     bool b;
00156     is >> b;
00157     *this = b;
00158 }
00159 
00160 
00161 // End of file

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