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
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef SC_WIF_TRACE_H
00058 #define SC_WIF_TRACE_H
00059
00060 #include <cstdio>
00061 #include "sysc/datatypes/int/sc_nbdefs.h"
00062 #include "sysc/tracing/sc_trace.h"
00063 #include "sysc/utils/sc_vector.h"
00064
00065 namespace sc_core {
00066
00067 class wif_trace;
00068 template<class T> class wif_T_trace;
00069
00070 void wif_put_error_message(const char* msg, bool just_warning);
00071
00072 class wif_trace_file : public sc_trace_file{
00073 public:
00074 enum wif_enum {WIF_BIT=0, WIF_MVL=1, WIF_REAL=2, WIF_LAST};
00075
00076 void sc_set_wif_time_unit(int exponent10_seconds);
00077
00078
00079
00080 wif_trace_file(const char *name);
00081
00082
00083 ~wif_trace_file();
00084
00085 protected:
00086
00087
00088
00089
00090 void trace(const bool& object, const std::string& name);
00091
00092
00093 void trace(const sc_dt::sc_bit& object, const std::string& name);
00094
00095
00096 void trace(const sc_dt::sc_logic& object, const std::string& name);
00097
00098
00099 void trace(const unsigned char& object, const std::string& name,
00100 int width);
00101
00102
00103 void trace(const unsigned short& object, const std::string& name,
00104 int width);
00105
00106
00107 void trace(const unsigned int& object, const std::string& name,
00108 int width);
00109
00110
00111 void trace(const unsigned long& object, const std::string& name,
00112 int width);
00113
00114
00115 void trace(const char& object, const std::string& name, int width);
00116
00117
00118 void trace(const short& object, const std::string& name, int width);
00119
00120
00121 void trace(const int& object, const std::string& name, int width);
00122
00123
00124 void trace(const long& object, const std::string& name, int width);
00125
00126
00127 void trace(const sc_dt::int64& object, const std::string& name,
00128 int width);
00129
00130
00131 void trace(const sc_dt::uint64& object, const std::string& name,
00132 int width);
00133
00134
00135 void trace(const float& object, const std::string& name);
00136
00137
00138 void trace(const double& object, const std::string& name);
00139
00140
00141 void trace (const sc_dt::sc_unsigned& object,
00142 const std::string& name);
00143
00144
00145 void trace (const sc_dt::sc_signed& object,
00146 const std::string& name);
00147
00148
00149 void trace (const sc_dt::sc_uint_base& object,
00150 const std::string& name);
00151
00152
00153 void trace (const sc_dt::sc_int_base& object, const std::string& name);
00154
00155
00156 void trace( const sc_dt::sc_fxval& object, const std::string& name );
00157
00158
00159 void trace( const sc_dt::sc_fxval_fast& object,
00160 const std::string& name );
00161
00162
00163 void trace( const sc_dt::sc_fxnum& object, const std::string& name );
00164
00165
00166 void trace( const sc_dt::sc_fxnum_fast& object,
00167 const std::string& name );
00168
00169 template<class T>
00170 void traceT(const T& object, const std::string& name, wif_enum type)
00171 {
00172 if(initialized)
00173 wif_put_error_message("No traces can be added once simulation has"
00174 " started.\nTo add traces, create a new wif trace file.", false);
00175 else
00176 traces.push_back(new wif_T_trace<T>(object, name,
00177 obtain_new_index(),type));
00178 }
00179
00180
00181 virtual void trace( const sc_dt::sc_bv_base& object,
00182 const std::string& name );
00183
00184
00185 virtual void trace( const sc_dt::sc_lv_base& object,
00186 const std::string& name );
00187
00188
00189
00190
00191 void trace(const unsigned& object, const std::string& name,
00192 const char** enum_literals);
00193
00194
00195 void write_comment(const std::string& comment);
00196
00197
00198 void delta_cycles(bool flag);
00199
00200
00201 void cycle(bool delta_cycle);
00202
00203 private:
00204
00205 void initialize();
00206
00207
00208 void create_wif_name(std::string* ptr_to_str);
00209
00210
00211 FILE* fp;
00212
00213 double timescale_unit;
00214 bool timescale_set_by_user;
00215 bool trace_delta_cycles;
00216
00217 unsigned wif_name_index;
00218
00219 unsigned previous_time_units_low, previous_time_units_high;
00220 double previous_time;
00221
00222 public:
00223
00224 bool initialized;
00225
00226 std::string obtain_new_index();
00227
00228
00229 sc_pvector<wif_trace*> traces;
00230 };
00231
00232
00233 extern sc_trace_file *sc_create_wif_trace_file(const char *name);
00234 extern void sc_close_wif_trace_file( sc_trace_file* tf );
00235
00236 }
00237
00238 #endif