aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorEddie Hung <eddie@fpgeh.com>2020-04-01 09:59:23 -0700
committerEddie Hung <eddie@fpgeh.com>2020-04-01 09:59:23 -0700
commitc22fb76664559abb0bac838e03a34b140d3146ee (patch)
tree933838e49bb1b2eb95f9db023e44af144f0d47f6 /frontends
parent5132f4099b0a09b542cdb32c3bcdee24917ca5f1 (diff)
downloadyosys-c22fb76664559abb0bac838e03a34b140d3146ee.tar.gz
yosys-c22fb76664559abb0bac838e03a34b140d3146ee.tar.bz2
yosys-c22fb76664559abb0bac838e03a34b140d3146ee.zip
ast: cap dynamic range select to size of signal, suppresses warnings
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ast/simplify.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index 073b9cbbe..26c1cc7a9 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -1732,8 +1732,9 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
AstNode *cond = new AstNode(AST_COND, mkconst_int(start_bit, true));
AstNode *lvalue = children[0]->clone();
lvalue->delete_children();
+ int end_bit = std::min(start_bit+result_width,source_width) - 1;
lvalue->children.push_back(new AstNode(AST_RANGE,
- mkconst_int(start_bit+result_width-1, true), mkconst_int(start_bit, true)));
+ mkconst_int(end_bit, true), mkconst_int(start_bit, true)));
cond->children.push_back(new AstNode(AST_BLOCK, new AstNode(type, lvalue, children[1]->clone())));
newNode->children.push_back(cond);
}