SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_vcd_trace.h
Go to the documentation of this file.
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_vcd_trace.h - Implementation of VCD 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. The
44 contribution of Infineon in the development of this tracing
45 technology is hereby acknowledged.
46
47 *****************************************************************************/
48
49#ifndef SC_VCD_TRACE_H
50#define SC_VCD_TRACE_H
51
53
54namespace sc_core {
55
56class sc_time;
57
58class vcd_trace; // defined in sc_vcd_trace.cpp
59template<class T> class vcd_T_trace;
60
61
62// ----------------------------------------------------------------------------
63// CLASS : vcd_trace_file
64//
65// ...
66// ----------------------------------------------------------------------------
67
69 : public sc_trace_file_base
70{
71public:
72
74
75 // sc_set_vcd_time_unit is deprecated.
76#if 0 // deprecated
77 inline void sc_set_vcd_time_unit(int exponent10_seconds)
78 { set_time_unit(exponent10_seconds); }
79#endif
80
81 // Create a Vcd trace file.
82 // `Name' forms the base of the name to which `.vcd' is added.
83 vcd_trace_file(const char *name);
84
85 // Flush results and close file.
87
88protected:
89
90 // These are all virtual functions in sc_trace_file and
91 // they need to be defined here.
92
93 // Trace sc_time, sc_event
94 virtual void trace(const sc_time& object, const std::string& name);
95 virtual void trace(const sc_event& object, const std::string& name);
96
97 // Trace a boolean object (single bit)
98 void trace(const bool& object, const std::string& name);
99
100 // Trace a sc_bit object (single bit)
101 virtual void trace( const sc_dt::sc_bit& object,
102 const std::string& name);
103
104 // Trace a sc_logic object (single bit)
105 void trace(const sc_dt::sc_logic& object, const std::string& name);
106
107 // Trace an unsigned char with the given width
108 void trace(const unsigned char& object, const std::string& name,
109 int width);
110
111 // Trace an unsigned short with the given width
112 void trace(const unsigned short& object, const std::string& name,
113 int width);
114
115 // Trace an unsigned int with the given width
116 void trace(const unsigned int& object, const std::string& name,
117 int width);
118
119 // Trace an unsigned long with the given width
120 void trace(const unsigned long& object, const std::string& name,
121 int width);
122
123 // Trace a signed char with the given width
124 void trace(const char& object, const std::string& name, int width);
125
126 // Trace a signed short with the given width
127 void trace(const short& object, const std::string& name, int width);
128
129 // Trace a signed int with the given width
130 void trace(const int& object, const std::string& name, int width);
131
132 // Trace a signed long with the given width
133 void trace(const long& object, const std::string& name, int width);
134
135 // Trace an int64 with a given width
136 void trace(const sc_dt::int64& object, const std::string& name,
137 int width);
138
139 // Trace a uint64 with a given width
140 void trace(const sc_dt::uint64& object, const std::string& name,
141 int width);
142
143 // Trace a float
144 void trace(const float& object, const std::string& name);
145
146 // Trace a double
147 void trace(const double& object, const std::string& name);
148
149 // Trace sc_dt::sc_uint_base
150 void trace (const sc_dt::sc_uint_base& object,
151 const std::string& name);
152
153 // Trace sc_dt::sc_int_base
154 void trace (const sc_dt::sc_int_base& object,
155 const std::string& name);
156
157 // Trace sc_dt::sc_unsigned
158 void trace (const sc_dt::sc_unsigned& object,
159 const std::string& name);
160
161 // Trace sc_dt::sc_signed
162 void trace (const sc_dt::sc_signed& object, const std::string& name);
163
164 // Trace sc_dt::sc_fxval
165 void trace( const sc_dt::sc_fxval& object, const std::string& name );
166
167 // Trace sc_dt::sc_fxval_fast
168 void trace( const sc_dt::sc_fxval_fast& object,
169 const std::string& name );
170
171 // Trace sc_dt::sc_fxnum
172 void trace( const sc_dt::sc_fxnum& object, const std::string& name );
173
174 // Trace sc_dt::sc_fxnum_fast
175 void trace( const sc_dt::sc_fxnum_fast& object,
176 const std::string& name );
177
178 template<class T>
179 void traceT(const T& object, const std::string& name,
180 vcd_enum type=VCD_WIRE)
181 {
182 if( add_trace_check(name) )
183 traces.push_back(new vcd_T_trace<T>( object, name
184 , obtain_name(),type) );
185 }
186
187 // Trace sc_dt::sc_bv_base (sc_dt::sc_bv)
188 virtual void trace(const sc_dt::sc_bv_base& object,
189 const std::string& name);
190
191 // Trace sc_dt::sc_lv_base (sc_dt::sc_lv)
192 virtual void trace(const sc_dt::sc_lv_base& object,
193 const std::string& name);
194
195 // Trace an enumerated object - where possible output the enumeration literals
196 // in the trace file. Enum literals is a null terminated array of null
197 // terminated char* literal strings.
198 void trace(const unsigned& object, const std::string& name,
199 const char** enum_literals);
200
201 // Output a comment to the trace file
202 void write_comment(const std::string& comment);
203
204 // Write trace info for cycle.
205 void cycle(bool delta_cycle);
206
207private:
208
209 template<typename T> const T& extract_ref(const T& object) const
210 { return object; }
211 const sc_dt::uint64& extract_ref(const sc_event& object) const
212 { return event_trigger_stamp(object); }
213
214 // avoid hidden overload warnings
215 virtual void trace( sc_trace_file* ) const;
216
217 // Initialize the VCD tracing
218 virtual void do_initialize();
219 void print_time_stamp(unit_type now_units_high, unit_type now_units_low) const;
220 bool get_time_stamp(unit_type &now_units_high, unit_type &now_units_low) const;
221
222 unsigned vcd_name_index; // Number of variables traced
223
224 unit_type previous_time_units_low;
225 unit_type previous_time_units_high;
226
227public:
228
229 // Array to store the variables traced
230 std::vector<vcd_trace*> traces;
231
232 // Create VCD names for each variable
233 std::string obtain_name();
234
235};
236
237} // namespace sc_core
238
239#endif // SC_VCD_TRACE_H
240// Taf!
unsigned long long uint64
Definition: sc_nbdefs.h:216
long long int64
Definition: sc_nbdefs.h:215
const sc_dt::uint64 & event_trigger_stamp(const sc_event &event) const
sc_time::value_type unit_type
virtual void set_time_unit(double v, sc_time_unit tu)
bool add_trace_check(const std::string &name) const
void trace(const int &object, const std::string &name, int width)
void trace(const double &object, const std::string &name)
virtual void trace(const sc_event &object, const std::string &name)
void trace(const float &object, const std::string &name)
void trace(const unsigned long &object, const std::string &name, int width)
virtual void trace(const sc_time &object, const std::string &name)
void trace(const sc_dt::sc_fxnum_fast &object, const std::string &name)
virtual void trace(const sc_dt::sc_bit &object, const std::string &name)
void trace(const unsigned short &object, const std::string &name, int width)
void trace(const unsigned char &object, const std::string &name, int width)
void trace(const sc_dt::sc_signed &object, const std::string &name)
void trace(const sc_dt::sc_fxval &object, const std::string &name)
void trace(const sc_dt::uint64 &object, const std::string &name, int width)
void cycle(bool delta_cycle)
void trace(const unsigned &object, const std::string &name, const char **enum_literals)
void trace(const sc_dt::sc_fxnum &object, const std::string &name)
virtual void trace(const sc_dt::sc_bv_base &object, const std::string &name)
std::string obtain_name()
void trace(const sc_dt::sc_fxval_fast &object, const std::string &name)
std::vector< vcd_trace * > traces
Definition: sc_vcd_trace.h:230
void trace(const unsigned int &object, const std::string &name, int width)
void trace(const sc_dt::sc_int_base &object, const std::string &name)
void write_comment(const std::string &comment)
virtual void trace(const sc_dt::sc_lv_base &object, const std::string &name)
void trace(const char &object, const std::string &name, int width)
void trace(const sc_dt::sc_logic &object, const std::string &name)
void trace(const short &object, const std::string &name, int width)
void trace(const sc_dt::int64 &object, const std::string &name, int width)
vcd_trace_file(const char *name)
void trace(const long &object, const std::string &name, int width)
void trace(const sc_dt::sc_unsigned &object, const std::string &name)
void trace(const sc_dt::sc_uint_base &object, const std::string &name)
void traceT(const T &object, const std::string &name, vcd_enum type=VCD_WIRE)
Definition: sc_vcd_trace.h:179
void trace(const bool &object, const std::string &name)