diff --git a/include/vcppd/scope.h b/include/vcppd/scope.h index da676dd..1aa6026 100644 --- a/include/vcppd/scope.h +++ b/include/vcppd/scope.h @@ -11,6 +11,7 @@ namespace vcppd template class Scope { friend T; + friend Scope; public: Scope(const Scope&) = delete; @@ -18,6 +19,7 @@ public: Scope scope(const std::string& name) { + parent.scope(name); return Scope(name, *this); } diff --git a/src/vcd.cpp b/src/vcd.cpp index abbff30..e34d6e5 100644 --- a/src/vcd.cpp +++ b/src/vcd.cpp @@ -27,7 +27,7 @@ void Vcd::tick() for (int i = 0; i < entry.size; i++) { uint8_t byte; - memcpy(&byte, static_cast(entry.ref), 1); + memcpy(&byte, static_cast(entry.ref) + i, 1); stream << std::format("{0:b}", byte); } stream << " " << name << std::endl; diff --git a/test/test.cpp b/test/test.cpp index 1a6c84f..989e732 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -4,11 +4,15 @@ int main(int argc, char** argv) { uint8_t eae = 0; uint8_t eae2 = 0; + uint16_t eae3 = 1; auto vcd = vcppd::Builder(std::cout) .scope("TOP") .trace("eae", eae) .trace("eae2", eae2) + .scope("MIDDLE") + .trace("eae3", eae3) + .unscope() .unscope() .build(); for (int i = 0; i < 10; i++) @@ -16,6 +20,7 @@ int main(int argc, char** argv) vcd.tick(); eae += 1; eae2 += 2; + eae3 *= 2; } return 0;