summaryrefslogtreecommitdiff
path: root/frontends/ast/simplify.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-02-01 13:50:23 +0100
committerClifford Wolf <clifford@clifford.at>2014-02-01 13:50:23 +0100
commitd06258f74f724ea3ed26ec9341dd64a51e320ccf (patch)
treecb0a5af86db1dff05686490bdb1ed5908471d2e2 /frontends/ast/simplify.cc
parent1e2440e7ed6979bdee2f80116d6c3a429b604e25 (diff)
Added constant size expression support of sized constants
Diffstat (limited to 'frontends/ast/simplify.cc')
-rw-r--r--frontends/ast/simplify.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index 5a2d1ae6..f19befe2 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -258,6 +258,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
}
break;
+ case AST_TO_BITS:
case AST_TO_SIGNED:
case AST_TO_UNSIGNED:
case AST_CONCAT:
@@ -442,6 +443,17 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
goto apply_newNode;
}
+ // evaluate TO_BITS nodes
+ if (type == AST_TO_BITS) {
+ if (children[0]->type != AST_CONSTANT)
+ log_error("Left operand of to_bits expression is not constant at %s:%d!\n", filename.c_str(), linenum);
+ if (children[1]->type != AST_CONSTANT)
+ log_error("Right operand of to_bits expression is not constant at %s:%d!\n", filename.c_str(), linenum);
+ RTLIL::Const new_value = children[1]->bitsAsConst(children[0]->bitsAsConst().as_int(), children[1]->is_signed);
+ newNode = mkconst_bits(new_value.bits, children[1]->is_signed);
+ goto apply_newNode;
+ }
+
// annotate constant ranges
if (type == AST_RANGE) {
bool old_range_valid = range_valid;