fix damage from pr #348

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2025-12-04 19:04:57 -07:00
parent 01ad7e5ed3
commit 8b8b86bb66
2 changed files with 16 additions and 23 deletions

View File

@ -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();

View File

@ -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);
}
}
}