From fa04b1967076d8a97bdd8802664fd2d1a2424be2 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 11 Jun 2020 12:42:37 +0000 Subject: cxxrtl: expose RTLIL::{Wire,Memory}->start_offset in debug info. --- backends/cxxrtl/cxxrtl.h | 84 +++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 36 deletions(-) (limited to 'backends/cxxrtl/cxxrtl.h') diff --git a/backends/cxxrtl/cxxrtl.h b/backends/cxxrtl/cxxrtl.h index ce21cc1e6..b8acd02df 100644 --- a/backends/cxxrtl/cxxrtl.h +++ b/backends/cxxrtl/cxxrtl.h @@ -734,71 +734,83 @@ struct debug_item : ::cxxrtl_object { debug_item(const ::cxxrtl_object &object) : cxxrtl_object(object) {} template - debug_item(value &item) { + debug_item(value &item, size_t lsb_offset = 0) { static_assert(sizeof(item) == value::chunks * sizeof(chunk_t), "value is not compatible with C layout"); - type = VALUE; - width = Bits; - depth = 1; - curr = item.data; - next = item.data; + type = VALUE; + width = Bits; + lsb_at = lsb_offset; + depth = 1; + zero_at = 0; + curr = item.data; + next = item.data; } template - debug_item(const value &item) { + debug_item(const value &item, size_t lsb_offset = 0) { static_assert(sizeof(item) == value::chunks * sizeof(chunk_t), "value is not compatible with C layout"); - type = VALUE; - width = Bits; - depth = 1; - curr = const_cast(item.data); - next = nullptr; + type = VALUE; + width = Bits; + lsb_at = lsb_offset; + depth = 1; + zero_at = 0; + curr = const_cast(item.data); + next = nullptr; } template - debug_item(wire &item) { + debug_item(wire &item, size_t lsb_offset = 0) { static_assert(sizeof(item.curr) == value::chunks * sizeof(chunk_t) && sizeof(item.next) == value::chunks * sizeof(chunk_t), "wire is not compatible with C layout"); - type = WIRE; - width = Bits; - depth = 1; - curr = item.curr.data; - next = item.next.data; + type = WIRE; + width = Bits; + lsb_at = lsb_offset; + depth = 1; + zero_at = 0; + curr = item.curr.data; + next = item.next.data; } template - debug_item(memory &item) { + debug_item(memory &item, size_t zero_offset = 0) { static_assert(sizeof(item.data[0]) == value::chunks * sizeof(chunk_t), "memory is not compatible with C layout"); - type = MEMORY; - width = Width; - depth = item.data.size(); - curr = item.data.empty() ? nullptr : item.data[0].data; - next = nullptr; + type = MEMORY; + width = Width; + lsb_at = 0; + depth = item.data.size(); + zero_at = zero_offset; + curr = item.data.empty() ? nullptr : item.data[0].data; + next = nullptr; } template - debug_item(debug_alias, const value &item) { + debug_item(debug_alias, const value &item, size_t lsb_offset = 0) { static_assert(sizeof(item) == value::chunks * sizeof(chunk_t), "value is not compatible with C layout"); - type = ALIAS; - width = Bits; - depth = 1; - curr = const_cast(item.data); - next = nullptr; + type = ALIAS; + width = Bits; + lsb_at = lsb_offset; + depth = 1; + zero_at = 0; + curr = const_cast(item.data); + next = nullptr; } template - debug_item(debug_alias, const wire &item) { + debug_item(debug_alias, const wire &item, size_t lsb_offset = 0) { static_assert(sizeof(item.curr) == value::chunks * sizeof(chunk_t) && sizeof(item.next) == value::chunks * sizeof(chunk_t), "wire is not compatible with C layout"); - type = ALIAS; - width = Bits; - depth = 1; - curr = const_cast(item.curr.data); - next = nullptr; + type = ALIAS; + width = Bits; + lsb_at = lsb_offset; + depth = 1; + zero_at = 0; + curr = const_cast(item.curr.data); + next = nullptr; } }; static_assert(std::is_standard_layout::value, "debug_item is not compatible with C layout"); -- cgit v1.2.3 From 8d712b1095c85cd34f8f4d33798d6a7f1f6c5a2d Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 11 Jun 2020 13:31:16 +0000 Subject: cxxrtl: handle multipart signals. This avoids losing design visibility when using the `splitnets` pass. --- backends/cxxrtl/cxxrtl.h | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'backends/cxxrtl/cxxrtl.h') diff --git a/backends/cxxrtl/cxxrtl.h b/backends/cxxrtl/cxxrtl.h index b8acd02df..43546bd3c 100644 --- a/backends/cxxrtl/cxxrtl.h +++ b/backends/cxxrtl/cxxrtl.h @@ -815,7 +815,38 @@ struct debug_item : ::cxxrtl_object { }; static_assert(std::is_standard_layout::value, "debug_item is not compatible with C layout"); -typedef std::map debug_items; +struct debug_items { + std::map> table; + + void add(const std::string &name, debug_item &&item) { + std::vector &parts = table[name]; + parts.emplace_back(item); + std::sort(parts.begin(), parts.end(), + [](const debug_item &a, const debug_item &b) { + return a.lsb_at < b.lsb_at; + }); + } + + size_t count(const std::string &name) const { + if (table.count(name) == 0) + return 0; + return table.at(name).size(); + } + + const std::vector &parts_at(const std::string &name) const { + return table.at(name); + } + + const debug_item &at(const std::string &name) const { + const std::vector &parts = table.at(name); + assert(parts.size() == 1); + return parts.at(0); + } + + const debug_item &operator [](const std::string &name) const { + return at(name); + } +}; struct module { module() {} -- cgit v1.2.3