sc_wif_trace.h revision 12027
1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 sc_wif_trace.h - Implementation of WIF tracing. 23 24 Original Author - Abhijit Ghosh, Synopsys, Inc. 25 26 *****************************************************************************/ 27 28/***************************************************************************** 29 30 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 31 changes you are making here. 32 33 Name, Affiliation, Date: 34 Description of Modification: 35 36 *****************************************************************************/ 37 38/***************************************************************************** 39 40 Acknowledgement: The tracing mechanism is based on the tracing 41 mechanism developed at Infineon (formerly Siemens HL). Though this 42 code is somewhat different, and significantly enhanced, the basics 43 are identical to what was originally contributed by Infineon. 44 The contribution of Infineon in the development of this tracing 45 technology is hereby acknowledged. 46 47 *****************************************************************************/ 48 49/***************************************************************************** 50 51 Instead of creating the binary WIF format, we create the ASCII 52 WIF format which can be converted to the binary format using 53 a2wif (utility that comes with VSS from Synopsys). This way, 54 a user who does not have Synopsys VSS can still create WIF 55 files, but the files can only be viewed by users who have VSS. 56 57 *****************************************************************************/ 58 59#ifndef SC_WIF_TRACE_H 60#define SC_WIF_TRACE_H 61 62#include <cstdio> 63#include "sysc/datatypes/int/sc_nbdefs.h" 64#include "sysc/tracing/sc_trace_file_base.h" 65 66namespace sc_core { 67 68class wif_trace; // defined in wif_trace.cc 69template<class T> class wif_T_trace; 70 71class wif_trace_file 72 : public sc_trace_file_base 73{ 74public: 75 enum wif_enum {WIF_BIT=0, WIF_MVL=1, WIF_REAL=2, WIF_LAST}; 76 77 // Create a wif trace file. 78 // `Name' forms the base of the name to which `.awif' is added. 79 explicit wif_trace_file(const char *name); 80 81 ~wif_trace_file(); 82 83protected: 84 // These are all virtual functions in sc_trace_file and 85 // they need to be defined here. 86 87 // Trace a boolean object (single bit) 88 void trace(const bool& object, const std::string& name); 89 90 // Trace a sc_bit object (single bit) 91 void trace(const sc_dt::sc_bit& object, const std::string& name); 92 93 // Trace a sc_logic object (single bit) 94 void trace(const sc_dt::sc_logic& object, const std::string& name); 95 96 // Trace an unsigned char with the given width 97 void trace(const unsigned char& object, const std::string& name, 98 int width); 99 100 // Trace an unsigned short with the given width 101 void trace(const unsigned short& object, const std::string& name, 102 int width); 103 104 // Trace an unsigned int with the given width 105 void trace(const unsigned int& object, const std::string& name, 106 int width); 107 108 // Trace an unsigned long with the given width 109 void trace(const unsigned long& object, const std::string& name, 110 int width); 111 112 // Trace a signed char with the given width 113 void trace(const char& object, const std::string& name, int width); 114 115 // Trace a signed short with the given width 116 void trace(const short& object, const std::string& name, int width); 117 118 // Trace a signed int with the given width 119 void trace(const int& object, const std::string& name, int width); 120 121 // Trace a signed long with the given width 122 void trace(const long& object, const std::string& name, int width); 123 124 // Trace a signed long long with the given width 125 void trace(const sc_dt::int64& object, const std::string& name, 126 int width); 127 128 // Trace an usigned long long with the given width 129 void trace(const sc_dt::uint64& object, const std::string& name, 130 int width); 131 132 // Trace a float 133 void trace(const float& object, const std::string& name); 134 135 // Trace a double 136 void trace(const double& object, const std::string& name); 137 138 // Trace sc_unsigned 139 void trace (const sc_dt::sc_unsigned& object, 140 const std::string& name); 141 142 // Trace sc_signed 143 void trace (const sc_dt::sc_signed& object, 144 const std::string& name); 145 146 // Trace sc_uint_base 147 void trace (const sc_dt::sc_uint_base& object, 148 const std::string& name); 149 150 // Trace sc_int_base 151 void trace (const sc_dt::sc_int_base& object, const std::string& name); 152 153 // Trace sc_fxval 154 void trace( const sc_dt::sc_fxval& object, const std::string& name ); 155 156 // Trace sc_fxval_fast 157 void trace( const sc_dt::sc_fxval_fast& object, 158 const std::string& name ); 159 160 // Trace sc_fxnum 161 void trace( const sc_dt::sc_fxnum& object, const std::string& name ); 162 163 // Trace sc_fxnum_fast 164 void trace( const sc_dt::sc_fxnum_fast& object, 165 const std::string& name ); 166 167 template<class T> 168 void traceT(const T& object, const std::string& name, wif_enum type) 169 { 170 if( add_trace_check(name) ) 171 traces.push_back( new wif_T_trace<T>( object, name 172 , obtain_name(),type ) ); 173 } 174 175 // Trace sc_bv_base (sc_bv) 176 virtual void trace( const sc_dt::sc_bv_base& object, 177 const std::string& name ); 178 179 // Trace sc_lv_base (sc_lv) 180 virtual void trace( const sc_dt::sc_lv_base& object, 181 const std::string& name ); 182 183 // Trace an enumerated object - where possible output the enumeration literals 184 // in the trace file. Enum literals is a null terminated array of null 185 // terminated char* literal strings. 186 void trace(const unsigned& object, const std::string& name, 187 const char** enum_literals); 188 189 // Output a comment to the trace file 190 void write_comment(const std::string& comment); 191 192 // Write trace info for cycle. 193 void cycle(bool delta_cycle); 194 195private: 196 197#if SC_TRACING_PHASE_CALLBACKS_ 198 // avoid hidden overload warnings 199 virtual void trace( sc_trace_file* ) const { sc_assert(false); } 200#endif // SC_TRACING_PHASE_CALLBACKS_ 201 202 // Initialize the tracing mechanism 203 virtual void do_initialize(); 204 205 unsigned wif_name_index; // Number of variables traced 206 207 unsigned previous_time_units_low; // Previous time as 64 bit integer 208 unsigned previous_time_units_high; 209 double previous_time; // Previous time as a double 210 211public: 212 // Create wif names for each variable 213 std::string obtain_name(); 214 215 // Array to store the variables traced 216 std::vector<wif_trace*> traces; 217}; 218 219} // namespace sc_core 220 221#endif // SC_WIF_TRACE_H 222// Taf! 223