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_fxcast_switch.h - 00021 00022 Original Author: Martin Janssen, 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_fxcast_switch.h,v $ 00037 // Revision 1.1.1.1 2006/12/15 20:31:36 acg 00038 // SystemC 2.2 00039 // 00040 // Revision 1.3 2006/01/13 18:53:57 acg 00041 // Andy Goodrich: added $Log command so that CVS comments are reproduced in 00042 // the source. 00043 // 00044 00045 #ifndef SC_FXCAST_SWITCH_H 00046 #define SC_FXCAST_SWITCH_H 00047 00048 00049 #include "sysc/datatypes/fx/sc_context.h" 00050 00051 00052 namespace sc_dt 00053 { 00054 00055 // classes defined in this module 00056 class sc_fxcast_switch; 00057 00058 00059 // ---------------------------------------------------------------------------- 00060 // CLASS : sc_fxcast_switch 00061 // 00062 // Fixed-point cast switch class. 00063 // ---------------------------------------------------------------------------- 00064 00065 class sc_fxcast_switch 00066 { 00067 00068 public: 00069 00070 sc_fxcast_switch(); 00071 sc_fxcast_switch( sc_switch ); 00072 sc_fxcast_switch( const sc_fxcast_switch& ); 00073 explicit sc_fxcast_switch( sc_without_context ); 00074 00075 sc_fxcast_switch& operator = ( const sc_fxcast_switch& ); 00076 00077 friend bool operator == ( const sc_fxcast_switch&, 00078 const sc_fxcast_switch& ); 00079 friend bool operator != ( const sc_fxcast_switch&, 00080 const sc_fxcast_switch& ); 00081 00082 const std::string to_string() const; 00083 00084 void print( ::std::ostream& = ::std::cout ) const; 00085 void dump( ::std::ostream& = ::std::cout ) const; 00086 00087 private: 00088 00089 sc_switch m_sw; 00090 00091 }; 00092 00093 00094 // ---------------------------------------------------------------------------- 00095 // TYPEDEF : sc_fxcast_context 00096 // 00097 // Context type for the fixed-point cast switch parameter. 00098 // ---------------------------------------------------------------------------- 00099 00100 typedef sc_context<sc_fxcast_switch> sc_fxcast_context; 00101 00102 00103 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 00104 00105 inline 00106 sc_fxcast_switch::sc_fxcast_switch() 00107 { 00108 *this = sc_fxcast_context::default_value(); 00109 } 00110 00111 inline 00112 sc_fxcast_switch::sc_fxcast_switch( sc_switch sw_ ) 00113 : m_sw( sw_ ) 00114 {} 00115 00116 inline 00117 sc_fxcast_switch::sc_fxcast_switch( const sc_fxcast_switch& a ) 00118 : m_sw( a.m_sw ) 00119 {} 00120 00121 inline 00122 sc_fxcast_switch::sc_fxcast_switch( sc_without_context ) 00123 : m_sw( SC_DEFAULT_CAST_SWITCH_ ) 00124 {} 00125 00126 00127 inline 00128 sc_fxcast_switch& 00129 sc_fxcast_switch::operator = ( const sc_fxcast_switch& a ) 00130 { 00131 if( &a != this ) 00132 { 00133 m_sw = a.m_sw; 00134 } 00135 return *this; 00136 } 00137 00138 00139 inline 00140 bool 00141 operator == ( const sc_fxcast_switch& a, const sc_fxcast_switch& b ) 00142 { 00143 return ( a.m_sw == b.m_sw ); 00144 } 00145 00146 00147 inline 00148 bool 00149 operator != ( const sc_fxcast_switch& a, const sc_fxcast_switch& b ) 00150 { 00151 return ( a.m_sw != b.m_sw ); 00152 } 00153 00154 00155 inline 00156 ::std::ostream& 00157 operator << ( ::std::ostream& os, const sc_fxcast_switch& a ) 00158 { 00159 a.print( os ); 00160 return os; 00161 } 00162 00163 } // namespace sc_dt 00164 00165 00166 #endif 00167 00168 // Taf!