diff options
author | Eddie Hung <eddie@fpgeh.com> | 2020-04-02 12:27:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-02 12:27:10 -0700 |
commit | cf716e1fff53fe4633dce98ebca04fe36c283106 (patch) | |
tree | bc261aa55d3fac92f2ac9e90d6085d100c0c1a86 | |
parent | 5f662b1c43052bf48558be12ff0013f2e39ae9ab (diff) | |
parent | c22fb76664559abb0bac838e03a34b140d3146ee (diff) | |
download | yosys-cf716e1fff53fe4633dce98ebca04fe36c283106.tar.gz yosys-cf716e1fff53fe4633dce98ebca04fe36c283106.tar.bz2 yosys-cf716e1fff53fe4633dce98ebca04fe36c283106.zip |
Merge pull request #1853 from YosysHQ/eddie/fix_dynslice
ast: cap dynamic range select to size of signal, suppresses warnings
-rw-r--r-- | frontends/ast/simplify.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 45c796b07..b87af0f8c 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); } |