Fix endianness and padding issues

This commit is contained in:
shylie 2026-03-25 01:41:42 -04:00
parent 2e89bebfe6
commit 83ff5b450c

View File

@ -24,11 +24,11 @@ void Vcd::tick()
for (const auto& [name, entry] : variables) for (const auto& [name, entry] : variables)
{ {
stream << "b"; stream << "b";
for (int i = 0; i < entry.size; i++) for (int i = entry.size - 1; i >= 0; i--)
{ {
uint8_t byte; uint8_t byte;
memcpy(&byte, static_cast<const uint8_t*>(entry.ref) + i, 1); memcpy(&byte, static_cast<const uint8_t*>(entry.ref) + i, 1);
stream << std::format("{0:b}", byte); stream << std::format("{:0>8b}", byte);
} }
stream << " " << name << std::endl; stream << " " << name << std::endl;
} }