SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_wif_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_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>
65
66namespace sc_core {
67
68class wif_trace; // defined in wif_trace.cc
69template<class T> class wif_T_trace;
70
72 : public sc_trace_file_base
73{
74public:
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
82
83protected:
84 // These are all virtual functions in sc_trace_file and
85 // they need to be defined here.
86
87 // Trace sc_time, sc_event
88 virtual void trace(const sc_time& object, const std::string& name);
89 virtual void trace(const sc_event& object, const std::string& name);
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 void trace(const sc_dt::sc_bit& object, const std::string& name);
96
97 // Trace a sc_logic object (single bit)
98 void trace(const sc_dt::sc_logic& object, const std::string& name);
99
100 // Trace an unsigned char with the given width
101 void trace(const unsigned char& object, const std::string& name,
102 int width);
103
104 // Trace an unsigned short with the given width
105 void trace(const unsigned short& object, const std::string& name,
106 int width);
107
108 // Trace an unsigned int with the given width
109 void trace(const unsigned int& object, const std::string& name,
110 int width);
111
112 // Trace an unsigned long with the given width
113 void trace(const unsigned long& object, const std::string& name,
114 int width);
115
116 // Trace a signed char with the given width
117 void trace(const char& object, const std::string& name, int width);
118
119 // Trace a signed short with the given width
120 void trace(const short& object, const std::string& name, int width);
121
122 // Trace a signed int with the given width
123 void trace(const int& object, const std::string& name, int width);
124
125 // Trace a signed long with the given width
126 void trace(const long& object, const std::string& name, int width);
127
128 // Trace a signed long long with the given width
129 void trace(const sc_dt::int64& object, const std::string& name,
130 int width);
131
132 // Trace an usigned long long with the given width
133 void trace(const sc_dt::uint64& object, const std::string& name,
134 int width);
135
136 // Trace a float
137 void trace(const float& object, const std::string& name);
138
139 // Trace a double
140 void trace(const double& object, const std::string& name);
141
142 // Trace sc_unsigned
143 void trace (const sc_dt::sc_unsigned& object,
144 const std::string& name);
145
146 // Trace sc_signed
147 void trace (const sc_dt::sc_signed& object,
148 const std::string& name);
149
150 // Trace sc_uint_base
151 void trace (const sc_dt::sc_uint_base& object,
152 const std::string& name);
153
154 // Trace sc_int_base
155 void trace (const sc_dt::sc_int_base& object, const std::string& name);
156
157 // Trace sc_fxval
158 void trace( const sc_dt::sc_fxval& object, const std::string& name );
159
160 // Trace sc_fxval_fast
161 void trace( const sc_dt::sc_fxval_fast& object,
162 const std::string& name );
163
164 // Trace sc_fxnum
165 void trace( const sc_dt::sc_fxnum& object, const std::string& name );
166
167 // Trace sc_fxnum_fast
168 void trace( const sc_dt::sc_fxnum_fast& object,
169 const std::string& name );
170
171 template<class T>
172 void traceT(const T& object, const std::string& name, wif_enum type)
173 {
174 if( add_trace_check(name) )
175 traces.push_back( new wif_T_trace<T>( object, name
176 , obtain_name(),type ) );
177 }
178
179 // Trace sc_bv_base (sc_bv)
180 virtual void trace( const sc_dt::sc_bv_base& object,
181 const std::string& name );
182
183 // Trace sc_lv_base (sc_lv)
184 virtual void trace( const sc_dt::sc_lv_base& object,
185 const std::string& name );
186
187 // Trace an enumerated object - where possible output the enumeration literals
188 // in the trace file. Enum literals is a null terminated array of null
189 // terminated char* literal strings.
190 void trace(const unsigned& object, const std::string& name,
191 const char** enum_literals);
192
193 // Output a comment to the trace file
194 void write_comment(const std::string& comment);
195
196 // Write trace info for cycle.
197 void cycle(bool delta_cycle);
198
199private:
200 // avoid hidden overload warnings
201 virtual void trace( sc_trace_file* ) const;
202
203 // Initialize the tracing mechanism
204 virtual void do_initialize();
205
206 unsigned wif_name_index; // Number of variables traced
207
208 unit_type previous_units_low;
209 unit_type previous_units_high;
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!
unsigned long long uint64
Definition: sc_nbdefs.h:216
long long int64
Definition: sc_nbdefs.h:215
sc_time::value_type unit_type
bool add_trace_check(const std::string &name) const
virtual void trace(const sc_event &object, const std::string &name)
void trace(const sc_dt::sc_fxnum &object, const std::string &name)
void trace(const unsigned int &object, const std::string &name, int width)
void write_comment(const std::string &comment)
wif_trace_file(const char *name)
void trace(const sc_dt::uint64 &object, const std::string &name, int width)
void trace(const sc_dt::int64 &object, const std::string &name, int width)
void trace(const double &object, const std::string &name)
std::string obtain_name()
void trace(const sc_dt::sc_fxnum_fast &object, const std::string &name)
void trace(const long &object, const std::string &name, int width)
std::vector< wif_trace * > traces
Definition: sc_wif_trace.h:216
virtual void trace(const sc_time &object, const std::string &name)
void trace(const float &object, const std::string &name)
void trace(const bool &object, const std::string &name)
void traceT(const T &object, const std::string &name, wif_enum type)
Definition: sc_wif_trace.h:172
void trace(const sc_dt::sc_fxval &object, const std::string &name)
void trace(const sc_dt::sc_uint_base &object, const std::string &name)
void trace(const sc_dt::sc_fxval_fast &object, const std::string &name)
void trace(const sc_dt::sc_signed &object, const std::string &name)
virtual void trace(const sc_dt::sc_bv_base &object, const std::string &name)
void trace(const unsigned long &object, const std::string &name, int width)
void trace(const int &object, const std::string &name, int width)
void trace(const char &object, const std::string &name, int width)
void trace(const unsigned char &object, const std::string &name, int width)
void cycle(bool delta_cycle)
void trace(const sc_dt::sc_unsigned &object, const std::string &name)
void trace(const short &object, const std::string &name, int width)
void trace(const sc_dt::sc_logic &object, const std::string &name)
virtual void trace(const sc_dt::sc_lv_base &object, const std::string &name)
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 &object, const std::string &name, const char **enum_literals)
void trace(const sc_dt::sc_int_base &object, const std::string &name)