19 return (udef & 1) ?
"x" : ((val & 1) ?
"1" :
"0");
23 char *ret =
new char[width + 3];
27 for (
unsigned i = 1; i < width + 1; i++)
29 ret[width + 1 - i] = (udef & 1) ?
'x' : ((val & 1) ?
'1' :
'0');
47 out +=
static_cast<char>(index % 94) + 33;
56VCD::VCD(
const std::string &file,
const std::string &comment) : dumpstarted_(
false), lasttime_ps(0), file(file)
59 valid_ = out_.is_open();
77 "$timescale 1ps $end\n";
80 dumpvar =
"$enddefinitions $end\n$dumpvars\n";
97bool VCD::declare(
void *variable,
const std::string &name,
unsigned width,
uint64_t initialvalue,
uint64_t undefined)
101 if (name.size() == 0)
111 if (sigs_.size() >= (94 + 94 * 94 + 94 * 94 * 94 + 94 * 94 * 94 * 94))
113 etiss::log(
etiss::ERROR,
"etiss::interfaces::VCD::declare called for more than supported variables.", *
this);
116 int checked_sig_size =
static_cast<int>(sigs_.size());
117 sigs_.emplace_back();
118 Signal &sig = sigs_.back();
122 sig.
value = initialvalue;
131 [](
const std::string &str,
size_t from,
size_t &seplen)
133 size_t f1 = str.find(
".", from);
134 size_t f2 = str.find(
"::", from);
135 seplen = f1 < f2 ? 1 : 2;
136 return f1 < f2 ? f1 : f2;
138 std::vector<std::string> vec;
139 vec.insert(vec.end(), vec_bd.begin(), vec_bd.end());
142 for (
size_t i = 1; i < vec.size(); i++)
144 out_ <<
"$scope module " << vec[i - 1] <<
" $end\n";
146 out_ <<
"$var wire " << width <<
" " << sig.
ident <<
" " << vec[vec.size() - 1] <<
" $end\n";
147 for (
size_t i = 1; i < vec.size(); i++)
149 out_ <<
"$upscope $end\n";
153 dumpvar = dumpvar +
val2str(initialvalue, width, undefined) + sig.
ident +
"\n";
155 ptr2index_.insert(std::make_pair(variable, (checked_sig_size - 1)));
165 if (time_ps < lasttime_ps)
170 auto findex = ptr2index_.find(variable);
171 if (findex != ptr2index_.end())
173 if (time_ps > lasttime_ps)
176 lasttime_ps = time_ps;
178 int index = findex->second;
179 Signal &sig = sigs_[index];
194 if (lasttime_ps == 0)
200 for (
size_t i = 0; i < sigs_.size(); i++)
210 out_ <<
"#" << lasttime_ps <<
"\n";
211 for (
size_t i = 0; i < sigs_.size(); i++)
216 out_ <<
val2str(
s.value,
s.width,
s.undefined) <<
s.ident <<
"\n";
__device__ __2f16 float bool s
static __inline__ uint64_t
#define ETISS_VERSION_FULL
static std::string index2str(int index)
generated an identifier for the given index
static std::string val2str(uint64_t val, unsigned width, uint64_t udef)
TODO efficient implementation.
std::list< std::string > split(const std::string &str, std::function< size_t(const std::string &, size_t, size_t &)> findsplit)
void log(Verbosity level, std::string msg)
write log message at the given level.