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 #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
00050
00051
00052
00053
00054 enum sc_enc
00055 {
00056 SC_TC_,
00057 SC_US_
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
00074
00075
00076
00077
00078 enum sc_q_mode
00079 {
00080 SC_RND,
00081 SC_RND_ZERO,
00082 SC_RND_MIN_INF,
00083 SC_RND_INF,
00084 SC_RND_CONV,
00085 SC_TRN,
00086 SC_TRN_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
00103
00104
00105
00106
00107 enum sc_o_mode
00108 {
00109 SC_SAT,
00110 SC_SAT_ZERO,
00111 SC_SAT_SYM,
00112 SC_WRAP,
00113 SC_WRAP_SM
00114 };
00115
00116
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
00132
00133
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
00156
00157
00158
00159
00160 enum sc_fmt
00161 {
00162 SC_F,
00163 SC_E
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
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
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
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
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
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 }
00292
00293
00294 #endif
00295
00296