gem5  v21.1.0.2
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 
36 namespace sc_gem5
37 {
38 
39 class 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 
52 class 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  {
73  _nextName[NextNameChars] = '\0';
74  for (int i = 0; i < NextNameChars; i++)
75  _nextName[i] = 'a';
76  }
77  ~VcdTraceFile();
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);
88  topScope.addValue(name, 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__
sc_gem5::VcdTraceScope::scopes
std::map< std::string, VcdTraceScope * > scopes
Definition: vcd.hh:45
sc_gem5::VcdTraceFile::initialize
void initialize()
Definition: vcd.cc:223
sc_gem5::VcdTraceFile::nextSignalName
std::string nextSignalName()
Definition: vcd.cc:205
sc_dt::sc_fxnum_fast
Definition: sc_fxnum.hh:844
sc_dt::sc_fxval
Definition: sc_fxval.hh:86
sc_dt::sc_bv_base
Definition: sc_bv_base.hh:105
sc_dt::sc_int_base
Definition: sc_int_base.hh:494
sc_gem5::VcdTraceFile::addNewTraceVal
void addNewTraceVal(const typename TV::TracedType *v, const std::string &name, int width=1)
Definition: vcd.hh:83
sc_gem5::VcdTraceFile::VcdTraceFile
VcdTraceFile(const std::string &name)
Definition: vcd.hh:69
sc_gem5::VcdTraceFile::trace
void trace(bool delta) override
Definition: vcd.cc:285
sc_gem5::VcdTraceFile::deltasAtNow
uint64_t deltasAtNow
Definition: vcd.hh:56
tracefile.hh
std::vector
STL vector class.
Definition: stl.hh:37
sc_dt::sc_signed
Definition: sc_signed.hh:984
sc_dt::sc_logic
Definition: sc_logic.hh:130
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
sc_gem5::VcdTraceFile::~VcdTraceFile
~VcdTraceFile()
Definition: vcd.cc:272
sc_gem5::VcdTraceFile
Definition: vcd.hh:52
sc_gem5::VcdTraceFile::_nextName
char _nextName[NextNameChars+1]
Definition: vcd.hh:59
sc_gem5::VcdTraceScope::output
void output(const std::string &name, std::ostream &os)
Definition: vcd.cc:158
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
gem5::ArmISA::width
Bitfield< 4 > width
Definition: misc_types.hh:71
sc_gem5::VcdTraceFile::NextNameChars
static const int NextNameChars
Definition: vcd.hh:58
sc_core::sc_event
Definition: sc_event.hh:169
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::ArmISA::v
Bitfield< 28 > v
Definition: misc_types.hh:54
sc_core::sc_time
Definition: sc_time.hh:49
sc_dt::sc_fxnum
Definition: sc_fxnum.hh:483
sc_gem5::TraceFile
Definition: tracefile.hh:191
sc_dt::int64
int64_t int64
Definition: sc_nbdefs.hh:205
sc_gem5::VcdTraceFile::addTraceVal
void addTraceVal(const bool *v, const std::string &name) override
Definition: vcd.cc:339
sc_gem5::VcdTraceFile::writeComment
void writeComment(const std::string &comment) override
Definition: vcd.cc:696
name
const std::string & name()
Definition: trace.cc:49
sc_gem5::VcdTraceScope
Definition: vcd.hh:41
sc_dt::sc_uint_base
Definition: sc_uint_base.hh:465
sc_dt::sc_lv_base
Definition: sc_lv_base.hh:118
sc_gem5::VcdTraceScope::values
std::vector< std::pair< std::string, VcdTraceValBase * > > values
Definition: vcd.hh:44
sc_dt::sc_fxval_fast
Definition: sc_fxval.hh:376
types.hh
gem5::X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:809
sc_dt::sc_unsigned
Definition: sc_unsigned.hh:890
sc_gem5::VcdTraceFile::initialized
bool initialized
Definition: vcd.hh:62
sc_gem5
Definition: sc_clock.cc:41
sc_gem5::VcdTraceScope::addValue
void addValue(const std::string &name, VcdTraceValBase *value)
Definition: vcd.cc:143
sc_gem5::VcdTraceFile::traceVals
std::vector< VcdTraceValBase * > traceVals
Definition: vcd.hh:65
sc_gem5::VcdTraceFile::lastPrintedTime
gem5::Tick lastPrintedTime
Definition: vcd.hh:55
sc_gem5::VcdTraceValBase
Definition: vcd.cc:71
sc_gem5::VcdTraceFile::topScope
VcdTraceScope topScope
Definition: vcd.hh:66

Generated on Tue Sep 21 2021 12:26:16 for gem5 by doxygen 1.8.17