ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
VCD.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// This file is part of ETISS. It is licensed under the BSD 3-Clause License; you may not use this file except in
4// compliance with the License. You should have received a copy of the license along with this project. If not, see the
5// LICENSE file.
14#ifndef ETISS_INTERFACES_VCD_H
15#define ETISS_INTERFACES_VCD_H
16
17#include "etiss/Misc.h"
18
19#include <fstream>
20#include <iostream>
21#include <vector>
22
33#define ETISS_INTERFACES_VCD_DECLARE(LOG, VAR, WIDTH) \
34 { \
35 (VAR).vcd = &(LOG); \
36 (LOG).declare((VAR), ETISS_TOSTRING(VAR), WIDTH, (VAR).errval); \
37 }
38
39namespace etiss
40{
41namespace interfaces
42{
43
48class VCD : public etiss::ToString
49{
50 public:
51 class Signal
52 {
53 public:
54 inline Signal() : valid(false) {}
55 std::string name;
56 // std::string module;
57 bool valid;
59 unsigned width;
60 std::string ident;
62 };
64
65 VCD(const std::string &file, const std::string &comment = std::string());
66 virtual ~VCD();
67
68 template <typename T>
69 inline bool declare(T &variable, const std::string &name, unsigned width, uint64_t initialvalue,
70 uint64_t undefined = -1)
71 {
72 return declare((void *)&variable, name, width, initialvalue, undefined);
73 }
74
75 template <typename T>
76 inline void update(double time_s, const T &variable, uint64_t value, uint64_t undefined = 0)
77 {
78 update((uint64_t)(time_s * 1000000000000.0), (void *)&variable, value, undefined);
79 }
80
81 inline std::string toString() const { return std::string("VCD { file=\"") + file + "\"}"; }
82
83 void close();
84
85 protected:
86 bool declare(void *variable, const std::string &name, unsigned width, uint64_t initialvalue, uint64_t undefined);
87 void update(uint64_t time_ps, void *variable, uint64_t value, uint64_t undefined);
88 void flush();
89
90 private:
91 std::ofstream out_;
92 bool valid_;
94 std::vector<Signal> sigs_;
96 std::map<void *, int> ptr2index_;
97 std::string dumpvar;
98 std::string file;
99};
100
101} // namespace interfaces
102} // namespace etiss
103
104#endif // ETISS_INTERFACES_VCD_H
general configuration and logging
#define etiss_del_como(CLASS)
Definition Misc.h:52
static __inline__ uint64_t
Definition arm_cde.h:31
Marker interface for toString() support.
Definition Misc.h:95
std::ofstream out_
Definition VCD.h:91
std::map< void *, int > ptr2index_
Definition VCD.h:96
bool declare(T &variable, const std::string &name, unsigned width, uint64_t initialvalue, uint64_t undefined=-1)
Definition VCD.h:69
uint64_t lasttime_ps
Definition VCD.h:95
virtual etiss_del_como(VCD) VCD(const std ~VCD()
Definition VCD.cpp:83
void update(double time_s, const T &variable, uint64_t value, uint64_t undefined=0)
Definition VCD.h:76
std::string toString() const
Definition VCD.h:81
std::string dumpvar
TODO replace with better lookup.
Definition VCD.h:97
std::vector< Signal > sigs_
Definition VCD.h:94
std::string file
Definition VCD.h:98
forwards: include/jit/*
Definition Benchmark.h:17
#define false
Definition stdbool.h:17