From 74abc3bbfde7477994a0a88f93a69fad5a2a8f23 Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Thu, 20 Aug 2020 20:09:54 -0400 Subject: Allow localparams in constant functions --- frontends/ast/simplify.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'frontends') diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 7f9795d29..b8e4f941c 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -4488,6 +4488,18 @@ AstNode *AstNode::eval_const_function(AstNode *fcall) log_assert(variables.count(str) != 0); + if (stmt->type == AST_LOCALPARAM) + { + while (stmt->simplify(true, false, false, 1, -1, false, true)) { } + + if (!backup_scope.count(stmt->str)) + backup_scope[stmt->str] = current_scope[stmt->str]; + current_scope[stmt->str] = stmt; + + block->children.erase(block->children.begin()); + continue; + } + if (stmt->type == AST_ASSIGN_EQ) { if (stmt->children.at(0)->type == AST_IDENTIFIER && stmt->children.at(0)->children.size() != 0 && -- cgit v1.2.3