From 9caeadf79713534a1fd5f51fb458af245c34dad9 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 30 Sep 2015 15:46:51 +0200 Subject: [PATCH] Fixed detection of unconditional $readmem[hb] --- frontends/ast/simplify.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 6b6f1522f..2e6892a82 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -1718,12 +1718,19 @@ skip_dynamic_range_lvalue_expansion:; bool unconditional_init = false; if (current_always->type == AST_INITIAL) { + pool queue; log_assert(current_always->children[0]->type == AST_BLOCK); - for (auto n : current_always->children[0]->children) - if (n == this) { - unconditional_init = true; - break; + queue.insert(current_always->children[0]); + while (!unconditional_init && !queue.empty()) { + pool next_queue; + for (auto n : queue) + for (auto c : n->children) { + if (c == this) + unconditional_init = true; + next_queue.insert(c); } + next_queue.swap(queue); + } } newNode = readmem(str == "\\$readmemh", node_filename->bitsAsConst().decode_string(), node_memory->id2ast, start_addr, finish_addr, unconditional_init); -- 2.30.2