00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef SC_FXDEFS_H
00046 #define SC_FXDEFS_H
00047
00048
00049 #include "sysc/utils/sc_machine.h"
00050 #include "sysc/datatypes/fx/sc_fx_ids.h"
00051 #include "sysc/datatypes/int/sc_nbutils.h"
00052 #include "sysc/utils/sc_string.h"
00053
00054
00055 namespace sc_dt
00056 {
00057
00058
00059
00060
00061
00062
00063
00064 enum sc_enc
00065 {
00066 SC_TC_,
00067 SC_US_
00068 };
00069
00070
00071 const std::string to_string( sc_enc );
00072
00073
00074 inline
00075 ::std::ostream&
00076 operator << ( ::std::ostream& os, sc_enc enc )
00077 {
00078 return os << to_string( enc );
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088 enum sc_q_mode
00089 {
00090 SC_RND,
00091 SC_RND_ZERO,
00092 SC_RND_MIN_INF,
00093 SC_RND_INF,
00094 SC_RND_CONV,
00095 SC_TRN,
00096 SC_TRN_ZERO
00097 };
00098
00099
00100 const std::string to_string( sc_q_mode );
00101
00102
00103 inline
00104 ::std::ostream&
00105 operator << ( ::std::ostream& os, sc_q_mode q_mode )
00106 {
00107 return os << to_string( q_mode );
00108 }
00109
00110
00111
00112
00113
00114
00115
00116
00117 enum sc_o_mode
00118 {
00119 SC_SAT,
00120 SC_SAT_ZERO,
00121 SC_SAT_SYM,
00122 SC_WRAP,
00123 SC_WRAP_SM
00124 };
00125
00126
00127
00128
00129 const std::string to_string( sc_o_mode );
00130
00131
00132 inline
00133 ::std::ostream&
00134 operator << ( ::std::ostream& os, sc_o_mode o_mode )
00135 {
00136 return os << to_string( o_mode );
00137 }
00138
00139
00140
00141
00142
00143
00144
00145
00146 enum sc_switch
00147 {
00148 SC_OFF,
00149 SC_ON
00150 };
00151
00152
00153 const std::string to_string( sc_switch );
00154
00155
00156 inline
00157 ::std::ostream&
00158 operator << ( ::std::ostream& os, sc_switch sw )
00159 {
00160 return os << to_string( sw );
00161 }
00162
00163
00164
00165
00166
00167
00168
00169
00170 enum sc_fmt
00171 {
00172 SC_F,
00173 SC_E
00174 };
00175
00176
00177 const std::string to_string( sc_fmt );
00178
00179
00180 inline
00181 ::std::ostream&
00182 operator << ( ::std::ostream& os, sc_fmt fmt )
00183 {
00184 return os << to_string( fmt );
00185 }
00186
00187
00188
00189
00190
00191
00192 const int SC_BUILTIN_WL_ = 32;
00193 const int SC_BUILTIN_IWL_ = 32;
00194 const sc_q_mode SC_BUILTIN_Q_MODE_ = SC_TRN;
00195 const sc_o_mode SC_BUILTIN_O_MODE_ = SC_WRAP;
00196 const int SC_BUILTIN_N_BITS_ = 0;
00197
00198
00199 const int SC_DEFAULT_WL_ = SC_BUILTIN_WL_;
00200 const int SC_DEFAULT_IWL_ = SC_BUILTIN_IWL_;
00201 const sc_q_mode SC_DEFAULT_Q_MODE_ = SC_BUILTIN_Q_MODE_;
00202 const sc_o_mode SC_DEFAULT_O_MODE_ = SC_BUILTIN_O_MODE_;
00203 const int SC_DEFAULT_N_BITS_ = SC_BUILTIN_N_BITS_;
00204
00205
00206
00207
00208
00209
00210 const sc_switch SC_BUILTIN_CAST_SWITCH_ = SC_ON;
00211
00212
00213 const sc_switch SC_DEFAULT_CAST_SWITCH_ = SC_BUILTIN_CAST_SWITCH_;
00214
00215
00216
00217
00218
00219
00220 const int SC_BUILTIN_DIV_WL_ = 64;
00221 const int SC_BUILTIN_CTE_WL_ = 64;
00222 const int SC_BUILTIN_MAX_WL_ = 1024;
00223
00224
00225 #if defined( SC_FXDIV_WL ) && ( SC_FXDIV_WL > 0 )
00226 const int SC_DEFAULT_DIV_WL_ = SC_FXDIV_WL;
00227 #else
00228 const int SC_DEFAULT_DIV_WL_ = SC_BUILTIN_DIV_WL_;
00229 #endif
00230
00231 #if defined( SC_FXCTE_WL ) && ( SC_FXCTE_WL > 0 )
00232 const int SC_DEFAULT_CTE_WL_ = SC_FXCTE_WL;
00233 #else
00234 const int SC_DEFAULT_CTE_WL_ = SC_BUILTIN_CTE_WL_;
00235 #endif
00236
00237 #if defined( SC_FXMAX_WL ) && ( SC_FXMAX_WL > 0 || SC_FXMAX_WL == -1 )
00238 const int SC_DEFAULT_MAX_WL_ = SC_FXMAX_WL;
00239 #else
00240 const int SC_DEFAULT_MAX_WL_ = SC_BUILTIN_MAX_WL_;
00241 #endif
00242
00243
00244
00245
00246
00247
00248 #ifdef DEBUG_SYSTEMC
00249 #define SC_ASSERT_(cnd,msg) \
00250 { \
00251 if( ! (cnd) ) \
00252 SC_REPORT_ERROR( sc_core::SC_ID_INTERNAL_ERROR_, msg ); \
00253 }
00254 #else
00255 #define SC_ASSERT_(cnd,msg)
00256 #endif
00257
00258 #define SC_ERROR_IF_(cnd,id) \
00259 { \
00260 if( cnd ) \
00261 SC_REPORT_ERROR( id, 0 ); \
00262 }
00263
00264
00265 #define SC_CHECK_WL_(wl) \
00266 SC_ERROR_IF_( (wl) <= 0, sc_core::SC_ID_INVALID_WL_ )
00267
00268 #define SC_CHECK_N_BITS_(n_bits) \
00269 SC_ERROR_IF_( (n_bits) < 0, sc_core::SC_ID_INVALID_N_BITS_ )
00270
00271 #define SC_CHECK_DIV_WL_(div_wl) \
00272 SC_ERROR_IF_( (div_wl) <= 0, sc_core::SC_ID_INVALID_DIV_WL_ )
00273
00274 #define SC_CHECK_CTE_WL_(cte_wl) \
00275 SC_ERROR_IF_( (cte_wl) <= 0, sc_core::SC_ID_INVALID_CTE_WL_ )
00276
00277 #define SC_CHECK_MAX_WL_(max_wl) \
00278 SC_ERROR_IF_( (max_wl) <= 0 && (max_wl) != -1, \
00279 sc_core::SC_ID_INVALID_MAX_WL_ )
00280
00281
00282
00283
00284
00285
00286 #define SC_OBSERVER_(object,observer_type,event) \
00287 { \
00288 if( (object).observer() != 0 ) \
00289 { \
00290 observer_type observer = (object).lock_observer(); \
00291 observer->event( (object) ); \
00292 (object).unlock_observer( observer ); \
00293 } \
00294 }
00295
00296 #define SC_OBSERVER_DEFAULT_(observer_type) \
00297 { \
00298 if( m_observer == 0 && observer_type ## ::default_observer != 0 ) \
00299 m_observer = (* ## observer_type ## ::default_observer)(); \
00300 }
00301
00302 }
00303
00304
00305 #endif
00306
00307