aboutsummaryrefslogtreecommitdiffstats
path: root/passes
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-06-04 10:46:54 +0000
committerwhitequark <whitequark@whitequark.org>2020-06-08 20:19:41 +0000
commitfbb346ea91a04f2feaf6fa96770fe0cd57020e75 (patch)
tree9cf9e3b9020ae24cc9f8219f9b985c8e3589f7a1 /passes
parent8d821dbbdb3ba68d4cd0fdb0d5857e77725275b9 (diff)
downloadyosys-fbb346ea91a04f2feaf6fa96770fe0cd57020e75.tar.gz
yosys-fbb346ea91a04f2feaf6fa96770fe0cd57020e75.tar.bz2
yosys-fbb346ea91a04f2feaf6fa96770fe0cd57020e75.zip
flatten: preserve original object names via hdlname attribute.
Diffstat (limited to 'passes')
-rw-r--r--passes/techmap/flatten.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/passes/techmap/flatten.cc b/passes/techmap/flatten.cc
index e913b3059..a2794541a 100644
--- a/passes/techmap/flatten.cc
+++ b/passes/techmap/flatten.cc
@@ -47,10 +47,21 @@ IdString map_name(RTLIL::Cell *cell, T *object)
}
template<class T>
-void map_attributes(RTLIL::Cell *cell, T *object)
+void map_attributes(RTLIL::Cell *cell, T *object, IdString orig_object_name)
{
- if (object->attributes.count(ID::src))
+ if (object->has_attribute(ID::src))
object->add_strpool_attribute(ID::src, cell->get_strpool_attribute(ID::src));
+
+ // Preserve original names via the hdlname attribute, but only for objects with a fully public name.
+ if (cell->name[0] == '\\' && (object->has_attribute(ID::hdlname) || orig_object_name[0] == '\\')) {
+ std::vector<std::string> hierarchy;
+ if (object->has_attribute(ID::hdlname))
+ hierarchy = object->get_hdlname_attribute();
+ else
+ hierarchy.push_back(orig_object_name.str().substr(1));
+ hierarchy.insert(hierarchy.begin(), cell->name.str().substr(1));
+ object->set_hdlname_attribute(hierarchy);
+ }
}
void map_sigspec(const dict<RTLIL::Wire*, RTLIL::Wire*> &map, RTLIL::SigSpec &sig, RTLIL::Module *into = nullptr)
@@ -81,7 +92,7 @@ struct FlattenWorker
dict<IdString, IdString> memory_map;
for (auto &tpl_memory_it : tpl->memories) {
RTLIL::Memory *new_memory = module->addMemory(map_name(cell, tpl_memory_it.second), tpl_memory_it.second);
- map_attributes(cell, new_memory);
+ map_attributes(cell, new_memory, tpl_memory_it.second->name);
memory_map[tpl_memory_it.first] = new_memory->name;
design->select(module, new_memory);
}
@@ -111,14 +122,14 @@ struct FlattenWorker
new_wire->port_id = false;
}
- map_attributes(cell, new_wire);
+ map_attributes(cell, new_wire, tpl_wire->name);
wire_map[tpl_wire] = new_wire;
design->select(module, new_wire);
}
for (auto tpl_cell : tpl->cells()) {
RTLIL::Cell *new_cell = module->addCell(map_name(cell, tpl_cell), tpl_cell);
- map_attributes(cell, new_cell);
+ map_attributes(cell, new_cell, tpl_cell->name);
if (new_cell->type.in(ID($memrd), ID($memwr), ID($meminit))) {
IdString memid = new_cell->getParam(ID::MEMID).decode_string();
new_cell->setParam(ID::MEMID, Const(memory_map.at(memid).str()));