58cleanName(std::string
name)
60 for (
int i = 0;
i <
name.length();
i++) {
63 else if (
name[i] ==
']')
79 const char first = orig[0];
81 if (first !=
'z' && first !=
'x' && first !=
'0')
84 const char *res = orig;
85 while (*++res == first) {}
87 if (first !=
'0' || *res !=
'1')
122 os << rep <<
vcdName() << std::endl;;
137 virtual std::string
vcdType() {
return "wire"; }
139 virtual void output(std::ostream &os) = 0;
145 size_t pos =
name.find_first_of(
'.');
146 if (pos == std::string::npos) {
149 std::string sname =
name.substr(0, pos);
150 auto it =
scopes.find(sname);
153 it->second->addValue(
name.substr(pos + 1), value);
160 os <<
"$scope module " <<
name <<
" $end" << std::endl;
163 const std::string &
name = p.first;
166 int w = value->
width();
175 std::string clean_name = cleanName(
name);
186 p.second->output(p.first, os);
188 os <<
"$upscope $end" << std::endl;
217 }
while (carry && pos >= 0);
228 stream() <<
"$date" << std::endl;
231 struct tm *p_tm = localtime(&long_time);
232 stream() << std::put_time(p_tm,
" %b %d, %Y %H:%M:%S\n");
233 stream() <<
"$end" << std::endl << std::endl;
236 stream() <<
"$version" << std::endl;
238 stream() <<
"$end" << std::endl << std::endl;
241 stream() <<
"$timescale" << std::endl;
244 stream() <<
"$end" << std::endl << std::endl;
251 stream() <<
"$enddefinitions $end" << std::endl << std::endl;
255 std::string timedump_comment =
257 "%g sec = %g timescale units.",
264 stream() <<
"$dumpvars" << std::endl;
267 stream() <<
"$end" << std::endl << std::endl;
310 bool time_printed =
false;
334 printVal(os, this->
value() ?
"1" :
"0");
341 addNewTraceVal<VcdTraceValBool>(v,
name);
350 std::string
vcdType()
override {
return "real"; }
362 addNewTraceVal<VcdTraceValFloat<float>>(v,
name);
367 addNewTraceVal<VcdTraceValFloat<double>>(v,
name);
379 scLogicToVcdState(
value().to_char()),
389 addNewTraceVal<VcdTraceValScLogic>(v,
name);
409 const int w = this->
width();
412 for (
int i = w - 1; i >= 0; i--)
413 str += this->
value()[i].to_bool() ?
'1' :
'0';
421 const std::string &
name)
423 addNewTraceVal<VcdTraceValFinite<sc_dt::sc_int_base>>(v,
name);
427 const std::string &
name)
429 addNewTraceVal<VcdTraceValFinite<sc_dt::sc_uint_base>>(v,
name);
435 addNewTraceVal<VcdTraceValFinite<sc_dt::sc_signed>>(v,
name);
439 const std::string &
name)
441 addNewTraceVal<VcdTraceValFinite<sc_dt::sc_unsigned>>(v,
name);
467 addNewTraceVal<VcdTraceValLogic<::sc_dt::sc_bv_base>>(v,
name);
472 addNewTraceVal<VcdTraceValLogic<::sc_dt::sc_lv_base>>(v,
name);
481 std::string
vcdType()
override {
return "real"; }
494 addNewTraceVal<VcdTraceValFxval<sc_dt::sc_fxval>>(v,
name);
498 const std::string &
name)
500 addNewTraceVal<VcdTraceValFxval<sc_dt::sc_fxval_fast>>(v,
name);
513 const int w = this->
width();
516 for (
int i = w - 1; i >= 0; i--)
517 str += this->
value()[i] ?
'1' :
'0';
526 addNewTraceVal<VcdTraceValFxnum<::sc_dt::sc_fxnum>>(v,
name);
530 const std::string &
name)
532 addNewTraceVal<VcdTraceValFxnum<::sc_dt::sc_fxnum_fast>>(v,
name);
540 std::string
vcdType()
override {
return "event"; }
555 addNewTraceVal<VcdTraceValEvent>(v,
name);
566 std::string
vcdType()
override {
return "time"; }
581 const uint64_t val =
value().value();
591 addNewTraceVal<VcdTraceValTime>(v,
name);
603 const int w = this->
width();
611 for (
int i = 0; i < w; i++)
614 for (
int i = 0; i < w; i++)
615 str[i] =
gem5::bits(val, w - i - 1) ?
'1' :
'0';
626 addNewTraceVal<VcdTraceValInt<unsigned char>>(v,
name, width);
631 addNewTraceVal<VcdTraceValInt<char>>(v,
name, width);
637 addNewTraceVal<VcdTraceValInt<unsigned short>>(v,
name, width);
642 addNewTraceVal<VcdTraceValInt<short>>(v,
name, width);
648 addNewTraceVal<VcdTraceValInt<unsigned int>>(v,
name, width);
653 addNewTraceVal<VcdTraceValInt<int>>(v,
name, width);
659 addNewTraceVal<VcdTraceValInt<unsigned long>>(v,
name, width);
664 addNewTraceVal<VcdTraceValInt<long>>(v,
name, width);
671 addNewTraceVal<VcdTraceValInt<sc_dt::int64>>(v,
name, width);
677 addNewTraceVal<VcdTraceValInt<sc_dt::uint64>>(v,
name, width);
682 const char **literals)
689 while (count >> bits)
692 addNewTraceVal<VcdTraceValInt<unsigned int>>(v,
name, bits);
698 stream() <<
"$comment" << std::endl;
699 stream() << comment << std::endl;
700 stream() <<
"$end" << std::endl << std::endl;
static sc_time from_value(sc_dt::uint64)
void writeComment(const std::string &comment) override
void addTraceVal(const bool *v, const std::string &name) override
char _nextName[NextNameChars+1]
static const int NextNameChars
std::vector< VcdTraceValBase * > traceVals
gem5::Tick lastPrintedTime
std::string nextSignalName()
void trace(bool delta) override
void addValue(const std::string &name, VcdTraceValBase *value)
std::map< std::string, VcdTraceScope * > scopes
std::vector< std::pair< std::string, VcdTraceValBase * > > values
void output(const std::string &name, std::ostream &os)
const char * stripLeadingBits(const char *orig)
char scLogicToVcdState(char in)
VcdTraceValBase(int width)
virtual std::string vcdType()
void printVal(std::ostream &os, const std::string &rep)
void vcdName(const std::string &vcd_name)
const std::string & vcdName()
virtual void output(std::ostream &os)=0
void output(std::ostream &os) override
void output(std::ostream &os) override
std::string vcdType() override
void output(std::ostream &os) override
void output(std::ostream &os) override
std::string vcdType() override
void output(std::ostream &os) override
void output(std::ostream &os) override
std::string vcdType() override
void output(std::ostream &os) override
void output(std::ostream &os) override
void output(std::ostream &os) override
std::string vcdType() override
void output(std::ostream &os) override
static const int TimeWidth
VcdTraceVal(const T *t, const std::string &vcd_name, int width)
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
double s
These variables equal the number of ticks in the unit of time they're named after in a double.
uint64_t Tick
Tick count type.
std::string csprintf(const char *format, const Args &...args)
void ccprintf(cp::Print &print)
const char * sc_version()
#define SC_REPORT_ERROR(msg_type, msg)
const std::string & name()