aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-04-15 14:16:50 +0000
committerGitHub <noreply@github.com>2020-04-15 14:16:50 +0000
commit2d436bc4f1f3ca574a89312caf0bf94b81b37f7a (patch)
tree8d39249ab05067b73235e2d03ae0ef2aa0adabe9 /frontends
parent43cc6bd8a10b47759f4d0d1916d3b7ad108e4486 (diff)
parent2106f78bb14eab6c234a0a367ec32ff6680fc6d9 (diff)
downloadyosys-2d436bc4f1f3ca574a89312caf0bf94b81b37f7a.tar.gz
yosys-2d436bc4f1f3ca574a89312caf0bf94b81b37f7a.tar.bz2
yosys-2d436bc4f1f3ca574a89312caf0bf94b81b37f7a.zip
Merge pull request #1918 from whitequark/simplify-improve_enum
ast/simplify: improve enum handling
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ast/simplify.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index ced5e5cf9..cb89f58ba 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -931,9 +931,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
);
}
//start building attribute string
- std::string enum_item_str = "\\enum_";
- enum_item_str.append(std::to_string(width));
- enum_item_str.append("_");
+ std::string enum_item_str = "\\enum_value_";
//get enum item value
if(enum_item->children[0]->type != AST_CONSTANT){
log_error("expected const, got %s for %s (%s)\n",
@@ -941,8 +939,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
enum_item->str.c_str(), enum_node->str.c_str()
);
}
- int val = enum_item->children[0]->asInt(is_signed);
- enum_item_str.append(std::to_string(val));
+ RTLIL::Const val = enum_item->children[0]->bitsAsConst(width, is_signed);
+ enum_item_str.append(val.as_string());
//set attribute for available val to enum item name mappings
attributes[enum_item_str.c_str()] = mkconst_str(enum_item->str);
}