gem5  v20.1.0.0
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 
34 
35 namespace sc_gem5
36 {
37 
38 class VcdTraceValBase;
39 
41 {
42  private:
44  std::map<std::string, VcdTraceScope *> scopes;
45 
46  public:
47  void addValue(const std::string &name, VcdTraceValBase *value);
48  void output(const std::string &name, std::ostream &os);
49 };
50 
51 class VcdTraceFile : public TraceFile
52 {
53  private:
55  uint64_t deltasAtNow;
56 
57  static const int NextNameChars = 5;
59  std::string nextSignalName();
60 
62  void initialize();
63 
66 
67  public:
68  VcdTraceFile(const std::string &name) :
69  TraceFile(name + ".vcd"), lastPrintedTime(0), deltasAtNow(0),
70  initialized(false)
71  {
72  _nextName[NextNameChars] = '\0';
73  for (int i = 0; i < NextNameChars; i++)
74  _nextName[i] = 'a';
75  }
76  ~VcdTraceFile();
77 
78  void trace(bool delta) override;
79 
80  template<typename TV>
81  void
82  addNewTraceVal(const typename TV::TracedType *v, const std::string &name,
83  int width=1)
84  {
85  VcdTraceValBase *tv = new TV(v, nextSignalName(), width);
86  traceVals.push_back(tv);
87  topScope.addValue(name, tv);
88  }
89 
90  void addTraceVal(const bool *v, const std::string &name) override;
91  void addTraceVal(const float *v, const std::string &name) override;
92  void addTraceVal(const double *v, const std::string &name) override;
93 
94  void addTraceVal(const sc_dt::sc_logic *v,
95  const std::string &name) override;
96  void addTraceVal(const sc_dt::sc_int_base *v,
97  const std::string &name) override;
98  void addTraceVal(const sc_dt::sc_uint_base *v,
99  const std::string &name) override;
100  void addTraceVal(const sc_dt::sc_signed *v,
101  const std::string &name) override;
102  void addTraceVal(const sc_dt::sc_unsigned *v,
103  const std::string &name) override;
104  void addTraceVal(const sc_dt::sc_bv_base *v,
105  const std::string &name) override;
106  void addTraceVal(const sc_dt::sc_lv_base *v,
107  const std::string &name) override;
108  void addTraceVal(const sc_dt::sc_fxval *v,
109  const std::string &name) override;
110  void addTraceVal(const sc_dt::sc_fxval_fast *v,
111  const std::string &name) override;
112  void addTraceVal(const sc_dt::sc_fxnum *v,
113  const std::string &name) override;
114  void addTraceVal(const sc_dt::sc_fxnum_fast *v,
115  const std::string &name) override;
116 
117  void addTraceVal(const sc_core::sc_event *v,
118  const std::string &name) override;
119  void addTraceVal(const sc_core::sc_time *v,
120  const std::string &name) override;
121 
122  void addTraceVal(const unsigned char *v,
123  const std::string &name, int width) override;
124  void addTraceVal(const char *v, const std::string &name,
125  int width) override;
126  void addTraceVal(const unsigned short *v,
127  const std::string &name, int width) override;
128  void addTraceVal(const short *v, const std::string &name,
129  int width) override;
130  void addTraceVal(const unsigned int *v,
131  const std::string &name, int width) override;
132  void addTraceVal(const int *v, const std::string &name,
133  int width) override;
134  void addTraceVal(const unsigned long *v,
135  const std::string &name, int width) override;
136  void addTraceVal(const long *v, const std::string &name,
137  int width) override;
138 
139  void addTraceVal(const sc_dt::int64 *v,
140  const std::string &name, int width) override;
141  void addTraceVal(const sc_dt::uint64 *v,
142  const std::string &name, int width) override;
143 
144  void addTraceVal(const unsigned int *, const std::string &name,
145  const char **literals) override;
146 
147  void writeComment(const std::string &comment) override;
148 };
149 
150 } // namespace sc_gem5
151 
152 #endif // __SYSTEMC_UTILS_VCD_HH__
sc_gem5::VcdTraceScope::scopes
std::map< std::string, VcdTraceScope * > scopes
Definition: vcd.hh:44
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
sc_gem5::VcdTraceFile::initialize
void initialize()
Definition: vcd.cc:222
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
sc_gem5::VcdTraceFile::nextSignalName
std::string nextSignalName()
Definition: vcd.cc:204
ArmISA::width
Bitfield< 4 > width
Definition: miscregs_types.hh:68
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
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
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:82
sc_gem5::VcdTraceFile::VcdTraceFile
VcdTraceFile(const std::string &name)
Definition: vcd.hh:68
sc_gem5::VcdTraceFile::trace
void trace(bool delta) override
Definition: vcd.cc:282
sc_gem5::VcdTraceFile::deltasAtNow
uint64_t deltasAtNow
Definition: vcd.hh:55
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
sc_gem5::VcdTraceFile::~VcdTraceFile
~VcdTraceFile()
Definition: vcd.cc:271
sc_gem5::VcdTraceFile
Definition: vcd.hh:51
sc_gem5::VcdTraceFile::_nextName
char _nextName[NextNameChars+1]
Definition: vcd.hh:58
sc_gem5::VcdTraceScope::output
void output(const std::string &name, std::ostream &os)
Definition: vcd.cc:157
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
sc_gem5::VcdTraceFile::NextNameChars
static const int NextNameChars
Definition: vcd.hh:57
sc_core::sc_event
Definition: sc_event.hh:169
sc_core::sc_time
Definition: sc_time.hh:49
sc_dt::sc_fxnum
Definition: sc_fxnum.hh:483
sc_gem5::TraceFile
Definition: tracefile.hh:190
sc_dt::int64
int64_t int64
Definition: sc_nbdefs.hh:205
sc_gem5::VcdTraceFile::lastPrintedTime
Tick lastPrintedTime
Definition: vcd.hh:54
sc_gem5::VcdTraceFile::addTraceVal
void addTraceVal(const bool *v, const std::string &name) override
Definition: vcd.cc:336
sc_gem5::VcdTraceFile::writeComment
void writeComment(const std::string &comment) override
Definition: vcd.cc:693
name
const std::string & name()
Definition: trace.cc:50
sc_gem5::VcdTraceScope
Definition: vcd.hh:40
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:43
sc_dt::sc_fxval_fast
Definition: sc_fxval.hh:376
sc_dt::sc_unsigned
Definition: sc_unsigned.hh:890
sc_gem5::VcdTraceFile::initialized
bool initialized
Definition: vcd.hh:61
sc_gem5
Definition: sc_clock.cc:42
sc_gem5::VcdTraceScope::addValue
void addValue(const std::string &name, VcdTraceValBase *value)
Definition: vcd.cc:142
sc_gem5::VcdTraceFile::traceVals
std::vector< VcdTraceValBase * > traceVals
Definition: vcd.hh:64
ArmISA::v
Bitfield< 28 > v
Definition: miscregs_types.hh:51
sc_gem5::VcdTraceValBase
Definition: vcd.cc:70
sc_gem5::VcdTraceFile::topScope
VcdTraceScope topScope
Definition: vcd.hh:65

Generated on Wed Sep 30 2020 14:02:18 for gem5 by doxygen 1.8.17