gem5 v24.0.0.0
Loading...
Searching...
No Matches
vcd.hh
Go to the documentation of this file.
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
28#ifndef __SYSTEMC_UTILS_VCD_HH__
29#define __SYSTEMC_UTILS_VCD_HH__
30
31#include <map>
32
33#include "base/types.hh"
35
36namespace sc_gem5
37{
38
39class VcdTraceValBase;
40
42{
43 private:
45 std::map<std::string, VcdTraceScope *> scopes;
46
47 public:
48 void addValue(const std::string &name, VcdTraceValBase *value);
49 void output(const std::string &name, std::ostream &os);
50};
51
52class VcdTraceFile : public TraceFile
53{
54 private:
56 uint64_t deltasAtNow;
57
58 static const int NextNameChars = 5;
60 std::string nextSignalName();
61
63 void initialize();
64
67
68 public:
69 VcdTraceFile(const std::string &name) :
70 TraceFile(name + ".vcd"), lastPrintedTime(0), deltasAtNow(0),
71 initialized(false)
72 {
74 for (int i = 0; i < NextNameChars; i++)
75 _nextName[i] = 'a';
76 }
78
79 void trace(bool delta) override;
80
81 template<typename TV>
82 void
83 addNewTraceVal(const typename TV::TracedType *v, const std::string &name,
84 int width=1)
85 {
86 VcdTraceValBase *tv = new TV(v, nextSignalName(), width);
87 traceVals.push_back(tv);
89 }
90
91 void addTraceVal(const bool *v, const std::string &name) override;
92 void addTraceVal(const float *v, const std::string &name) override;
93 void addTraceVal(const double *v, const std::string &name) override;
94
95 void addTraceVal(const sc_dt::sc_logic *v,
96 const std::string &name) override;
97 void addTraceVal(const sc_dt::sc_int_base *v,
98 const std::string &name) override;
99 void addTraceVal(const sc_dt::sc_uint_base *v,
100 const std::string &name) override;
101 void addTraceVal(const sc_dt::sc_signed *v,
102 const std::string &name) override;
103 void addTraceVal(const sc_dt::sc_unsigned *v,
104 const std::string &name) override;
105 void addTraceVal(const sc_dt::sc_bv_base *v,
106 const std::string &name) override;
107 void addTraceVal(const sc_dt::sc_lv_base *v,
108 const std::string &name) override;
109 void addTraceVal(const sc_dt::sc_fxval *v,
110 const std::string &name) override;
111 void addTraceVal(const sc_dt::sc_fxval_fast *v,
112 const std::string &name) override;
113 void addTraceVal(const sc_dt::sc_fxnum *v,
114 const std::string &name) override;
115 void addTraceVal(const sc_dt::sc_fxnum_fast *v,
116 const std::string &name) override;
117
118 void addTraceVal(const sc_core::sc_event *v,
119 const std::string &name) override;
120 void addTraceVal(const sc_core::sc_time *v,
121 const std::string &name) override;
122
123 void addTraceVal(const unsigned char *v,
124 const std::string &name, int width) override;
125 void addTraceVal(const char *v, const std::string &name,
126 int width) override;
127 void addTraceVal(const unsigned short *v,
128 const std::string &name, int width) override;
129 void addTraceVal(const short *v, const std::string &name,
130 int width) override;
131 void addTraceVal(const unsigned int *v,
132 const std::string &name, int width) override;
133 void addTraceVal(const int *v, const std::string &name,
134 int width) override;
135 void addTraceVal(const unsigned long *v,
136 const std::string &name, int width) override;
137 void addTraceVal(const long *v, const std::string &name,
138 int width) override;
139
140 void addTraceVal(const sc_dt::int64 *v,
141 const std::string &name, int width) override;
142 void addTraceVal(const sc_dt::uint64 *v,
143 const std::string &name, int width) override;
144
145 void addTraceVal(const unsigned int *, const std::string &name,
146 const char **literals) override;
147
148 void writeComment(const std::string &comment) override;
149};
150
151} // namespace sc_gem5
152
153#endif // __SYSTEMC_UTILS_VCD_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
void writeComment(const std::string &comment) override
Definition vcd.cc:696
void addTraceVal(const bool *v, const std::string &name) override
Definition vcd.cc:339
uint64_t deltasAtNow
Definition vcd.hh:56
VcdTraceFile(const std::string &name)
Definition vcd.hh:69
char _nextName[NextNameChars+1]
Definition vcd.hh:59
static const int NextNameChars
Definition vcd.hh:58
std::vector< VcdTraceValBase * > traceVals
Definition vcd.hh:65
void addNewTraceVal(const typename TV::TracedType *v, const std::string &name, int width=1)
Definition vcd.hh:83
gem5::Tick lastPrintedTime
Definition vcd.hh:55
std::string nextSignalName()
Definition vcd.cc:205
void trace(bool delta) override
Definition vcd.cc:285
VcdTraceScope topScope
Definition vcd.hh:66
void addValue(const std::string &name, VcdTraceValBase *value)
Definition vcd.cc:143
std::map< std::string, VcdTraceScope * > scopes
Definition vcd.hh:45
std::vector< std::pair< std::string, VcdTraceValBase * > > values
Definition vcd.hh:44
void output(const std::string &name, std::ostream &os)
Definition vcd.cc:158
STL vector class.
Definition stl.hh:37
uint64_t Tick
Tick count type.
Definition types.hh:58
uint64_t uint64
Definition sc_nbdefs.hh:172
int64_t int64
Definition sc_nbdefs.hh:171
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:07 for gem5 by doxygen 1.11.0