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