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