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_time;
00075 
00076 template <class T> class sc_signal_in_if;
00077 
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     
00156     virtual void set_time_unit( double v, sc_time_unit tu )=0;
00157 
00158 protected:
00159 
00160     
00161     virtual void cycle( bool delta_cycle ) = 0;
00162 
00163     
00164     virtual ~sc_trace_file()
00165         {  }
00166 };
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 #define DECL_TRACE_FUNC_REF_A(tp)     \
00176 void                                  \
00177 sc_trace( sc_trace_file* tf,          \
00178           const tp& object,               \
00179           const std::string& name );
00180 
00181 #define DECL_TRACE_FUNC_PTR_A(tp)     \
00182 void                                  \
00183 sc_trace( sc_trace_file* tf,          \
00184           const tp* object,               \
00185           const std::string& name );        \
00186 
00187 #define DECL_TRACE_FUNC_A(tp)         \
00188 DECL_TRACE_FUNC_REF_A(tp)             \
00189 DECL_TRACE_FUNC_PTR_A(tp)
00190 
00191 
00192 DECL_TRACE_FUNC_A( sc_dt::sc_bit )
00193 DECL_TRACE_FUNC_A( sc_dt::sc_logic )
00194 
00195 DECL_TRACE_FUNC_A( sc_dt::sc_int_base )
00196 DECL_TRACE_FUNC_A( sc_dt::sc_uint_base )
00197 DECL_TRACE_FUNC_A( sc_dt::sc_signed )
00198 DECL_TRACE_FUNC_A( sc_dt::sc_unsigned )
00199 
00200 DECL_TRACE_FUNC_REF_A( sc_dt::sc_bv_base )
00201 DECL_TRACE_FUNC_REF_A( sc_dt::sc_lv_base )
00202 
00203 
00204 #undef DECL_TRACE_FUNC_REF_A
00205 #undef DECL_TRACE_FUNC_PTR_A
00206 #undef DECL_TRACE_FUNC_A
00207 
00208 
00209 
00210 
00211 #define DEFN_TRACE_FUNC_REF_A(tp)                                             \
00212 inline                                                                        \
00213 void                                                                          \
00214 sc_trace( sc_trace_file* tf, const tp& object, const std::string& name ) \
00215 {                                                                             \
00216     if( tf ) {                                                                \
00217         tf->trace( object, name );                                            \
00218     }                                                                         \
00219 }
00220 
00221 #define DEFN_TRACE_FUNC_PTR_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_A(tp)                                                 \
00232 DEFN_TRACE_FUNC_REF_A(tp)                                                     \
00233 DEFN_TRACE_FUNC_PTR_A(tp)
00234 
00235 
00236 #define DEFN_TRACE_FUNC_REF_B(tp)                                             \
00237 inline                                                                        \
00238 void                                                                          \
00239 sc_trace( sc_trace_file* tf, const tp& object, const std::string& name,  \
00240           int width = 8 * sizeof( tp ) )                                      \
00241 {                                                                             \
00242     if( tf ) {                                                                \
00243         tf->trace( object, name, width );                                     \
00244     }                                                                         \
00245 }
00246 
00247 #define DEFN_TRACE_FUNC_PTR_B(tp)                                             \
00248 inline                                                                        \
00249 void                                                                          \
00250 sc_trace( sc_trace_file* tf, const tp* object, const std::string& name,  \
00251           int width = 8 * sizeof( tp ) )                                      \
00252 {                                                                             \
00253     if( tf ) {                                                                \
00254         tf->trace( *object, name, width );                                    \
00255     }                                                                         \
00256 }
00257 
00258 
00259 #define DEFN_TRACE_FUNC_B(tp)                                                 \
00260 DEFN_TRACE_FUNC_REF_B(tp)                                                     \
00261 DEFN_TRACE_FUNC_PTR_B(tp)
00262 
00263 
00264 DEFN_TRACE_FUNC_A( bool )
00265 DEFN_TRACE_FUNC_A( float )
00266 DEFN_TRACE_FUNC_A( double )
00267 
00268 DEFN_TRACE_FUNC_B( unsigned char )
00269 DEFN_TRACE_FUNC_B( unsigned short )
00270 DEFN_TRACE_FUNC_B( unsigned int )
00271 DEFN_TRACE_FUNC_B( unsigned long )
00272 DEFN_TRACE_FUNC_B( char )
00273 DEFN_TRACE_FUNC_B( short )
00274 DEFN_TRACE_FUNC_B( int )
00275 DEFN_TRACE_FUNC_B( long )
00276 DEFN_TRACE_FUNC_B( sc_dt::int64 )
00277 DEFN_TRACE_FUNC_B( sc_dt::uint64 )
00278 
00279 
00280 #undef DEFN_TRACE_FUNC_REF_A
00281 #undef DEFN_TRACE_FUNC_PTR_A
00282 #undef DEFN_TRACE_FUNC_A
00283 
00284 #undef DEFN_TRACE_FUNC_REF_B
00285 #undef DEFN_TRACE_FUNC_PTR_B
00286 #undef DEFN_TRACE_FUNC_B
00287 
00288 
00289 template <class T> 
00290 inline
00291 void
00292 sc_trace( sc_trace_file* tf,
00293           const sc_signal_in_if<T>& object,
00294           const std::string& name )
00295 {
00296     sc_trace( tf, object.read(), name );
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 char* name )
00305 {
00306     sc_trace( tf, object.read(), name );
00307 }
00308 
00309 
00310 
00311 
00312 void sc_trace( sc_trace_file* tf,
00313                const sc_signal_in_if<char>& object,
00314                const std::string& name,
00315                int width );
00316 
00317 void sc_trace( sc_trace_file* tf,
00318                const sc_signal_in_if<short>& object,
00319                const std::string& name,
00320                int width );
00321 
00322 void sc_trace( sc_trace_file* tf,
00323                const sc_signal_in_if<int>& object,
00324                const std::string& name,
00325                int width );
00326 
00327 void sc_trace( sc_trace_file* tf,
00328                const sc_signal_in_if<long>& object,
00329                const std::string& name,
00330                int width );
00331 
00332 
00333 
00334 
00335 
00336 
00337 
00338 
00339 
00340 
00341 
00342 void
00343 sc_trace( sc_trace_file* tf,
00344           const unsigned int& object,
00345           const std::string& name,
00346           const char** enum_literals );
00347 
00348 
00349 
00350 
00351 extern void sc_trace( sc_trace_file* tf,
00352                       const void* object,
00353                       const std::string& name );
00354 
00355 
00356 
00357 
00358 
00359 inline
00360 void
00361 sc_trace_delta_cycles( sc_trace_file* tf, bool on = true )
00362 {
00363     if( tf ) tf->delta_cycles( on );
00364 }
00365 
00366 
00367 
00368 
00369 inline
00370 void
00371 sc_write_comment( sc_trace_file* tf, const std::string& comment )
00372 {
00373     if( tf ) tf->write_comment( comment );
00374 }
00375 
00376 
00377 
00378 
00379 void tprintf( sc_trace_file* tf,  const char* format, ... );
00380 
00381 
00382 
00383 extern sc_trace_file *sc_create_vcd_trace_file(const char* name);
00384 extern void sc_close_vcd_trace_file( sc_trace_file* tf );
00385 
00386 
00387 
00388 
00389 extern sc_trace_file *sc_create_wif_trace_file(const char *name);
00390 extern void sc_close_wif_trace_file( sc_trace_file* tf );
00391 
00392 } 
00393 
00394 #endif // SC_TRACE_H
00395