57 cleanName(std::string
name)
59 for (
int i = 0;
i <
name.length();
i++) {
62 else if (
name[
i] ==
']')
78 const char first = orig[0];
80 if (first !=
'z' && first !=
'x' && first !=
'0')
83 const char *res = orig;
84 while (*++res == first) {}
86 if (first !=
'0' || *res !=
'1')
136 virtual std::string
vcdType() {
return "wire"; }
138 virtual void output(std::ostream &
os) = 0;
144 size_t pos =
name.find_first_of(
'.');
145 if (pos == std::string::npos) {
148 std::string sname =
name.substr(0, pos);
149 auto it =
scopes.find(sname);
152 it->second->addValue(
name.substr(pos + 1), value);
159 os <<
"$scope module " <<
name <<
" $end" << std::endl;
162 const std::string &
name =
p.first;
174 std::string clean_name = cleanName(
name);
179 ccprintf(
os,
"$var %s % 3d %s %s [%d:0] $end\n",
185 p.second->output(
p.first,
os);
187 os <<
"$upscope $end" << std::endl;
190 template <
typename T>
216 }
while (carry && pos >= 0);
227 stream() <<
"$date" << std::endl;
230 struct tm *p_tm = localtime(&long_time);
231 stream() << std::put_time(p_tm,
" %b %d, %Y %H:%M:%S\n");
232 stream() <<
"$end" << std::endl << std::endl;
235 stream() <<
"$version" << std::endl;
237 stream() <<
"$end" << std::endl << std::endl;
240 stream() <<
"$timescale" << std::endl;
243 stream() <<
"$end" << std::endl << std::endl;
250 stream() <<
"$enddefinitions $end" << std::endl << std::endl;
254 std::string timedump_comment =
255 csprintf(
"All initial values are dumped below at time "
256 "%g sec = %g timescale units.",
263 stream() <<
"$dumpvars" << std::endl;
266 stream() <<
"$end" << std::endl << std::endl;
307 bool time_printed =
false;
338 addNewTraceVal<VcdTraceValBool>(
v,
name);
341 template <
typename T>
347 std::string
vcdType()
override {
return "real"; }
359 addNewTraceVal<VcdTraceValFloat<float>>(
v,
name);
364 addNewTraceVal<VcdTraceValFloat<double>>(
v,
name);
386 addNewTraceVal<VcdTraceValScLogic>(
v,
name);
389 template <
typename T>
406 const int w = this->
width();
409 for (
int i =
w - 1;
i >= 0;
i--)
410 str += this->
value()[
i].to_bool() ?
'1' :
'0';
418 const std::string &
name)
420 addNewTraceVal<VcdTraceValFinite<sc_dt::sc_int_base>>(
v,
name);
424 const std::string &
name)
426 addNewTraceVal<VcdTraceValFinite<sc_dt::sc_uint_base>>(
v,
name);
432 addNewTraceVal<VcdTraceValFinite<sc_dt::sc_signed>>(
v,
name);
436 const std::string &
name)
438 addNewTraceVal<VcdTraceValFinite<sc_dt::sc_unsigned>>(
v,
name);
441 template <
typename T>
464 addNewTraceVal<VcdTraceValLogic<::sc_dt::sc_bv_base>>(
v,
name);
469 addNewTraceVal<VcdTraceValLogic<::sc_dt::sc_lv_base>>(
v,
name);
472 template <
typename T>
478 std::string
vcdType()
override {
return "real"; }
491 addNewTraceVal<VcdTraceValFxval<sc_dt::sc_fxval>>(
v,
name);
495 const std::string &
name)
497 addNewTraceVal<VcdTraceValFxval<sc_dt::sc_fxval_fast>>(
v,
name);
500 template <
typename T>
510 const int w = this->
width();
513 for (
int i =
w - 1;
i >= 0;
i--)
514 str += this->
value()[
i] ?
'1' :
'0';
523 addNewTraceVal<VcdTraceValFxnum<::sc_dt::sc_fxnum>>(
v,
name);
527 const std::string &
name)
529 addNewTraceVal<VcdTraceValFxnum<::sc_dt::sc_fxnum_fast>>(
v,
name);
537 std::string
vcdType()
override {
return "event"; }
552 addNewTraceVal<VcdTraceValEvent>(
v,
name);
563 std::string
vcdType()
override {
return "time"; }
588 addNewTraceVal<VcdTraceValTime>(
v,
name);
591 template <
typename T>
600 const int w = this->
width();
605 static_cast<uint64_t
>(this->
value()) & ::
mask(
sizeof(T) * 8);
608 for (
int i = 0;
i <
w;
i++)
611 for (
int i = 0;
i <
w;
i++)
623 addNewTraceVal<VcdTraceValInt<unsigned char>>(
v,
name,
width);
628 addNewTraceVal<VcdTraceValInt<char>>(
v,
name,
width);
634 addNewTraceVal<VcdTraceValInt<unsigned short>>(
v,
name,
width);
639 addNewTraceVal<VcdTraceValInt<short>>(
v,
name,
width);
645 addNewTraceVal<VcdTraceValInt<unsigned int>>(
v,
name,
width);
650 addNewTraceVal<VcdTraceValInt<int>>(
v,
name,
width);
656 addNewTraceVal<VcdTraceValInt<unsigned long>>(
v,
name,
width);
661 addNewTraceVal<VcdTraceValInt<long>>(
v,
name,
width);
668 addNewTraceVal<VcdTraceValInt<sc_dt::int64>>(
v,
name,
width);
674 addNewTraceVal<VcdTraceValInt<sc_dt::uint64>>(
v,
name,
width);
679 const char **literals)
689 addNewTraceVal<VcdTraceValInt<unsigned int>>(
v,
name,
bits);
695 stream() <<
"$comment" << std::endl;
696 stream() << comment << std::endl;
697 stream() <<
"$end" << std::endl << std::endl;