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