cxxrtl: add debug_item::{get,set}.
authorwhitequark <whitequark@whitequark.org>
Sun, 18 Jul 2021 06:07:27 +0000 (06:07 +0000)
committerwhitequark <whitequark@whitequark.org>
Sun, 18 Jul 2021 06:20:45 +0000 (06:20 +0000)
Fixes #2877.

backends/cxxrtl/cxxrtl.h

index 0e55c46c223986aea5bdf57009f9c671bd9ddebd..4552a01254d3cdafcc2748228447f29a50fa783e 100644 (file)
@@ -999,6 +999,22 @@ struct debug_item : ::cxxrtl_object {
                next    = nullptr;
                outline = &group;
        }
+
+       template<size_t Bits, class IntegerT>
+       IntegerT get() const {
+               assert(width == Bits && depth == 1);
+               value<Bits> item;
+               std::copy(curr, curr + value<Bits>::chunks, item.data);
+               return item.template get<IntegerT>();
+       }
+
+       template<size_t Bits, class IntegerT>
+       void set(IntegerT other) const {
+               assert(width == Bits && depth == 1);
+               value<Bits> item;
+               item.template set<IntegerT>(other);
+               std::copy(item.data, item.data + value<Bits>::chunks, next);
+       }
 };
 static_assert(std::is_standard_layout<debug_item>::value, "debug_item is not compatible with C layout");