aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast
diff options
context:
space:
mode:
authorJeff Wang <jjj11x@gmail.com>2020-01-16 17:05:45 -0500
committerJeff Wang <jeffrey.wang@ll.mit.edu>2020-01-16 18:13:30 -0500
commit549deb637305a4bf4c9e2c58388b149ee8fa6089 (patch)
treeaffbd50aab4443fe292c8c3f19691bed984d3df8 /frontends/ast
parent41a0a93dcc489fbba2624006ef52a3d0f565ee25 (diff)
downloadyosys-549deb637305a4bf4c9e2c58388b149ee8fa6089.tar.gz
yosys-549deb637305a4bf4c9e2c58388b149ee8fa6089.tar.bz2
yosys-549deb637305a4bf4c9e2c58388b149ee8fa6089.zip
fix enum in generate blocks
Diffstat (limited to 'frontends/ast')
-rw-r--r--frontends/ast/simplify.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index 2e1b1e404..c96f5d549 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -3097,6 +3097,26 @@ void AstNode::expand_genblock(std::string index_var, std::string prefix, std::ma
child->str = new_name;
current_scope[new_name] = child;
}
+ if (child->type == AST_ENUM){
+ for (auto enode : child->children){
+ log_assert(enode->type == AST_ENUM_ITEM);
+ if (backup_name_map.size() == 0)
+ backup_name_map = name_map;
+ std::string new_name = prefix[0] == '\\' ? prefix.substr(1) : prefix;
+ size_t pos = enode->str.rfind('.');
+ if (pos == std::string::npos)
+ pos = enode->str[0] == '\\' && prefix[0] == '\\' ? 1 : 0;
+ else
+ pos = pos + 1;
+ new_name = enode->str.substr(0, pos) + new_name + enode->str.substr(pos);
+ if (new_name[0] != '$' && new_name[0] != '\\')
+ new_name = prefix[0] + new_name;
+ name_map[enode->str] = new_name;
+
+ enode->str = new_name;
+ current_scope[new_name] = enode;
+ }
+ }
}
for (size_t i = 0; i < children.size(); i++) {