From fbb346ea91a04f2feaf6fa96770fe0cd57020e75 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 4 Jun 2020 10:46:54 +0000 Subject: flatten: preserve original object names via hdlname attribute. --- kernel/rtlil.cc | 16 ++++++++++++++++ kernel/rtlil.h | 3 +++ 2 files changed, 19 insertions(+) (limited to 'kernel') diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 335c48456..b876862c8 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -339,6 +339,22 @@ pool RTLIL::AttrObject::get_strpool_attribute(RTLIL::IdString id) const return data; } +void RTLIL::AttrObject::set_hdlname_attribute(const vector &hierarchy) +{ + string attrval; + for (const auto &ident : hierarchy) { + if (!attrval.empty()) + attrval += " "; + attrval += ident; + } + set_string_attribute(ID::hdlname, attrval); +} + +vector RTLIL::AttrObject::get_hdlname_attribute() const +{ + return split_tokens(get_string_attribute(ID::hdlname), " "); +} + bool RTLIL::Selection::selected_module(RTLIL::IdString mod_name) const { if (full_selection) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 86b4e25b6..f751bdce4 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -682,6 +682,9 @@ struct RTLIL::AttrObject std::string get_src_attribute() const { return get_string_attribute(ID::src); } + + void set_hdlname_attribute(const vector &hierarchy); + vector get_hdlname_attribute() const; }; struct RTLIL::SigChunk -- cgit v1.2.3