aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-04-18 03:43:15 +0000
committerwhitequark <whitequark@whitequark.org>2020-04-18 03:47:28 +0000
commit41421f5dca3587172c870b548921331398a06c19 (patch)
treecb96823ce1559c8fd4f287e9ebb6572145ed1fd8 /frontends
parent115fc261e60ebcd0456e26aac452942137db1ca9 (diff)
downloadyosys-41421f5dca3587172c870b548921331398a06c19.tar.gz
yosys-41421f5dca3587172c870b548921331398a06c19.tar.bz2
yosys-41421f5dca3587172c870b548921331398a06c19.zip
ast, rpc: record original name of $paramod\* as \hdlname attribute.
The $paramod name mangling is not invertible (the \ character, which separates the module name from the parameters, is valid in the module name itself), which does not stop people from trying to invert it. This commit makes it easy to invert the name mangling by storing the original name explicitly, and fixes the firrtl backend to use the newly introduced attribute.
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ast/ast.cc3
-rw-r--r--frontends/rpc/rpc_frontend.cc2
2 files changed, 5 insertions, 0 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc
index 245a53611..de741a506 100644
--- a/frontends/ast/ast.cc
+++ b/frontends/ast/ast.cc
@@ -1565,6 +1565,9 @@ std::string AstModule::derive_common(RTLIL::Design *design, const dict<RTLIL::Id
rewritten.reserve(GetSize(parameters));
AstNode *new_ast = ast->clone();
+ if (!new_ast->attributes.count(ID::hdlname))
+ new_ast->attributes[ID::hdlname] = AstNode::mkconst_str(stripped_name);
+
para_counter = 0;
for (auto child : new_ast->children) {
if (child->type != AST_PARAMETER)
diff --git a/frontends/rpc/rpc_frontend.cc b/frontends/rpc/rpc_frontend.cc
index a23f7548e..46ee6a733 100644
--- a/frontends/rpc/rpc_frontend.cc
+++ b/frontends/rpc/rpc_frontend.cc
@@ -217,6 +217,8 @@ struct RpcModule : RTLIL::Module {
module.second->name = mangled_name;
module.second->design = design;
module.second->attributes.erase(ID::top);
+ if (!module.second->has_attribute(ID::hdlname))
+ module.second->set_string_attribute(ID::hdlname, module.first.str());
design->modules_[mangled_name] = module.second;
derived_design->modules_.erase(module.first);
}