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