diff --git a/power/VcdParse.cc b/power/VcdParse.cc index c1dcc642..071fcdf7 100644 --- a/power/VcdParse.cc +++ b/power/VcdParse.cc @@ -232,28 +232,15 @@ VcdParse::parseVarValues() reader_->varAppendValue(id, time_, char0); } else if (char0 == 'B') { - char char1 = toupper(token[1]); - if (char1 == 'X' - || char1 == 'U' - || char1 == 'Z') { - string id = getToken(); - if (!reader_->varIdValid(id)) - report_->fileError(806, filename_, stmt_line_, - "unknown variable %s", id.c_str()); - // Bus mixed 0/1/X/U not supported. - reader_->varAppendValue(id, time_, char1); - } + string bus_value = token.substr(1); + string id = getToken(); + if (!reader_->varIdValid(id)) + report_->fileError(807, filename_, stmt_line_, + "unknown variable %s", id.c_str()); else { - string bus_value = token.substr(1); - string id = getToken(); - if (!reader_->varIdValid(id)) - report_->fileError(807, filename_, stmt_line_, - "unknown variable %s", id.c_str()); - else { - // Reverse the bus value to match the bit order in the VCD file. - std::reverse(bus_value.begin(), bus_value.end()); - reader_->varAppendBusValue(id, time_, bus_value); - } + // Reverse the bus value to match the bit order in the VCD file. + std::reverse(bus_value.begin(), bus_value.end()); + reader_->varAppendBusValue(id, time_, bus_value); } } token = getToken(); diff --git a/power/VcdReader.cc b/power/VcdReader.cc index 81874e0a..f208c8ad 100644 --- a/power/VcdReader.cc +++ b/power/VcdReader.cc @@ -335,8 +335,15 @@ VcdCountReader::varAppendBusValue(const string &id, if (itr != vcd_count_map_.end()) { VcdCounts &vcd_counts = itr->second; for (size_t bit_idx = 0; bit_idx < vcd_counts.size(); bit_idx++) { - char bit_value = bus_value[bit_idx]; + char bit_value; + if (bus_value.size() == 1) + bit_value = bus_value[0]; + else if (bit_idx < bus_value.size()) + bit_value = bus_value[bit_idx]; + else + bit_value = '0'; VcdCount &vcd_count = vcd_counts[bit_idx]; + vcd_count.incrCounts(time, bit_value); if (debug_->check("read_vcd", 3)) { for (const Pin *pin : vcd_count.pins()) { debugPrint(debug_, "read_vcd", 3, "%s time %" PRIu64 " value %c", @@ -345,7 +352,6 @@ VcdCountReader::varAppendBusValue(const string &id, bit_value); } } - vcd_count.incrCounts(time, bit_value); } } }