1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include <vector>
31
32#include "systemc/core/scheduler.hh"
33#include "systemc/ext/channel/sc_signal_in_if.hh"
34#include "systemc/ext/core/sc_event.hh"
35#include "systemc/ext/core/sc_time.hh"
36#include "systemc/ext/dt/bit/sc_bv_base.hh"
37#include "systemc/ext/dt/bit/sc_logic.hh"
38#include "systemc/ext/dt/bit/sc_lv_base.hh"
39#include "systemc/ext/dt/fx/sc_fxnum.hh"
40#include "systemc/ext/dt/fx/sc_fxval.hh"
41#include "systemc/ext/dt/int/sc_int_base.hh"
42#include "systemc/ext/dt/int/sc_signed.hh"
43#include "systemc/ext/dt/int/sc_uint_base.hh"
44#include "systemc/ext/dt/int/sc_unsigned.hh"
45#include "systemc/ext/utils/sc_trace_file.hh"
46#include "systemc/utils/vcd.hh"
47
48namespace sc_core
49{
50
51sc_trace_file::sc_trace_file() {}
52sc_trace_file::~sc_trace_file() {}
53
54sc_trace_file *
55sc_create_vcd_trace_file(const char *name)
56{
57    auto tf = new ::sc_gem5::VcdTraceFile(name);
58    ::sc_gem5::scheduler.registerTraceFile(tf);
59    return tf;
60}
61
62void
63sc_close_vcd_trace_file(sc_trace_file *tf)
64{
65    ::sc_gem5::scheduler.unregisterTraceFile(
66            static_cast<::sc_gem5::TraceFile *>(tf));
67    delete tf;
68}
69
70void
71sc_write_comment(sc_trace_file *tf, const std::string &comment)
72{
73    static_cast<::sc_gem5::TraceFile *>(tf)->writeComment(comment);
74}
75
76void
77sc_trace(sc_trace_file *tf, const bool &v, const std::string &name)
78{
79    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
80}
81
82void
83sc_trace(sc_trace_file *tf, const bool *v, const std::string &name)
84{
85    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
86}
87
88void
89sc_trace(sc_trace_file *tf, const float &v, const std::string &name)
90{
91    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
92}
93
94void
95sc_trace(sc_trace_file *tf, const float *v, const std::string &name)
96{
97    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
98}
99
100void
101sc_trace(sc_trace_file *tf, const double &v, const std::string &name)
102{
103    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
104}
105
106void
107sc_trace(sc_trace_file *tf, const double *v, const std::string &name)
108{
109    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
110}
111
112void
113sc_trace(sc_trace_file *tf, const sc_dt::sc_logic &v, const std::string &name)
114{
115    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
116}
117
118void
119sc_trace(sc_trace_file *tf, const sc_dt::sc_logic *v, const std::string &name)
120{
121    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
122}
123
124void
125sc_trace(sc_trace_file *tf, const sc_dt::sc_int_base &v,
126        const std::string &name)
127{
128    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
129}
130
131void
132sc_trace(sc_trace_file *tf, const sc_dt::sc_int_base *v,
133        const std::string &name)
134{
135    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
136}
137
138void
139sc_trace(sc_trace_file *tf, const sc_dt::sc_uint_base &v,
140        const std::string &name)
141{
142    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
143}
144
145void
146sc_trace(sc_trace_file *tf, const sc_dt::sc_uint_base *v,
147        const std::string &name)
148{
149    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
150}
151
152void
153sc_trace(sc_trace_file *tf, const sc_dt::sc_signed &v,
154        const std::string &name)
155{
156    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
157}
158
159void
160sc_trace(sc_trace_file *tf, const sc_dt::sc_signed *v,
161        const std::string &name)
162{
163    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
164}
165
166void
167sc_trace(sc_trace_file *tf, const sc_dt::sc_unsigned &v,
168        const std::string &name)
169{
170    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
171}
172
173void
174sc_trace(sc_trace_file *tf, const sc_dt::sc_unsigned *v,
175        const std::string &name)
176{
177    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
178}
179
180void
181sc_trace(sc_trace_file *tf, const sc_dt::sc_bv_base &v,
182        const std::string &name)
183{
184    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
185}
186
187void
188sc_trace(sc_trace_file *tf, const sc_dt::sc_bv_base *v,
189        const std::string &name)
190{
191    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
192}
193
194void
195sc_trace(sc_trace_file *tf, const sc_dt::sc_lv_base &v,
196        const std::string &name)
197{
198    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
199}
200
201void
202sc_trace(sc_trace_file *tf, const sc_dt::sc_lv_base *v,
203        const std::string &name)
204{
205    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
206}
207
208void
209sc_trace(sc_trace_file *tf, const sc_dt::sc_fxval &v, const std::string &name)
210{
211    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
212}
213
214void
215sc_trace(sc_trace_file *tf, const sc_dt::sc_fxval *v, const std::string &name)
216{
217    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
218}
219
220void
221sc_trace(sc_trace_file *tf, const sc_dt::sc_fxval_fast &v,
222        const std::string &name)
223{
224    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
225}
226
227void
228sc_trace(sc_trace_file *tf, const sc_dt::sc_fxval_fast *v,
229        const std::string &name)
230{
231    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
232}
233
234void
235sc_trace(sc_trace_file *tf, const sc_dt::sc_fxnum &v, const std::string &name)
236{
237    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
238}
239
240void
241sc_trace(sc_trace_file *tf, const sc_dt::sc_fxnum *v, const std::string &name)
242{
243    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
244}
245
246void
247sc_trace(sc_trace_file *tf, const sc_dt::sc_fxnum_fast &v,
248        const std::string &name)
249{
250    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
251}
252
253void
254sc_trace(sc_trace_file *tf, const sc_dt::sc_fxnum_fast *v,
255        const std::string &name)
256{
257    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
258}
259
260void
261sc_trace(sc_trace_file *tf, const sc_event &v, const std::string &name)
262{
263    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
264}
265
266void
267sc_trace(sc_trace_file *tf, const sc_event *v, const std::string &name)
268{
269    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
270}
271
272void
273sc_trace(sc_trace_file *tf, const sc_time &v, const std::string &name)
274{
275    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name);
276}
277
278void
279sc_trace(sc_trace_file *tf, const sc_time *v, const std::string &name)
280{
281    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name);
282}
283
284void
285sc_trace(sc_trace_file *tf, const unsigned char &v,
286         const std::string &name, int width)
287{
288    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
289}
290
291void
292sc_trace(sc_trace_file *tf, const unsigned char *v,
293         const std::string &name, int width)
294{
295    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
296}
297
298void
299sc_trace(sc_trace_file *tf, const unsigned short &v,
300         const std::string &name, int width)
301{
302    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
303}
304
305void
306sc_trace(sc_trace_file *tf, const unsigned short *v,
307         const std::string &name, int width)
308{
309    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
310}
311
312void
313sc_trace(sc_trace_file *tf, const unsigned int &v,
314        const std::string &name, int width)
315{
316    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
317}
318
319void
320sc_trace(sc_trace_file *tf, const unsigned int *v,
321        const std::string &name, int width)
322{
323    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
324}
325
326void
327sc_trace(sc_trace_file *tf, const unsigned long &v,
328         const std::string &name, int width)
329{
330    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
331}
332
333void
334sc_trace(sc_trace_file *tf, const unsigned long *v,
335         const std::string &name, int width)
336{
337    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
338}
339
340void
341sc_trace(sc_trace_file *tf, const char &v, const std::string &name, int width)
342{
343    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
344}
345
346void
347sc_trace(sc_trace_file *tf, const char *v, const std::string &name, int width)
348{
349    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
350}
351
352void
353sc_trace(sc_trace_file *tf, const short &v,
354        const std::string &name, int width)
355{
356    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
357}
358
359void
360sc_trace(sc_trace_file *tf, const short *v,
361        const std::string &name, int width)
362{
363    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
364}
365
366void
367sc_trace(sc_trace_file *tf, const int &v, const std::string &name, int width)
368{
369    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
370}
371
372void
373sc_trace(sc_trace_file *tf, const int *v, const std::string &name, int width)
374{
375    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
376}
377
378void
379sc_trace(sc_trace_file *tf, const long &v, const std::string &name, int width)
380{
381    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
382}
383
384void
385sc_trace(sc_trace_file *tf, const long *v, const std::string &name, int width)
386{
387    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
388}
389
390void
391sc_trace(sc_trace_file *tf, const sc_dt::int64 &v,
392        const std::string &name, int width)
393{
394    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
395}
396
397void
398sc_trace(sc_trace_file *tf, const sc_dt::int64 *v,
399        const std::string &name, int width)
400{
401    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
402}
403
404void
405sc_trace(sc_trace_file *tf, const sc_dt::uint64 &v,
406         const std::string &name, int width)
407{
408    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(&v, name, width);
409}
410
411void
412sc_trace(sc_trace_file *tf, const sc_dt::uint64 *v,
413         const std::string &name, int width)
414{
415    static_cast<::sc_gem5::TraceFile *>(tf)->addTraceVal(v, name, width);
416}
417
418void
419sc_trace(sc_trace_file *tf, const sc_signal_in_if<char> &v,
420         const std::string &name, int width)
421{
422    static_cast<::sc_gem5::TraceFile *>(tf)->
423        addTraceVal(&v.read(), name, width);
424}
425
426void
427sc_trace(sc_trace_file *tf, const sc_signal_in_if<short> &v,
428         const std::string &name, int width)
429{
430    static_cast<::sc_gem5::TraceFile *>(tf)->
431        addTraceVal(&v.read(), name, width);
432}
433
434void
435sc_trace(sc_trace_file *tf, const sc_signal_in_if<int> &v,
436         const std::string &name, int width)
437{
438    static_cast<::sc_gem5::TraceFile *>(tf)->
439        addTraceVal(&v.read(), name, width);
440}
441
442void
443sc_trace(sc_trace_file *tf, const sc_signal_in_if<long> &v,
444         const std::string &name, int width)
445{
446    static_cast<::sc_gem5::TraceFile *>(tf)->
447        addTraceVal(&v.read(), name, width);
448}
449
450void
451sc_trace(sc_trace_file *tf, const unsigned int &v,
452         const std::string &name, const char **enum_literals)
453{
454    static_cast<::sc_gem5::TraceFile *>(tf)->
455        addTraceVal(&v, name, enum_literals);
456}
457
458void
459sc_trace_delta_cycles(sc_trace_file *tf, bool on)
460{
461    static_cast<::sc_gem5::TraceFile *>(tf)->traceDeltas(on);
462}
463
464} // namespace sc_core
465