From d8ce26a5bad847521f09c7d31325c9d63f3e4a69 Mon Sep 17 00:00:00 2001 From: Catherine Date: Tue, 13 Feb 2024 18:20:26 +0000 Subject: [PATCH 1/2] read_verilog: correctly format `hdlname` attribute value. The leading slash is not a part of the attribute as it only concerns public values. --- frontends/ast/ast.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index ead79fd95..996f6715d 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -1820,7 +1820,7 @@ std::string AstModule::derive_common(RTLIL::Design *design, const dictclone(); if (!new_ast->attributes.count(ID::hdlname)) - new_ast->set_attribute(ID::hdlname, AstNode::mkconst_str(stripped_name)); + new_ast->set_attribute(ID::hdlname, AstNode::mkconst_str(stripped_name.substr(1))); para_counter = 0; for (auto child : new_ast->children) { From b16f4900fd97308134d27b32adaf09ae6204f801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Tue, 13 Feb 2024 21:38:41 +0100 Subject: [PATCH 2/2] ast/simplify: Interpret hdlname w/o expecting backslash --- frontends/ast/simplify.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 96296aeb8..43a4e03a2 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -5662,7 +5662,7 @@ std::string AstNode::try_pop_module_prefix() const if (current_scope.count(new_str)) { std::string prefix = str.substr(0, pos); auto it = current_scope_ast->attributes.find(ID::hdlname); - if ((it != current_scope_ast->attributes.end() && it->second->str == prefix) + if ((it != current_scope_ast->attributes.end() && it->second->str == prefix.substr(1)) || prefix == current_scope_ast->str) return new_str; }