sc_vcd_trace.h revision 12027
12SN/A/***************************************************************************** 21762SN/A 32SN/A Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 42SN/A more contributor license agreements. See the NOTICE file distributed 52SN/A with this work for additional information regarding copyright ownership. 62SN/A Accellera licenses this file to you under the Apache License, Version 2.0 72SN/A (the "License"); you may not use this file except in compliance with the 82SN/A License. You may obtain a copy of the License at 92SN/A 102SN/A http://www.apache.org/licenses/LICENSE-2.0 112SN/A 122SN/A Unless required by applicable law or agreed to in writing, software 132SN/A distributed under the License is distributed on an "AS IS" BASIS, 142SN/A WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 152SN/A implied. See the License for the specific language governing 162SN/A permissions and limitations under the License. 172SN/A 182SN/A *****************************************************************************/ 192SN/A 202SN/A/***************************************************************************** 212SN/A 222SN/A sc_vcd_trace.h - Implementation of VCD tracing. 232SN/A 242SN/A Original Author - Abhijit Ghosh, Synopsys, Inc. 252SN/A 262SN/A *****************************************************************************/ 272665Ssaidi@eecs.umich.edu 282665Ssaidi@eecs.umich.edu/***************************************************************************** 292665Ssaidi@eecs.umich.edu 302SN/A MODIFICATION LOG - modifiers, enter your name, affiliation, date and 312SN/A changes you are making here. 322SN/A 3356SN/A Name, Affiliation, Date: 341696SN/A Description of Modification: 352SN/A 362107SN/A *****************************************************************************/ 372SN/A 382SN/A/***************************************************************************** 392107SN/A 402SN/A Acknowledgement: The tracing mechanism is based on the tracing 412SN/A mechanism developed at Infineon (formerly Siemens HL). Though this 422107SN/A code is somewhat different, and significantly enhanced, the basics 432SN/A are identical to what was originally contributed by Infineon. The 442SN/A contribution of Infineon in the development of this tracing 452SN/A technology is hereby acknowledged. 462SN/A 472SN/A *****************************************************************************/ 482SN/A 492SN/A#ifndef SC_VCD_TRACE_H 502SN/A#define SC_VCD_TRACE_H 512SN/A 522SN/A#include "sysc/tracing/sc_trace_file_base.h" 532SN/A 542SN/Anamespace sc_core { 552SN/A 562SN/Aclass vcd_trace; // defined in vcd_trace.cpp 572SN/Atemplate<class T> class vcd_T_trace; 582SN/A 592SN/A 602SN/A// ---------------------------------------------------------------------------- 612SN/A// CLASS : vcd_trace_file 622SN/A// 632107SN/A// ... 642SN/A// ---------------------------------------------------------------------------- 652SN/A 662SN/Aclass vcd_trace_file 672SN/A : public sc_trace_file_base 682SN/A{ 692SN/Apublic: 702SN/A 712SN/A enum vcd_enum {VCD_WIRE=0, VCD_REAL=1, VCD_LAST}; 722SN/A 732SN/A // sc_set_vcd_time_unit is deprecated. 742SN/A#if 0 // deprecated 752SN/A inline void sc_set_vcd_time_unit(int exponent10_seconds) 762SN/A { set_time_unit(exponent10_seconds); } 772SN/A#endif 78 79 // Create a Vcd trace file. 80 // `Name' forms the base of the name to which `.vcd' is added. 81 vcd_trace_file(const char *name); 82 83 // Flush results and close file. 84 ~vcd_trace_file(); 85 86protected: 87 88 // These are all virtual functions in sc_trace_file and 89 // they need to be defined here. 90 91 // Trace a boolean object (single bit) 92 void trace(const bool& object, const std::string& name); 93 94 // Trace a sc_bit object (single bit) 95 virtual void trace( const sc_dt::sc_bit& object, 96 const std::string& name); 97 98 // Trace a sc_logic object (single bit) 99 void trace(const sc_dt::sc_logic& object, const std::string& name); 100 101 // Trace an unsigned char with the given width 102 void trace(const unsigned char& object, const std::string& name, 103 int width); 104 105 // Trace an unsigned short with the given width 106 void trace(const unsigned short& object, const std::string& name, 107 int width); 108 109 // Trace an unsigned int with the given width 110 void trace(const unsigned int& object, const std::string& name, 111 int width); 112 113 // Trace an unsigned long with the given width 114 void trace(const unsigned long& object, const std::string& name, 115 int width); 116 117 // Trace a signed char with the given width 118 void trace(const char& object, const std::string& name, int width); 119 120 // Trace a signed short with the given width 121 void trace(const short& object, const std::string& name, int width); 122 123 // Trace a signed int with the given width 124 void trace(const int& object, const std::string& name, int width); 125 126 // Trace a signed long with the given width 127 void trace(const long& object, const std::string& name, int width); 128 129 // Trace an int64 with a given width 130 void trace(const sc_dt::int64& object, const std::string& name, 131 int width); 132 133 // Trace a uint64 with a given width 134 void trace(const sc_dt::uint64& object, const std::string& name, 135 int width); 136 137 // Trace a float 138 void trace(const float& object, const std::string& name); 139 140 // Trace a double 141 void trace(const double& object, const std::string& name); 142 143 // Trace sc_dt::sc_uint_base 144 void trace (const sc_dt::sc_uint_base& object, 145 const std::string& name); 146 147 // Trace sc_dt::sc_int_base 148 void trace (const sc_dt::sc_int_base& object, 149 const std::string& name); 150 151 // Trace sc_dt::sc_unsigned 152 void trace (const sc_dt::sc_unsigned& object, 153 const std::string& name); 154 155 // Trace sc_dt::sc_signed 156 void trace (const sc_dt::sc_signed& object, const std::string& name); 157 158 // Trace sc_dt::sc_fxval 159 void trace( const sc_dt::sc_fxval& object, const std::string& name ); 160 161 // Trace sc_dt::sc_fxval_fast 162 void trace( const sc_dt::sc_fxval_fast& object, 163 const std::string& name ); 164 165 // Trace sc_dt::sc_fxnum 166 void trace( const sc_dt::sc_fxnum& object, const std::string& name ); 167 168 // Trace sc_dt::sc_fxnum_fast 169 void trace( const sc_dt::sc_fxnum_fast& object, 170 const std::string& name ); 171 172 template<class T> 173 void traceT(const T& object, const std::string& name, 174 vcd_enum type=VCD_WIRE) 175 { 176 if( add_trace_check(name) ) 177 traces.push_back(new vcd_T_trace<T>( object, name 178 , obtain_name(),type) ); 179 } 180 181 // Trace sc_dt::sc_bv_base (sc_dt::sc_bv) 182 virtual void trace(const sc_dt::sc_bv_base& object, 183 const std::string& name); 184 185 // Trace sc_dt::sc_lv_base (sc_dt::sc_lv) 186 virtual void trace(const sc_dt::sc_lv_base& object, 187 const std::string& name); 188 // Trace an enumerated object - where possible output the enumeration literals 189 // in the trace file. Enum literals is a null terminated array of null 190 // terminated char* literal strings. 191 void trace(const unsigned& object, const std::string& name, 192 const char** enum_literals); 193 194 // Output a comment to the trace file 195 void write_comment(const std::string& comment); 196 197 // Write trace info for cycle. 198 void cycle(bool delta_cycle); 199 200private: 201 202#if SC_TRACING_PHASE_CALLBACKS_ 203 // avoid hidden overload warnings 204 virtual void trace( sc_trace_file* ) const { sc_assert(false); } 205#endif // SC_TRACING_PHASE_CALLBACKS_ 206 207 // Initialize the VCD tracing 208 virtual void do_initialize(); 209 210 unsigned vcd_name_index; // Number of variables traced 211 212 unsigned previous_time_units_low; // Previous time unit as 64-bit integer 213 unsigned previous_time_units_high; 214 215public: 216 217 // Array to store the variables traced 218 std::vector<vcd_trace*> traces; 219 220 // Create VCD names for each variable 221 std::string obtain_name(); 222 223}; 224 225} // namespace sc_core 226 227#endif // SC_VCD_TRACE_H 228// Taf! 229