Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

sc_fxdefs.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-2004 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_fxdefs.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 #ifndef SC_FXDEFS_H
00037 #define SC_FXDEFS_H
00038 
00039 
00040 #include "systemc/datatypes/fx/sc_fx_ids.h"
00041 #include "systemc/datatypes/int/sc_nbutils.h"
00042 #include "systemc/utils/sc_string.h"
00043 
00044 
00045 namespace sc_dt
00046 {
00047 
00048 // ----------------------------------------------------------------------------
00049 //  ENUM : sc_enc
00050 //
00051 //  Enumeration of sign encodings.
00052 // ----------------------------------------------------------------------------
00053 
00054 enum sc_enc
00055 {
00056     SC_TC_, // two's complement
00057     SC_US_  // unsigned
00058 };
00059 
00060 
00061 const sc_string to_string( sc_enc );
00062 
00063 
00064 inline
00065 ostream&
00066 operator << ( ostream& os, sc_enc enc )
00067 {
00068     return os << to_string( enc );
00069 }
00070 
00071 
00072 // ----------------------------------------------------------------------------
00073 //  ENUM : sc_q_mode
00074 //
00075 //  Enumeration of quantization modes.
00076 // ----------------------------------------------------------------------------
00077 
00078 enum sc_q_mode
00079 {
00080     SC_RND,   // rounding to plus infinity
00081     SC_RND_ZERO,  // rounding to zero
00082     SC_RND_MIN_INF, // rounding to minus infinity
00083     SC_RND_INF,   // rounding to infinity
00084     SC_RND_CONV,  // convergent rounding
00085     SC_TRN,   // truncation
00086     SC_TRN_ZERO   // truncation to zero
00087 };
00088 
00089 
00090 const sc_string to_string( sc_q_mode );
00091 
00092 
00093 inline
00094 ostream&
00095 operator << ( ostream& os, sc_q_mode q_mode )
00096 {
00097     return os << to_string( q_mode );
00098 }
00099 
00100 
00101 // ----------------------------------------------------------------------------
00102 //  ENUM : sc_o_mode
00103 //
00104 //  Enumeration of overflow modes.
00105 // ----------------------------------------------------------------------------
00106 
00107 enum sc_o_mode
00108 {
00109     SC_SAT,   // saturation
00110     SC_SAT_ZERO,  // saturation to zero
00111     SC_SAT_SYM,   // symmetrical saturation
00112     SC_WRAP,    // wrap-around (*)
00113     SC_WRAP_SM    // sign magnitude wrap-around (*)
00114 };
00115 
00116 // (*) uses the number of saturated bits argument, see the documentation.
00117 
00118 
00119 const sc_string to_string( sc_o_mode );
00120 
00121 
00122 inline
00123 ostream&
00124 operator << ( ostream& os, sc_o_mode o_mode )
00125 {
00126     return os << to_string( o_mode );
00127 }
00128 
00129 
00130 // ----------------------------------------------------------------------------
00131 //  ENUM : sc_switch
00132 //
00133 //  Enumeration of switch states.
00134 // ----------------------------------------------------------------------------
00135 
00136 enum sc_switch
00137 {
00138     SC_OFF,
00139     SC_ON
00140 };
00141 
00142 
00143 const sc_string to_string( sc_switch );
00144 
00145 
00146 inline
00147 ostream&
00148 operator << ( ostream& os, sc_switch sw )
00149 {
00150     return os << to_string( sw );
00151 }
00152 
00153 
00154 // ----------------------------------------------------------------------------
00155 //  ENUM : sc_fmt
00156 //
00157 //  Enumeration of formats for character string conversion.
00158 // ----------------------------------------------------------------------------
00159 
00160 enum sc_fmt
00161 {
00162     SC_F, // fixed
00163     SC_E  // scientific
00164 };
00165 
00166 
00167 const sc_string to_string( sc_fmt );
00168 
00169 
00170 inline
00171 ostream&
00172 operator << ( ostream& os, sc_fmt fmt )
00173 {
00174     return os << to_string( fmt );
00175 }
00176 
00177 
00178 // ----------------------------------------------------------------------------
00179 //  Built-in & default fixed-point type parameter values.
00180 // ----------------------------------------------------------------------------
00181 
00182 const int       SC_BUILTIN_WL_     = 32;
00183 const int       SC_BUILTIN_IWL_    = 32;
00184 const sc_q_mode SC_BUILTIN_Q_MODE_ = SC_TRN;
00185 const sc_o_mode SC_BUILTIN_O_MODE_ = SC_WRAP;
00186 const int       SC_BUILTIN_N_BITS_ = 0;
00187 
00188 
00189 const int       SC_DEFAULT_WL_     = SC_BUILTIN_WL_;
00190 const int       SC_DEFAULT_IWL_    = SC_BUILTIN_IWL_;
00191 const sc_q_mode SC_DEFAULT_Q_MODE_ = SC_BUILTIN_Q_MODE_;
00192 const sc_o_mode SC_DEFAULT_O_MODE_ = SC_BUILTIN_O_MODE_;
00193 const int       SC_DEFAULT_N_BITS_ = SC_BUILTIN_N_BITS_;
00194 
00195 
00196 // ----------------------------------------------------------------------------
00197 //  Built-in & default fixed-point cast switch parameter values.
00198 // ----------------------------------------------------------------------------
00199 
00200 const sc_switch SC_BUILTIN_CAST_SWITCH_ = SC_ON;
00201 
00202 
00203 const sc_switch SC_DEFAULT_CAST_SWITCH_ = SC_BUILTIN_CAST_SWITCH_;
00204 
00205 
00206 // ----------------------------------------------------------------------------
00207 //  Built-in & default fixed-point value type parameter values.
00208 // ----------------------------------------------------------------------------
00209 
00210 const int SC_BUILTIN_DIV_WL_ = 64;
00211 const int SC_BUILTIN_CTE_WL_ = 64;
00212 const int SC_BUILTIN_MAX_WL_ = 1024;
00213 
00214 
00215 #if defined( SC_FXDIV_WL ) && ( SC_FXDIV_WL > 0 )
00216 const int SC_DEFAULT_DIV_WL_ = SC_FXDIV_WL;
00217 #else
00218 const int SC_DEFAULT_DIV_WL_ = SC_BUILTIN_DIV_WL_;
00219 #endif
00220 
00221 #if defined( SC_FXCTE_WL ) && ( SC_FXCTE_WL > 0 )
00222 const int SC_DEFAULT_CTE_WL_ = SC_FXCTE_WL;
00223 #else
00224 const int SC_DEFAULT_CTE_WL_ = SC_BUILTIN_CTE_WL_;
00225 #endif
00226 
00227 #if defined( SC_FXMAX_WL ) && ( SC_FXMAX_WL > 0 || SC_FXMAX_WL == -1 )
00228 const int SC_DEFAULT_MAX_WL_ = SC_FXMAX_WL;
00229 #else
00230 const int SC_DEFAULT_MAX_WL_ = SC_BUILTIN_MAX_WL_;
00231 #endif
00232 
00233 
00234 // ----------------------------------------------------------------------------
00235 //  Dedicated error reporting and checking.
00236 // ----------------------------------------------------------------------------
00237 
00238 #ifdef DEBUG_SYSTEMC
00239 #define SC_ASSERT_(cnd,msg)                                                   \
00240 {                                                                             \
00241     if( ! (cnd) )                                                             \
00242         SC_REPORT_ERROR( SC_ID_INTERNAL_ERROR_, msg );                        \
00243 }
00244 #else
00245 #define SC_ASSERT_(cnd,msg)
00246 #endif
00247 
00248 #define SC_ERROR_IF_(cnd,id)                                                  \
00249 {                                                                             \
00250     if( cnd )                                                                 \
00251         SC_REPORT_ERROR( id, 0 );                                             \
00252 }
00253 
00254 
00255 #define SC_CHECK_WL_(wl)                                                      \
00256     SC_ERROR_IF_( (wl) <= 0, SC_ID_INVALID_WL_ )
00257 
00258 #define SC_CHECK_N_BITS_(n_bits)                                              \
00259     SC_ERROR_IF_( (n_bits) < 0, SC_ID_INVALID_N_BITS_ )
00260 
00261 #define SC_CHECK_DIV_WL_(div_wl)                                              \
00262     SC_ERROR_IF_( (div_wl) <= 0, SC_ID_INVALID_DIV_WL_ )
00263 
00264 #define SC_CHECK_CTE_WL_(cte_wl)                                              \
00265     SC_ERROR_IF_( (cte_wl) <= 0, SC_ID_INVALID_CTE_WL_ )
00266 
00267 #define SC_CHECK_MAX_WL_(max_wl)                                              \
00268     SC_ERROR_IF_( (max_wl) <= 0 && (max_wl) != -1, SC_ID_INVALID_MAX_WL_ )
00269 
00270 
00271 // ----------------------------------------------------------------------------
00272 //  Generic observer macros.
00273 // ----------------------------------------------------------------------------
00274 
00275 #define SC_OBSERVER_(object,observer_type,event)                              \
00276 {                                                                             \
00277     if( (object).observer() != 0 )                                            \
00278     {                                                                         \
00279   observer_type observer = (object).lock_observer();                    \
00280   observer->event( (object) );                                          \
00281   (object).unlock_observer( observer );                                 \
00282     }                                                                         \
00283 }
00284 
00285 #define SC_OBSERVER_DEFAULT_(observer_type)                                   \
00286 {                                                                             \
00287     if( m_observer == 0 && observer_type ## ::default_observer != 0 )         \
00288         m_observer = (* ## observer_type ## ::default_observer)();            \
00289 }
00290 
00291 } // namespace sc_dt
00292 
00293 
00294 #endif
00295 
00296 // Taf!

Generated on Fri Jan 14 08:29:01 2005 for SystemC2.1beta11(excludingMSLib)(IncludingSCV)\nProvidedby:www.openverificationfoundation.org by doxygen1.2.18