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
00046
00047 #ifndef SC_TRACE_H
00048 #define SC_TRACE_H
00049
00050 #include <cstdio>
00051
00052 #include "sysc/datatypes/int/sc_nbdefs.h"
00053 #include "sysc/kernel/sc_time.h"
00054
00055
00056 namespace sc_dt
00057 {
00058 class sc_bit;
00059 class sc_logic;
00060 class sc_bv_base;
00061 class sc_lv_base;
00062 class sc_signed;
00063 class sc_unsigned;
00064 class sc_int_base;
00065 class sc_uint_base;
00066 class sc_fxval;
00067 class sc_fxval_fast;
00068 class sc_fxnum;
00069 class sc_fxnum_fast;
00070 }
00071
00072 namespace sc_core {
00073
00074 class sc_logic_resolve;
00075 class sc_time;
00076
00077 template <class T> class sc_signal_in_if;
00078
00079
00080 void put_error_message(const char* msg, bool just_warning);
00081
00082
00083
00084
00085 class sc_trace_file
00086 {
00087 friend class sc_simcontext;
00088
00089 public:
00090
00091
00092 sc_trace_file();
00093
00094
00095
00096
00097
00098 #define DECL_TRACE_METHOD_A(tp) \
00099 virtual void trace( const tp& object, \
00100 const std::string& name ) = 0;
00101
00102 #define DECL_TRACE_METHOD_B(tp) \
00103 virtual void trace( const tp& object, \
00104 const std::string& name, \
00105 int width ) = 0;
00106
00107
00108 DECL_TRACE_METHOD_A( bool )
00109 DECL_TRACE_METHOD_A( sc_dt::sc_bit )
00110 DECL_TRACE_METHOD_A( sc_dt::sc_logic )
00111
00112 DECL_TRACE_METHOD_B( unsigned char )
00113 DECL_TRACE_METHOD_B( unsigned short )
00114 DECL_TRACE_METHOD_B( unsigned int )
00115 DECL_TRACE_METHOD_B( unsigned long )
00116 DECL_TRACE_METHOD_B( char )
00117 DECL_TRACE_METHOD_B( short )
00118 DECL_TRACE_METHOD_B( int )
00119 DECL_TRACE_METHOD_B( long )
00120 DECL_TRACE_METHOD_B( sc_dt::int64 )
00121 DECL_TRACE_METHOD_B( sc_dt::uint64 )
00122
00123 DECL_TRACE_METHOD_A( float )
00124 DECL_TRACE_METHOD_A( double )
00125 DECL_TRACE_METHOD_A( sc_dt::sc_int_base )
00126 DECL_TRACE_METHOD_A( sc_dt::sc_uint_base )
00127 DECL_TRACE_METHOD_A( sc_dt::sc_signed )
00128 DECL_TRACE_METHOD_A( sc_dt::sc_unsigned )
00129
00130 DECL_TRACE_METHOD_A( sc_dt::sc_fxval )
00131 DECL_TRACE_METHOD_A( sc_dt::sc_fxval_fast )
00132 DECL_TRACE_METHOD_A( sc_dt::sc_fxnum )
00133 DECL_TRACE_METHOD_A( sc_dt::sc_fxnum_fast )
00134
00135 DECL_TRACE_METHOD_A( sc_dt::sc_bv_base )
00136 DECL_TRACE_METHOD_A( sc_dt::sc_lv_base )
00137
00138
00139 #undef DECL_TRACE_METHOD_A
00140 #undef DECL_TRACE_METHOD_B
00141
00142
00143
00144
00145 virtual void trace( const unsigned int& object,
00146 const std::string& name,
00147 const char** enum_literals ) = 0;
00148
00149
00150 virtual void write_comment( const std::string& comment ) = 0;
00151
00152
00153
00154 virtual void space( int n );
00155
00156
00157 virtual void delta_cycles( bool flag );
00158
00159
00160 virtual void set_time_unit( int exponent10_seconds );
00161 virtual void set_time_unit( double v, sc_time_unit tu );
00162
00163 protected:
00164
00165
00166 virtual void cycle( bool delta_cycle ) = 0;
00167
00168
00169 virtual ~sc_trace_file()
00170 { };
00171
00172 protected:
00173 bool initialized;
00174 double timescale_unit;
00175 bool timescale_set_by_user;
00176 };
00177
00178
00179
00180
00181
00182
00183
00184
00185 #define DECL_TRACE_FUNC_REF_A(tp) \
00186 void \
00187 sc_trace( sc_trace_file* tf, \
00188 const tp& object, \
00189 const std::string& name );
00190
00191 #define DECL_TRACE_FUNC_PTR_A(tp) \
00192 void \
00193 sc_trace( sc_trace_file* tf, \
00194 const tp* object, \
00195 const std::string& name ); \
00196
00197 #define DECL_TRACE_FUNC_A(tp) \
00198 DECL_TRACE_FUNC_REF_A(tp) \
00199 DECL_TRACE_FUNC_PTR_A(tp)
00200
00201
00202 DECL_TRACE_FUNC_A( sc_dt::sc_bit )
00203 DECL_TRACE_FUNC_A( sc_dt::sc_logic )
00204
00205 DECL_TRACE_FUNC_A( sc_dt::sc_int_base )
00206 DECL_TRACE_FUNC_A( sc_dt::sc_uint_base )
00207 DECL_TRACE_FUNC_A( sc_dt::sc_signed )
00208 DECL_TRACE_FUNC_A( sc_dt::sc_unsigned )
00209
00210 DECL_TRACE_FUNC_REF_A( sc_dt::sc_bv_base )
00211 DECL_TRACE_FUNC_REF_A( sc_dt::sc_lv_base )
00212
00213
00214 #undef DECL_TRACE_FUNC_REF_A
00215 #undef DECL_TRACE_FUNC_PTR_A
00216 #undef DECL_TRACE_FUNC_A
00217
00218
00219
00220
00221 #define DEFN_TRACE_FUNC_REF_A(tp) \
00222 inline \
00223 void \
00224 sc_trace( sc_trace_file* tf, const tp& object, const std::string& name ) \
00225 { \
00226 if( tf ) { \
00227 tf->trace( object, name ); \
00228 } \
00229 }
00230
00231 #define DEFN_TRACE_FUNC_PTR_A(tp) \
00232 inline \
00233 void \
00234 sc_trace( sc_trace_file* tf, const tp* object, const std::string& name ) \
00235 { \
00236 if( tf ) { \
00237 tf->trace( *object, name ); \
00238 } \
00239 }
00240
00241 #define DEFN_TRACE_FUNC_A(tp) \
00242 DEFN_TRACE_FUNC_REF_A(tp) \
00243 DEFN_TRACE_FUNC_PTR_A(tp)
00244
00245
00246 #define DEFN_TRACE_FUNC_REF_B(tp) \
00247 inline \
00248 void \
00249 sc_trace( sc_trace_file* tf, const tp& object, const std::string& name, \
00250 int width = 8 * sizeof( tp ) ) \
00251 { \
00252 if( tf ) { \
00253 tf->trace( object, name, width ); \
00254 } \
00255 }
00256
00257 #define DEFN_TRACE_FUNC_PTR_B(tp) \
00258 inline \
00259 void \
00260 sc_trace( sc_trace_file* tf, const tp* object, const std::string& name, \
00261 int width = 8 * sizeof( tp ) ) \
00262 { \
00263 if( tf ) { \
00264 tf->trace( *object, name, width ); \
00265 } \
00266 }
00267
00268
00269 #define DEFN_TRACE_FUNC_B(tp) \
00270 DEFN_TRACE_FUNC_REF_B(tp) \
00271 DEFN_TRACE_FUNC_PTR_B(tp)
00272
00273
00274 DEFN_TRACE_FUNC_A( bool )
00275 DEFN_TRACE_FUNC_A( float )
00276 DEFN_TRACE_FUNC_A( double )
00277
00278 DEFN_TRACE_FUNC_B( unsigned char )
00279 DEFN_TRACE_FUNC_B( unsigned short )
00280 DEFN_TRACE_FUNC_B( unsigned int )
00281 DEFN_TRACE_FUNC_B( unsigned long )
00282 DEFN_TRACE_FUNC_B( char )
00283 DEFN_TRACE_FUNC_B( short )
00284 DEFN_TRACE_FUNC_B( int )
00285 DEFN_TRACE_FUNC_B( long )
00286 DEFN_TRACE_FUNC_B( sc_dt::int64 )
00287 DEFN_TRACE_FUNC_B( sc_dt::uint64 )
00288
00289
00290 #undef DEFN_TRACE_FUNC_REF_A
00291 #undef DEFN_TRACE_FUNC_PTR_A
00292 #undef DEFN_TRACE_FUNC_A
00293
00294 #undef DEFN_TRACE_FUNC_REF_B
00295 #undef DEFN_TRACE_FUNC_PTR_B
00296 #undef DEFN_TRACE_FUNC_B
00297
00298
00299 template <class T>
00300 inline
00301 void
00302 sc_trace( sc_trace_file* tf,
00303 const sc_signal_in_if<T>& object,
00304 const std::string& name )
00305 {
00306 sc_trace( tf, object.read(), name );
00307 }
00308
00309 template< class T >
00310 inline
00311 void
00312 sc_trace( sc_trace_file* tf,
00313 const sc_signal_in_if<T>& object,
00314 const char* name )
00315 {
00316 sc_trace( tf, object.read(), name );
00317 }
00318
00319
00320
00321
00322 void sc_trace( sc_trace_file* tf,
00323 const sc_signal_in_if<char>& object,
00324 const std::string& name,
00325 int width );
00326
00327 void sc_trace( sc_trace_file* tf,
00328 const sc_signal_in_if<short>& object,
00329 const std::string& name,
00330 int width );
00331
00332 void sc_trace( sc_trace_file* tf,
00333 const sc_signal_in_if<int>& object,
00334 const std::string& name,
00335 int width );
00336
00337 void sc_trace( sc_trace_file* tf,
00338 const sc_signal_in_if<long>& object,
00339 const std::string& name,
00340 int width );
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352 void
00353 sc_trace( sc_trace_file* tf,
00354 const unsigned int& object,
00355 const std::string& name,
00356 const char** enum_literals );
00357
00358
00359
00360
00361 extern void sc_trace( sc_trace_file* tf,
00362 const void* object,
00363 const std::string& name );
00364
00365
00366
00367
00368
00369 inline
00370 void
00371 sc_trace_delta_cycles( sc_trace_file* tf, bool on = true )
00372 {
00373 if( tf ) tf->delta_cycles( on );
00374 }
00375
00376
00377
00378
00379 inline
00380 void
00381 sc_write_comment( sc_trace_file* tf, const std::string& comment )
00382 {
00383 if( tf ) tf->write_comment( comment );
00384 }
00385
00386
00387
00388
00389 #ifdef __GNUC__
00390 void tprintf( sc_trace_file* tf, const char* format, ... )
00391 __attribute__ ((format (printf,2,3)));
00392 #else
00393 void tprintf( sc_trace_file* tf, const char* format, ... );
00394 #endif
00395
00396
00397
00398
00399 extern void double_to_special_int64( double in,
00400 unsigned* high,
00401 unsigned* low );
00402
00403 }
00404
00405 #endif