aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddie Hung <eddie@fpgeh.com>2019-12-11 16:26:26 -0800
committerEddie Hung <eddie@fpgeh.com>2019-12-11 16:52:37 -0800
commitaf36943cb979f9e70cb2254090560cf346c11af0 (patch)
tree6112ed221b27484a143cce25860414a9e34ecf43
parent151f7533e89d1a6db9c52b3c5d77adb2089db366 (diff)
downloadyosys-af36943cb979f9e70cb2254090560cf346c11af0.tar.gz
yosys-af36943cb979f9e70cb2254090560cf346c11af0.tar.bz2
yosys-af36943cb979f9e70cb2254090560cf346c11af0.zip
Preserve size of $genval$-s in for loops
-rw-r--r--frontends/ast/simplify.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index 44fd32cdc..8cbf5a6e2 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -1198,6 +1198,15 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
varbuf = new AstNode(AST_LOCALPARAM, varbuf);
varbuf->str = init_ast->children[0]->str;
+ auto resolved = current_scope.at(init_ast->children[0]->str);
+ if (resolved->range_valid) {
+ varbuf->range_left = resolved->range_left;
+ varbuf->range_right = resolved->range_right;
+ varbuf->range_swapped = resolved->range_swapped;
+ varbuf->range_valid = resolved->range_valid;
+ log_dump(varbuf->range_left, varbuf->range_right);
+ }
+
AstNode *backup_scope_varbuf = current_scope[varbuf->str];
current_scope[varbuf->str] = varbuf;
@@ -2998,6 +3007,14 @@ void AstNode::expand_genblock(std::string index_var, std::string prefix, std::ma
current_ast_mod->children.push_back(p);
str = p->str;
id2ast = p;
+
+ auto resolved = current_scope.at(index_var);
+ if (resolved->range_valid) {
+ p->range_left = resolved->range_left;
+ p->range_right = resolved->range_right;
+ p->range_swapped = resolved->range_swapped;
+ p->range_valid = resolved->range_valid;
+ }
}
}