diff options
author | Eddie Hung <eddie@fpgeh.com> | 2019-04-22 11:45:49 -0700 |
---|---|---|
committer | Eddie Hung <eddie@fpgeh.com> | 2019-04-22 11:45:49 -0700 |
commit | 4486a98fd5928a4e3cdf9cd27c27b7dd821513bb (patch) | |
tree | 0afd22de8a09ab3995355e3813015c4523bd63fd /frontends/ast/simplify.cc | |
parent | cbb85e40e87fbfb1602bb934ed76a97efb9e55c6 (diff) | |
parent | ec88129a5cf510afc39ea12efa6059bed3eadfc3 (diff) | |
download | yosys-4486a98fd5928a4e3cdf9cd27c27b7dd821513bb.tar.gz yosys-4486a98fd5928a4e3cdf9cd27c27b7dd821513bb.tar.bz2 yosys-4486a98fd5928a4e3cdf9cd27c27b7dd821513bb.zip |
Merge remote-tracking branch 'origin/xc7srl' into xc7mux
Diffstat (limited to 'frontends/ast/simplify.cc')
-rw-r--r-- | frontends/ast/simplify.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 63b71b800..76da5a97c 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -1030,7 +1030,26 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, log_file_error(filename, linenum, "While loops are only allowed in constant functions!\n"); if (type == AST_REPEAT) - log_file_error(filename, linenum, "Repeat loops are only allowed in constant functions!\n"); + { + AstNode *count = children[0]; + AstNode *body = children[1]; + + // eval count expression + while (count->simplify(true, false, false, stage, 32, true, false)) { } + + if (count->type != AST_CONSTANT) + log_file_error(filename, linenum, "Repeat loops outside must have constant repeat counts!\n"); + + // convert to a block with the body repeated n times + type = AST_BLOCK; + children.clear(); + for (int i = 0; i < count->bitsAsConst().as_int(); i++) + children.insert(children.begin(), body->clone()); + + delete count; + delete body; + did_something = true; + } // unroll for loops and generate-for blocks if ((type == AST_GENFOR || type == AST_FOR) && children.size() != 0) |