ast/simplify: Retire in_lvalue/in_param arguments to simplify

This commit is contained in:
Martin Povišer 2023-04-04 22:59:44 +02:00
parent 22b99413e8
commit a511976b48
4 changed files with 110 additions and 119 deletions

View File

@ -1078,7 +1078,7 @@ static RTLIL::Module *process_module(RTLIL::Design *design, AstNode *ast, bool d
// simplify this module or interface using the current design as context
// for lookup up ports and wires within cells
set_simplify_design_context(design);
while (ast->simplify(!flag_noopt, false, 0, -1, false, false)) { }
while (ast->simplify(!flag_noopt, 0, -1, false)) { }
set_simplify_design_context(nullptr);
if (flag_dump_ast2) {
@ -1380,7 +1380,7 @@ void AST::process(RTLIL::Design *design, AstNode *ast, bool dump_ast1, bool dump
}
else if (child->type == AST_PACKAGE) {
// process enum/other declarations
child->simplify(true, false, 1, -1, false, false);
child->simplify(true, 1, -1, false);
rename_in_package_stmts(child);
design->verilog_packages.push_back(child->clone());
current_scope.clear();

View File

@ -258,7 +258,7 @@ namespace AST
// simplify() creates a simpler AST by unrolling for-loops, expanding generate blocks, etc.
// it also sets the id2ast pointers so that identifier lookups are fast in genRTLIL()
bool simplify(bool const_fold, bool in_lvalue, int stage, int width_hint, bool sign_hint, bool in_param);
bool simplify(bool const_fold, int stage, int width_hint, bool sign_hint);
void replace_result_wire_name_in_function(const std::string &from, const std::string &to);
AstNode *readmem(bool is_readmemh, std::string mem_filename, AstNode *memory, int start_addr, int finish_addr, bool unconditional_init);
void expand_genblock(const std::string &prefix);

View File

@ -180,7 +180,7 @@ struct AST_INTERNAL::LookaheadRewriter
wire->str = stringf("$lookahead%s$%d", node->str.c_str(), autoidx++);
wire->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
wire->is_logic = true;
while (wire->simplify(true, false, 1, -1, false, false)) { }
while (wire->simplify(true, 1, -1, false)) { }
current_ast_mod->children.push_back(wire);
lookaheadids[node->str] = make_pair(node->id2ast, wire);
wire->genRTLIL();
@ -927,7 +927,7 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
this_width = id_ast->children[1]->range_left - id_ast->children[1]->range_right + 1;
} else {
if (id_ast->children[0]->type != AST_CONSTANT)
while (id_ast->simplify(true, false, 1, -1, false, true)) { }
while (id_ast->simplify(true, 1, -1, false)) { }
if (id_ast->children[0]->type == AST_CONSTANT)
this_width = id_ast->children[0]->bits.size();
else
@ -971,8 +971,8 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
else if (!range->range_valid) {
AstNode *left_at_zero_ast = children[0]->children[0]->clone_at_zero();
AstNode *right_at_zero_ast = children[0]->children.size() >= 2 ? children[0]->children[1]->clone_at_zero() : left_at_zero_ast->clone();
while (left_at_zero_ast->simplify(true, false, 1, -1, false, false)) { }
while (right_at_zero_ast->simplify(true, false, 1, -1, false, false)) { }
while (left_at_zero_ast->simplify(true, 1, -1, false)) { }
while (right_at_zero_ast->simplify(true, 1, -1, false)) { }
if (left_at_zero_ast->type != AST_CONSTANT || right_at_zero_ast->type != AST_CONSTANT)
input_error("Unsupported expression on dynamic range select on signal `%s'!\n", str.c_str());
this_width = abs(int(left_at_zero_ast->integer - right_at_zero_ast->integer)) + 1;
@ -988,7 +988,7 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
break;
case AST_TO_BITS:
while (children[0]->simplify(true, false, 1, -1, false, false) == true) { }
while (children[0]->simplify(true, 1, -1, false) == true) { }
if (children[0]->type != AST_CONSTANT)
input_error("Left operand of tobits expression is not constant!\n");
children[1]->detectSignWidthWorker(sub_width_hint, sign_hint);
@ -1010,7 +1010,7 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
break;
case AST_CAST_SIZE:
while (children.at(0)->simplify(true, false, 1, -1, false, false)) { }
while (children.at(0)->simplify(true, 1, -1, false)) { }
if (children.at(0)->type != AST_CONSTANT)
input_error("Static cast with non constant expression!\n");
children.at(1)->detectSignWidthWorker(width_hint, sign_hint);
@ -1032,7 +1032,7 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
break;
case AST_REPLICATE:
while (children[0]->simplify(true, false, 1, -1, false, true) == true) { }
while (children[0]->simplify(true, 1, -1, false) == true) { }
if (children[0]->type != AST_CONSTANT)
input_error("Left operand of replicate expression is not constant!\n");
children[1]->detectSignWidthWorker(sub_width_hint, sub_sign_hint);
@ -1144,7 +1144,7 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
case AST_PREFIX:
// Prefix nodes always resolve to identifiers in generate loops, so we
// can simply perform the resolution to determine the sign and width.
simplify(true, false, 1, -1, false, false);
simplify(true, 1, -1, false);
log_assert(type == AST_IDENTIFIER);
detectSignWidthWorker(width_hint, sign_hint, found_real);
break;
@ -1152,7 +1152,7 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
case AST_FCALL:
if (str == "\\$anyconst" || str == "\\$anyseq" || str == "\\$allconst" || str == "\\$allseq") {
if (GetSize(children) == 1) {
while (children[0]->simplify(true, false, 1, -1, false, true) == true) { }
while (children[0]->simplify(true, 1, -1, false) == true) { }
if (children[0]->type != AST_CONSTANT)
input_error("System function %s called with non-const argument!\n",
RTLIL::unescape_id(str).c_str());
@ -1201,8 +1201,8 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
AstNode *right = range->children.at(1)->clone();
left->set_in_param_flag(true);
right->set_in_param_flag(true);
while (left->simplify(true, in_lvalue, 1, -1, false, true)) { }
while (right->simplify(true, in_lvalue, 1, -1, false, true)) { }
while (left->simplify(true, 1, -1, false)) { }
while (right->simplify(true, 1, -1, false)) { }
if (left->type != AST_CONSTANT || right->type != AST_CONSTANT)
input_error("Function %s has non-constant width!",
RTLIL::unescape_id(str).c_str());
@ -1546,8 +1546,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
if (!children[0]->range_valid) {
AstNode *left_at_zero_ast = children[0]->children[0]->clone_at_zero();
AstNode *right_at_zero_ast = children[0]->children.size() >= 2 ? children[0]->children[1]->clone_at_zero() : left_at_zero_ast->clone();
while (left_at_zero_ast->simplify(true, false, 1, -1, false, false)) { }
while (right_at_zero_ast->simplify(true, false, 1, -1, false, false)) { }
while (left_at_zero_ast->simplify(true, 1, -1, false)) { }
while (right_at_zero_ast->simplify(true, 1, -1, false)) { }
if (left_at_zero_ast->type != AST_CONSTANT || right_at_zero_ast->type != AST_CONSTANT)
input_error("Unsupported expression on dynamic range select on signal `%s'!\n", str.c_str());
int width = abs(int(left_at_zero_ast->integer - right_at_zero_ast->integer)) + 1;

View File

@ -136,7 +136,7 @@ Fmt AstNode::processFormat(int stage, bool sformat_like, int default_base, size_
std::vector<VerilogFmtArg> args;
for (size_t index = first_arg_at; index < children.size(); index++) {
AstNode *node_arg = children[index];
while (node_arg->simplify(true, false, stage, -1, false, in_param)) { }
while (node_arg->simplify(true, stage, -1, false)) { }
VerilogFmtArg arg = {};
arg.filename = filename;
@ -180,7 +180,7 @@ void AstNode::annotateTypedEnums(AstNode *template_node)
log_assert(current_scope.count(enum_type) == 1);
AstNode *enum_node = current_scope.at(enum_type);
log_assert(enum_node->type == AST_ENUM);
while (enum_node->simplify(true, false, 1, -1, false, false)) { }
while (enum_node->simplify(true, 1, -1, false)) { }
//get width from 1st enum item:
log_assert(enum_node->children.size() >= 1);
AstNode *enum_item0 = enum_node->children[0];
@ -814,8 +814,8 @@ static bool try_determine_range_width(AstNode *range, int &result_width)
AstNode *left_at_zero_ast = range->children[0]->clone_at_zero();
AstNode *right_at_zero_ast = range->children[1]->clone_at_zero();
while (left_at_zero_ast->simplify(true, false, 1, -1, false, false)) {}
while (right_at_zero_ast->simplify(true, false, 1, -1, false, false)) {}
while (left_at_zero_ast->simplify(true, 1, -1, false)) {}
while (right_at_zero_ast->simplify(true, 1, -1, false)) {}
bool ok = false;
if (left_at_zero_ast->type == AST_CONSTANT
@ -899,7 +899,7 @@ static void check_auto_nosync(AstNode *node)
//
// this function also does all name resolving and sets the id2ast member of all
// nodes that link to a different node using names and lexical scoping.
bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hint, bool sign_hint, bool in_param_)
bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hint)
{
static int recursion_counter = 0;
static bool deep_recursion_warning = false;
@ -917,8 +917,8 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
#if 0
log("-------------\n");
log("AST simplify[%d] depth %d at %s:%d on %s %p:\n", stage, recursion_counter, filename.c_str(), location.first_line, type2str(type).c_str(), this);
log("const_fold=%d, in_lvalue=%d, stage=%d, width_hint=%d, sign_hint=%d, in_param=%d\n",
int(const_fold), int(in_lvalue), int(stage), int(width_hint), int(sign_hint), int(in_param));
log("const_fold=%d, stage=%d, width_hint=%d, sign_hint=%d\n",
int(const_fold), int(stage), int(width_hint), int(sign_hint));
// dumpAst(NULL, "> ");
#endif
@ -927,7 +927,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
log_assert(type == AST_MODULE || type == AST_INTERFACE);
deep_recursion_warning = true;
while (simplify(const_fold, in_lvalue, 1, width_hint, sign_hint, in_param)) { }
while (simplify(const_fold, 1, width_hint, sign_hint)) { }
if (!flag_nomem2reg && !get_bool_attribute(ID::nomem2reg))
{
@ -1010,7 +1010,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
reg->filename = node->filename;
reg->location = node->location;
children.push_back(reg);
while (reg->simplify(true, false, 1, -1, false, false)) { }
while (reg->simplify(true, 1, -1, false)) { }
}
}
@ -1024,7 +1024,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
delete node;
}
while (simplify(const_fold, in_lvalue, 2, width_hint, sign_hint, in_param)) { }
while (simplify(const_fold, 2, width_hint, sign_hint)) { }
recursion_counter--;
return false;
}
@ -1071,7 +1071,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
// when $display()/$write() functions are used in an always block, simplify the expressions and
// convert them to a special cell later in genrtlil
for (auto node : children)
while (node->simplify(true, false, stage, -1, false, in_param)) {}
while (node->simplify(true, stage, -1, false)) {}
return false;
}
@ -1085,12 +1085,6 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (type == AST_IDENTIFIER && current_scope.count(str) > 0 && (current_scope[str]->type == AST_PARAMETER || current_scope[str]->type == AST_LOCALPARAM || current_scope[str]->type == AST_ENUM_ITEM))
const_fold = true;
// in certain cases a function must be evaluated constant. this is what in_param controls.
if (type == AST_PARAMETER || type == AST_LOCALPARAM || type == AST_DEFPARAM || type == AST_PARASET || type == AST_PREFIX)
in_param_ = true;
log_assert(in_param == in_param_);
log_assert(in_lvalue == in_lvalue_);
std::map<std::string, AstNode*> backup_scope;
// create name resolution entries for all objects with names
@ -1193,12 +1187,12 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
for (size_t i = 0; i < children.size(); i++) {
AstNode *node = children[i];
if (node->type == AST_PARAMETER || node->type == AST_LOCALPARAM || node->type == AST_WIRE || node->type == AST_AUTOWIRE || node->type == AST_MEMORY || node->type == AST_TYPEDEF)
while (node->simplify(true, false, 1, -1, false, node->type == AST_PARAMETER || node->type == AST_LOCALPARAM))
while (node->simplify(true, 1, -1, false))
did_something = true;
if (node->type == AST_ENUM) {
for (auto enode : node->children){
log_assert(enode->type==AST_ENUM_ITEM);
while (node->simplify(true, false, 1, -1, false, in_param))
while (node->simplify(true, 1, -1, false))
did_something = true;
}
}
@ -1263,7 +1257,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
for (AstNode *child : children) {
// simplify any parameters to constants
if (child->type == AST_PARASET)
while (child->simplify(true, false, 1, -1, false, true)) { }
while (child->simplify(true, 1, -1, false)) { }
// look for patterns which _may_ indicate ambiguity requiring
// resolution of the underlying module
@ -1378,9 +1372,9 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
case AST_ASSIGN_EQ:
case AST_ASSIGN_LE:
case AST_ASSIGN:
while (!children[0]->basic_prep && children[0]->simplify(false, true, stage, -1, false, in_param) == true)
while (!children[0]->basic_prep && children[0]->simplify(false, stage, -1, false) == true)
did_something = true;
while (!children[1]->basic_prep && children[1]->simplify(false, false, stage, -1, false, in_param) == true)
while (!children[1]->basic_prep && children[1]->simplify(false, stage, -1, false) == true)
did_something = true;
children[0]->detectSignWidth(backup_width_hint, backup_sign_hint);
children[1]->detectSignWidth(width_hint, sign_hint);
@ -1416,7 +1410,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (!basic_prep) {
for (auto *node : children) {
// resolve any ranges
while (!node->basic_prep && node->simplify(true, false, stage, -1, false, false)) {
while (!node->basic_prep && node->simplify(true, stage, -1, false)) {
did_something = true;
}
}
@ -1449,7 +1443,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
AstNode *template_node = resolved_type_node->children[0];
// Ensure typedef itself is fully simplified
while (template_node->simplify(const_fold, in_lvalue, stage, width_hint, sign_hint, in_param)) {};
while (template_node->simplify(const_fold, stage, width_hint, sign_hint)) {};
// Remove type reference
delete children[0];
@ -1495,7 +1489,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
//log("\nENUM %s: %d child %d\n", str.c_str(), basic_prep, children[0]->basic_prep);
if (!basic_prep) {
for (auto item_node : children) {
while (!item_node->basic_prep && item_node->simplify(false, false, stage, -1, false, in_param))
while (!item_node->basic_prep && item_node->simplify(false, stage, -1, false))
did_something = true;
}
// allocate values (called more than once)
@ -1515,11 +1509,11 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
add_members_to_scope(attributes[ID::wiretype], str);
}
}
while (!children[0]->basic_prep && children[0]->simplify(false, false, stage, -1, false, true) == true)
while (!children[0]->basic_prep && children[0]->simplify(false, stage, -1, false) == true)
did_something = true;
children[0]->detectSignWidth(width_hint, sign_hint);
if (children.size() > 1 && children[1]->type == AST_RANGE) {
while (!children[1]->basic_prep && children[1]->simplify(false, false, stage, -1, false, true) == true)
while (!children[1]->basic_prep && children[1]->simplify(false, stage, -1, false) == true)
did_something = true;
if (!children[1]->range_valid)
input_error("Non-constant width range on parameter decl.\n");
@ -1527,11 +1521,11 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
}
break;
case AST_ENUM_ITEM:
while (!children[0]->basic_prep && children[0]->simplify(false, false, stage, -1, false, in_param))
while (!children[0]->basic_prep && children[0]->simplify(false, stage, -1, false))
did_something = true;
children[0]->detectSignWidth(width_hint, sign_hint);
if (children.size() > 1 && children[1]->type == AST_RANGE) {
while (!children[1]->basic_prep && children[1]->simplify(false, false, stage, -1, false, in_param))
while (!children[1]->basic_prep && children[1]->simplify(false, stage, -1, false))
did_something = true;
if (!children[1]->range_valid)
input_error("Non-constant width range on enum item decl.\n");
@ -1590,7 +1584,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
width_hint = -1;
sign_hint = true;
for (auto child : children) {
while (!child->basic_prep && child->simplify(false, in_lvalue, stage, -1, false, in_param) == true)
while (!child->basic_prep && child->simplify(false, stage, -1, false) == true)
did_something = true;
child->detectSignWidthWorker(width_hint, sign_hint);
}
@ -1625,10 +1619,10 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (detect_width_simple && width_hint < 0) {
if (type == AST_REPLICATE)
while (children[0]->simplify(true, in_lvalue, stage, -1, false, true) == true)
while (children[0]->simplify(true, stage, -1, false) == true)
did_something = true;
for (auto child : children)
while (!child->basic_prep && child->simplify(false, in_lvalue, stage, -1, false, in_param) == true)
while (!child->basic_prep && child->simplify(false, stage, -1, false) == true)
did_something = true;
detectSignWidth(width_hint, sign_hint);
}
@ -1638,18 +1632,18 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (type == AST_TERNARY) {
if (width_hint < 0) {
while (!children[0]->basic_prep && children[0]->simplify(true, in_lvalue, stage, -1, false, in_param))
while (!children[0]->basic_prep && children[0]->simplify(true, stage, -1, false))
did_something = true;
bool backup_unevaluated_tern_branch = unevaluated_tern_branch;
AstNode *chosen = get_tern_choice().first;
unevaluated_tern_branch = backup_unevaluated_tern_branch || chosen == children[2];
while (!children[1]->basic_prep && children[1]->simplify(false, in_lvalue, stage, -1, false, in_param))
while (!children[1]->basic_prep && children[1]->simplify(false, stage, -1, false))
did_something = true;
unevaluated_tern_branch = backup_unevaluated_tern_branch || chosen == children[1];
while (!children[2]->basic_prep && children[2]->simplify(false, in_lvalue, stage, -1, false, in_param))
while (!children[2]->basic_prep && children[2]->simplify(false, stage, -1, false))
did_something = true;
unevaluated_tern_branch = backup_unevaluated_tern_branch;
@ -1681,7 +1675,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (const_fold && type == AST_CASE)
{
detectSignWidth(width_hint, sign_hint);
while (children[0]->simplify(const_fold, in_lvalue, stage, width_hint, sign_hint, in_param)) { }
while (children[0]->simplify(const_fold, stage, width_hint, sign_hint)) { }
if (children[0]->type == AST_CONSTANT && children[0]->bits_only_01()) {
children[0]->is_signed = sign_hint;
RTLIL::Const case_expr = children[0]->bitsAsConst(width_hint, sign_hint);
@ -1695,7 +1689,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
goto keep_const_cond;
if (v->type == AST_BLOCK)
continue;
while (v->simplify(const_fold, in_lvalue, stage, width_hint, sign_hint, in_param)) { }
while (v->simplify(const_fold, stage, width_hint, sign_hint)) { }
if (v->type == AST_CONSTANT && v->bits_only_01()) {
RTLIL::Const case_item_expr = v->bitsAsConst(width_hint, sign_hint);
RTLIL::Const match = const_eq(case_expr, case_item_expr, sign_hint, sign_hint, 1);
@ -1752,20 +1746,18 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
unevaluated_tern_branch = chosen && chosen != children[i];
}
while (did_something_here && i < children.size()) {
bool const_fold_here = const_fold, in_lvalue_here = in_lvalue;
bool const_fold_here = const_fold;
int width_hint_here = width_hint;
bool sign_hint_here = sign_hint;
bool in_param_here = in_param;
if (i == 0 && (type == AST_REPLICATE || type == AST_WIRE))
const_fold_here = true, in_param_here = true;
const_fold_here = true;
if (i == 0 && (type == AST_GENIF || type == AST_GENCASE))
in_param_here = true;
if (i == 1 && (type == AST_FOR || type == AST_GENFOR))
in_param_here = true;
if (type == AST_PARAMETER || type == AST_LOCALPARAM)
const_fold_here = true;
if (i == 0 && (type == AST_ASSIGN || type == AST_ASSIGN_EQ || type == AST_ASSIGN_LE))
in_lvalue_here = true;
if (type == AST_BLOCK) {
current_block = this;
current_block_child = children[i];
@ -1780,7 +1772,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
width_hint_here = -1, sign_hint_here = false;
if (children_are_self_determined)
width_hint_here = -1, sign_hint_here = false;
did_something_here = children[i]->simplify(const_fold_here, in_lvalue_here, stage, width_hint_here, sign_hint_here, in_param_here);
did_something_here = children[i]->simplify(const_fold_here, stage, width_hint_here, sign_hint_here);
if (did_something_here)
did_something = true;
}
@ -1800,7 +1792,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
}
}
for (auto &attr : attributes) {
while (attr.second->simplify(true, false, stage, -1, false, true))
while (attr.second->simplify(true, stage, -1, false))
did_something = true;
}
if (type == AST_CASE && stage == 2) {
@ -1878,7 +1870,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
log_assert(children.size() == 1);
auto type_node = children[0];
log_assert(type_node->type == AST_WIRE || type_node->type == AST_MEMORY || type_node->type == AST_STRUCT || type_node->type == AST_UNION);
while (type_node->simplify(const_fold, in_lvalue, stage, width_hint, sign_hint, in_param)) {
while (type_node->simplify(const_fold, stage, width_hint, sign_hint)) {
did_something = true;
}
log_assert(!type_node->is_custom_type);
@ -1900,7 +1892,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
AstNode *template_node = resolved_type_node->children[0];
// Ensure typedef itself is fully simplified
while (template_node->simplify(const_fold, in_lvalue, stage, width_hint, sign_hint, false)) {};
while (template_node->simplify(const_fold, stage, width_hint, sign_hint)) {};
if (!str.empty() && str[0] == '\\' && (template_node->type == AST_STRUCT || template_node->type == AST_UNION)) {
// replace instance with wire representing the packed structure
@ -1966,7 +1958,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
AstNode *template_node = resolved_type_node->children[0];
// Ensure typedef itself is fully simplified
while (template_node->simplify(const_fold, false, stage, width_hint, sign_hint, false)) {};
while (template_node->simplify(const_fold, stage, width_hint, sign_hint)) {};
if (template_node->type == AST_STRUCT || template_node->type == AST_UNION) {
// replace with wire representing the packed structure
@ -2009,7 +2001,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
input_error("Index in generate block prefix syntax is not constant!\n");
}
if (children[1]->type == AST_PREFIX)
children[1]->simplify(const_fold, in_lvalue, stage, width_hint, sign_hint, in_param);
children[1]->simplify(const_fold, stage, width_hint, sign_hint);
log_assert(children[1]->type == AST_IDENTIFIER);
newNode = children[1]->clone();
const char *second_part = children[1]->str.c_str();
@ -2304,7 +2296,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (current_block)
wire->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
current_ast_mod->children.push_back(wire);
while (wire->simplify(true, false, 1, -1, false, false)) { }
while (wire->simplify(true, 1, -1, false)) { }
AstNode *data = clone();
delete data->children[1];
@ -2346,7 +2338,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
AstNode *body = children[1];
// eval count expression
while (count->simplify(true, false, stage, 32, true, false)) { }
while (count->simplify(true, stage, 32, true)) { }
if (count->type != AST_CONSTANT)
input_error("Repeat loops outside must have constant repeat counts!\n");
@ -2402,7 +2394,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
int expr_width_hint = -1;
bool expr_sign_hint = true;
varbuf->detectSignWidth(expr_width_hint, expr_sign_hint);
while (varbuf->simplify(true, false, stage, 32, true, false)) { }
while (varbuf->simplify(true, stage, 32, true)) { }
}
if (varbuf->type != AST_CONSTANT)
@ -2443,7 +2435,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
int expr_width_hint = -1;
bool expr_sign_hint = true;
buf->detectSignWidth(expr_width_hint, expr_sign_hint);
while (buf->simplify(true, false, stage, expr_width_hint, expr_sign_hint, false)) { }
while (buf->simplify(true, stage, expr_width_hint, expr_sign_hint)) { }
}
if (buf->type != AST_CONSTANT)
@ -2478,7 +2470,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (type == AST_GENFOR) {
for (size_t i = 0; i < buf->children.size(); i++) {
buf->children[i]->simplify(const_fold, false, stage, -1, false, false);
buf->children[i]->simplify(const_fold, stage, -1, false);
current_ast_mod->children.push_back(buf->children[i]);
}
} else {
@ -2495,7 +2487,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
int expr_width_hint = -1;
bool expr_sign_hint = true;
buf->detectSignWidth(expr_width_hint, expr_sign_hint);
while (buf->simplify(true, false, stage, expr_width_hint, expr_sign_hint, true)) { }
while (buf->simplify(true, stage, expr_width_hint, expr_sign_hint)) { }
}
if (buf->type != AST_CONSTANT)
@ -2547,7 +2539,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
std::vector<AstNode*> new_children;
for (size_t i = 0; i < children.size(); i++)
if (children[i]->type == AST_WIRE || children[i]->type == AST_MEMORY || children[i]->type == AST_PARAMETER || children[i]->type == AST_LOCALPARAM || children[i]->type == AST_TYPEDEF) {
children[i]->simplify(false, false, stage, -1, false, false);
children[i]->simplify(false, stage, -1, false);
current_ast_mod->children.push_back(children[i]);
current_scope[children[i]->str] = children[i];
} else
@ -2566,7 +2558,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
}
for (size_t i = 0; i < children.size(); i++) {
children[i]->simplify(const_fold, false, stage, -1, false, false);
children[i]->simplify(const_fold, stage, -1, false);
current_ast_mod->children.push_back(children[i]);
}
@ -2578,7 +2570,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (type == AST_GENIF && children.size() != 0)
{
AstNode *buf = children[0]->clone();
while (buf->simplify(true, false, stage, width_hint, sign_hint, false)) { }
while (buf->simplify(true, stage, width_hint, sign_hint)) { }
if (buf->type != AST_CONSTANT) {
// for (auto f : log_files)
// dumpAst(f, "verilog-ast> ");
@ -2602,7 +2594,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
}
for (size_t i = 0; i < buf->children.size(); i++) {
buf->children[i]->simplify(const_fold, false, stage, -1, false, false);
buf->children[i]->simplify(const_fold, stage, -1, false);
current_ast_mod->children.push_back(buf->children[i]);
}
@ -2618,7 +2610,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (type == AST_GENCASE && children.size() != 0)
{
AstNode *buf = children[0]->clone();
while (buf->simplify(true, false, stage, width_hint, sign_hint, false)) { }
while (buf->simplify(true, stage, width_hint, sign_hint)) { }
if (buf->type != AST_CONSTANT) {
// for (auto f : log_files)
// dumpAst(f, "verilog-ast> ");
@ -2653,7 +2645,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
buf = child->clone();
buf->set_in_param_flag(true);
while (buf->simplify(true, false, stage, width_hint, sign_hint, true)) { }
while (buf->simplify(true, stage, width_hint, sign_hint)) { }
if (buf->type != AST_CONSTANT) {
// for (auto f : log_files)
// dumpAst(f, "verilog-ast> ");
@ -2681,7 +2673,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
}
for (size_t i = 0; i < buf->children.size(); i++) {
buf->children[i]->simplify(const_fold, false, stage, -1, false, false);
buf->children[i]->simplify(const_fold, stage, -1, false);
current_ast_mod->children.push_back(buf->children[i]);
}
@ -2866,7 +2858,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
if (children[0]->id2ast->attributes.count(ID::nowrshmsk)) {
AstNode *node = children[0]->id2ast->attributes.at(ID::nowrshmsk);
while (node->simplify(true, false, stage, -1, false, true)) { }
while (node->simplify(true, stage, -1, false)) { }
if (node->type != AST_CONSTANT)
input_error("Non-constant value for `nowrshmsk' attribute on `%s'!\n", children[0]->id2ast->str.c_str());
if (node->asAttrConst().as_bool())
@ -2904,14 +2896,14 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
wire_mask->str = stringf("$bitselwrite$mask$%s:%d$%d", RTLIL::encode_filename(filename).c_str(), location.first_line, autoidx++);
wire_mask->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
wire_mask->is_logic = true;
while (wire_mask->simplify(true, false, 1, -1, false, false)) { }
while (wire_mask->simplify(true, 1, -1, false)) { }
current_ast_mod->children.push_back(wire_mask);
AstNode *wire_data = new AstNode(AST_WIRE, new AstNode(AST_RANGE, mkconst_int(source_width-1, true), mkconst_int(0, true)));
wire_data->str = stringf("$bitselwrite$data$%s:%d$%d", RTLIL::encode_filename(filename).c_str(), location.first_line, autoidx++);
wire_data->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
wire_data->is_logic = true;
while (wire_data->simplify(true, false, 1, -1, false, false)) { }
while (wire_data->simplify(true, 1, -1, false)) { }
current_ast_mod->children.push_back(wire_data);
int shamt_width_hint = -1;
@ -2923,7 +2915,7 @@ bool AstNode::simplify(bool const_fold, bool in_lvalue_, int stage, int width_hi
wire_sel->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
wire_sel->is_logic = true;
wire_sel->is_signed = shamt_sign_hint;
while (wire_sel->simplify(true, false, 1, -1, false, false)) { }
while (wire_sel->simplify(true, 1, -1, false)) { }
current_ast_mod->children.push_back(wire_sel);
did_something = true;
@ -3008,7 +3000,7 @@ skip_dynamic_range_lvalue_expansion:;
wire_check->was_checked = true;
current_ast_mod->children.push_back(wire_check);
current_scope[wire_check->str] = wire_check;
while (wire_check->simplify(true, false, 1, -1, false, false)) { }
while (wire_check->simplify(true, 1, -1, false)) { }
AstNode *wire_en = new AstNode(AST_WIRE);
wire_en->str = id_en;
@ -3020,7 +3012,7 @@ skip_dynamic_range_lvalue_expansion:;
current_ast_mod->children.back()->children[0]->children[0]->children[0]->was_checked = true;
}
current_scope[wire_en->str] = wire_en;
while (wire_en->simplify(true, false, 1, -1, false, false)) { }
while (wire_en->simplify(true, 1, -1, false)) { }
AstNode *check_defval;
if (type == AST_LIVE || type == AST_FAIR) {
@ -3116,7 +3108,7 @@ skip_dynamic_range_lvalue_expansion:;
current_ast_mod->children.push_back(wire_tmp);
current_scope[wire_tmp->str] = wire_tmp;
wire_tmp->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
while (wire_tmp->simplify(true, false, 1, -1, false, false)) { }
while (wire_tmp->simplify(true, 1, -1, false)) { }
wire_tmp->is_logic = true;
AstNode *wire_tmp_id = new AstNode(AST_IDENTIFIER);
@ -3186,7 +3178,7 @@ skip_dynamic_range_lvalue_expansion:;
wire_addr->was_checked = true;
current_ast_mod->children.push_back(wire_addr);
current_scope[wire_addr->str] = wire_addr;
while (wire_addr->simplify(true, false, 1, -1, false, false)) { }
while (wire_addr->simplify(true, 1, -1, false)) { }
AstNode *assign_addr = new AstNode(AST_ASSIGN_EQ, new AstNode(AST_IDENTIFIER), mkconst_bits(x_bits_addr, false));
assign_addr->children[0]->str = id_addr;
@ -3212,7 +3204,7 @@ skip_dynamic_range_lvalue_expansion:;
wire_data->is_signed = mem_signed;
current_ast_mod->children.push_back(wire_data);
current_scope[wire_data->str] = wire_data;
while (wire_data->simplify(true, false, 1, -1, false, false)) { }
while (wire_data->simplify(true, 1, -1, false)) { }
AstNode *assign_data = new AstNode(AST_ASSIGN_EQ, new AstNode(AST_IDENTIFIER), mkconst_bits(x_bits_data, false));
assign_data->children[0]->str = id_data;
@ -3228,7 +3220,7 @@ skip_dynamic_range_lvalue_expansion:;
wire_en->was_checked = true;
current_ast_mod->children.push_back(wire_en);
current_scope[wire_en->str] = wire_en;
while (wire_en->simplify(true, false, 1, -1, false, false)) { }
while (wire_en->simplify(true, 1, -1, false)) { }
AstNode *assign_en_first = new AstNode(AST_ASSIGN_EQ, new AstNode(AST_IDENTIFIER), mkconst_int(0, false, mem_width));
assign_en_first->children[0]->str = id_en;
@ -3356,7 +3348,7 @@ skip_dynamic_range_lvalue_expansion:;
AstNode *wire = new AstNode(AST_WIRE);
wire->str = stringf("$initstate$%d_wire", myidx);
current_ast_mod->children.push_back(wire);
while (wire->simplify(true, false, 1, -1, false, false)) { }
while (wire->simplify(true, 1, -1, false)) { }
AstNode *cell = new AstNode(AST_CELL, new AstNode(AST_CELLTYPE), new AstNode(AST_ARGUMENT, new AstNode(AST_IDENTIFIER)));
cell->str = stringf("$initstate$%d", myidx);
@ -3365,7 +3357,7 @@ skip_dynamic_range_lvalue_expansion:;
cell->children[1]->children[0]->str = wire->str;
cell->children[1]->children[0]->id2ast = wire;
current_ast_mod->children.push_back(cell);
while (cell->simplify(true, false, 1, -1, false, false)) { }
while (cell->simplify(true, 1, -1, false)) { }
newNode = new AstNode(AST_IDENTIFIER);
newNode->str = wire->str;
@ -3391,7 +3383,7 @@ skip_dynamic_range_lvalue_expansion:;
if (GetSize(children) == 2)
{
AstNode *buf = children[1]->clone();
while (buf->simplify(true, false, stage, -1, false, false)) { }
while (buf->simplify(true, stage, -1, false)) { }
if (buf->type != AST_CONSTANT)
input_error("Failed to evaluate system function `%s' with non-constant value.\n", str.c_str());
@ -3426,7 +3418,7 @@ skip_dynamic_range_lvalue_expansion:;
current_ast_mod->children.push_back(reg);
while (reg->simplify(true, false, 1, -1, false, false)) { }
while (reg->simplify(true, 1, -1, false)) { }
AstNode *regid = new AstNode(AST_IDENTIFIER);
regid->str = reg->str;
@ -3502,7 +3494,7 @@ skip_dynamic_range_lvalue_expansion:;
RTLIL::unescape_id(str).c_str(), int(children.size()));
AstNode *buf = children[0]->clone();
while (buf->simplify(true, false, stage, width_hint, sign_hint, false)) { }
while (buf->simplify(true, stage, width_hint, sign_hint)) { }
if (buf->type != AST_CONSTANT)
input_error("Failed to evaluate system function `%s' with non-constant value.\n", str.c_str());
@ -3534,7 +3526,7 @@ skip_dynamic_range_lvalue_expansion:;
if (children.size() == 2) {
AstNode *buf = children[1]->clone();
// Evaluate constant expression
while (buf->simplify(true, false, stage, width_hint, sign_hint, false)) { }
while (buf->simplify(true, stage, width_hint, sign_hint)) { }
dim = buf->asInt(false);
delete buf;
}
@ -3692,7 +3684,7 @@ skip_dynamic_range_lvalue_expansion:;
}
if (children.size() >= 1) {
while (children[0]->simplify(true, false, stage, width_hint, sign_hint, in_param)) { }
while (children[0]->simplify(true, stage, width_hint, sign_hint)) { }
if (!children[0]->isConst())
input_error("Failed to evaluate system function `%s' with non-constant argument.\n",
RTLIL::unescape_id(str).c_str());
@ -3703,7 +3695,7 @@ skip_dynamic_range_lvalue_expansion:;
}
if (children.size() >= 2) {
while (children[1]->simplify(true, false, stage, width_hint, sign_hint, in_param)) { }
while (children[1]->simplify(true, stage, width_hint, sign_hint)) { }
if (!children[1]->isConst())
input_error("Failed to evaluate system function `%s' with non-constant argument.\n",
RTLIL::unescape_id(str).c_str());
@ -3760,7 +3752,7 @@ skip_dynamic_range_lvalue_expansion:;
// Determine which bits to count
for (size_t i = 1; i < children.size(); i++) {
AstNode *node = children[i];
while (node->simplify(true, false, stage, -1, false, in_param)) { }
while (node->simplify(true, stage, -1, false)) { }
if (node->type != AST_CONSTANT)
input_error("Failed to evaluate system function `%s' with non-constant control bit argument.\n", str.c_str());
if (node->bits.size() != 1)
@ -3855,8 +3847,7 @@ skip_dynamic_range_lvalue_expansion:;
argtypes.push_back(RTLIL::unescape_id(dpi_decl->children.at(i)->str));
args.push_back(children.at(i-2)->clone());
args.back()->set_in_param_flag(true);
while (args.back()->simplify(true, false, stage, -1, false, true)) { }
while (args.back()->simplify(true, stage, -1, false)) { }
if (args.back()->type != AST_CONSTANT && args.back()->type != AST_REALVALUE)
input_error("Failed to evaluate DPI function with non-constant argument.\n");
@ -3893,12 +3884,12 @@ skip_dynamic_range_lvalue_expansion:;
RTLIL::unescape_id(str).c_str(), int(children.size()));
AstNode *node_filename = children[0]->clone();
while (node_filename->simplify(true, false, stage, width_hint, sign_hint, false)) { }
while (node_filename->simplify(true, stage, width_hint, sign_hint)) { }
if (node_filename->type != AST_CONSTANT)
input_error("Failed to evaluate system function `%s' with non-constant 1st argument.\n", str.c_str());
AstNode *node_memory = children[1]->clone();
while (node_memory->simplify(true, false, stage, width_hint, sign_hint, false)) { }
while (node_memory->simplify(true, stage, width_hint, sign_hint)) { }
if (node_memory->type != AST_IDENTIFIER || node_memory->id2ast == nullptr || node_memory->id2ast->type != AST_MEMORY)
input_error("Failed to evaluate system function `%s' with non-memory 2nd argument.\n", str.c_str());
@ -3906,7 +3897,7 @@ skip_dynamic_range_lvalue_expansion:;
if (GetSize(children) > 2) {
AstNode *node_addr = children[2]->clone();
while (node_addr->simplify(true, false, stage, width_hint, sign_hint, false)) { }
while (node_addr->simplify(true, stage, width_hint, sign_hint)) { }
if (node_addr->type != AST_CONSTANT)
input_error("Failed to evaluate system function `%s' with non-constant 3rd argument.\n", str.c_str());
start_addr = int(node_addr->asInt(false));
@ -3914,7 +3905,7 @@ skip_dynamic_range_lvalue_expansion:;
if (GetSize(children) > 3) {
AstNode *node_addr = children[3]->clone();
while (node_addr->simplify(true, false, stage, width_hint, sign_hint, false)) { }
while (node_addr->simplify(true, stage, width_hint, sign_hint)) { }
if (node_addr->type != AST_CONSTANT)
input_error("Failed to evaluate system function `%s' with non-constant 4th argument.\n", str.c_str());
finish_addr = int(node_addr->asInt(false));
@ -3966,7 +3957,7 @@ skip_dynamic_range_lvalue_expansion:;
bool require_const_eval = decl->has_const_only_constructs();
bool all_args_const = true;
for (auto child : children) {
while (child->simplify(true, in_lvalue, 1, -1, false, in_param)) { }
while (child->simplify(true, 1, -1, false)) { }
if (child->type != AST_CONSTANT && child->type != AST_REALVALUE)
all_args_const = false;
}
@ -4011,7 +4002,7 @@ skip_dynamic_range_lvalue_expansion:;
current_scope[wire->str] = wire;
current_ast_mod->children.push_back(wire);
while (wire->simplify(true, false, 1, -1, false, false)) { }
while (wire->simplify(true, 1, -1, false)) { }
AstNode *lvalue = new AstNode(AST_IDENTIFIER);
lvalue->str = wire->str;
@ -4057,7 +4048,7 @@ skip_dynamic_range_lvalue_expansion:;
wire->is_input = false;
wire->is_output = false;
current_ast_mod->children.push_back(wire);
while (wire->simplify(true, false, 1, -1, false, false)) { }
while (wire->simplify(true, 1, -1, false)) { }
AstNode *wire_id = new AstNode(AST_IDENTIFIER);
wire_id->str = wire->str;
@ -4100,7 +4091,7 @@ skip_dynamic_range_lvalue_expansion:;
for (auto c : child->children)
wire->children.push_back(c->clone());
} else if (!child->children.empty()) {
while (child->simplify(true, false, stage, -1, false, false)) { }
while (child->simplify(true, stage, -1, false)) { }
if (GetSize(child->children) == GetSize(wire->children) - contains_value) {
for (int i = 0; i < GetSize(child->children); i++)
if (*child->children.at(i) != *wire->children.at(i + contains_value))
@ -4128,7 +4119,7 @@ skip_dynamic_range_lvalue_expansion:;
current_ast_mod->children.push_back(wire);
}
while (wire->simplify(true, false, 1, -1, false, false)) { }
while (wire->simplify(true, 1, -1, false)) { }
if ((child->is_input || child->is_output) && arg_count < children.size())
{
@ -4161,7 +4152,7 @@ skip_dynamic_range_lvalue_expansion:;
}
wire->fixup_hierarchy_flags();
// updates the sizing
while (wire->simplify(true, false, 1, -1, false, true)) { }
while (wire->simplify(true, 1, -1, false)) { }
delete arg;
continue;
}
@ -5072,7 +5063,7 @@ bool AstNode::mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod,
wire_addr->was_checked = true;
wire_addr->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
mod->children.push_back(wire_addr);
while (wire_addr->simplify(true, false, 1, -1, false, false)) { }
while (wire_addr->simplify(true, 1, -1, false)) { }
AstNode *wire_data = new AstNode(AST_WIRE, new AstNode(AST_RANGE, mkconst_int(mem_width-1, true), mkconst_int(0, true)));
wire_data->str = id_data;
@ -5081,7 +5072,7 @@ bool AstNode::mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod,
wire_data->is_signed = mem_signed;
wire_data->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
mod->children.push_back(wire_data);
while (wire_data->simplify(true, false, 1, -1, false, false)) { }
while (wire_data->simplify(true, 1, -1, false)) { }
log_assert(block != NULL);
size_t assign_idx = 0;
@ -5194,7 +5185,7 @@ bool AstNode::mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod,
if (block)
wire_addr->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
mod->children.push_back(wire_addr);
while (wire_addr->simplify(true, false, 1, -1, false, false)) { }
while (wire_addr->simplify(true, 1, -1, false)) { }
AstNode *wire_data = new AstNode(AST_WIRE, new AstNode(AST_RANGE, mkconst_int(mem_width-1, true), mkconst_int(0, true)));
wire_data->str = id_data;
@ -5204,7 +5195,7 @@ bool AstNode::mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod,
if (block)
wire_data->set_attribute(ID::nosync, AstNode::mkconst_int(1, false));
mod->children.push_back(wire_data);
while (wire_data->simplify(true, false, 1, -1, false, false)) { }
while (wire_data->simplify(true, 1, -1, false)) { }
AstNode *assign_addr = new AstNode(block ? AST_ASSIGN_EQ : AST_ASSIGN, new AstNode(AST_IDENTIFIER), children[0]->children[0]->clone());
assign_addr->children[0]->str = id_addr;
@ -5387,7 +5378,7 @@ bool AstNode::replace_variables(std::map<std::string, AstNode::varinfo_t> &varia
}
if (!children.at(0)->replace_variables(variables, fcall, must_succeed))
return false;
while (simplify(true, false, 1, -1, false, true)) { }
while (simplify(true, 1, -1, false)) { }
if (!children.at(0)->range_valid) {
if (!must_succeed)
return false;
@ -5443,7 +5434,7 @@ AstNode *AstNode::eval_const_function(AstNode *fcall, bool must_succeed)
if (stmt->type == AST_WIRE)
{
while (stmt->simplify(true, false, 1, -1, false, true)) { }
while (stmt->simplify(true, 1, -1, false)) { }
if (!stmt->range_valid) {
if (!must_succeed)
goto finished;
@ -5487,7 +5478,7 @@ AstNode *AstNode::eval_const_function(AstNode *fcall, bool must_succeed)
if (stmt->type == AST_LOCALPARAM)
{
while (stmt->simplify(true, false, 1, -1, false, true)) { }
while (stmt->simplify(true, 1, -1, false)) { }
current_scope[stmt->str] = stmt;
@ -5504,7 +5495,7 @@ AstNode *AstNode::eval_const_function(AstNode *fcall, bool must_succeed)
goto finished;
if (!stmt->children.at(1)->replace_variables(variables, fcall, must_succeed))
goto finished;
while (stmt->simplify(true, false, 1, -1, false, true)) { }
while (stmt->simplify(true, 1, -1, false)) { }
if (stmt->type != AST_ASSIGN_EQ)
continue;
@ -5572,7 +5563,7 @@ AstNode *AstNode::eval_const_function(AstNode *fcall, bool must_succeed)
if (!cond->replace_variables(variables, fcall, must_succeed))
goto finished;
cond->set_in_param_flag(true);
while (cond->simplify(true, false, 1, -1, false, true)) { }
while (cond->simplify(true, 1, -1, false)) { }
if (cond->type != AST_CONSTANT) {
if (!must_succeed)
@ -5598,7 +5589,7 @@ AstNode *AstNode::eval_const_function(AstNode *fcall, bool must_succeed)
if (!num->replace_variables(variables, fcall, must_succeed))
goto finished;
num->set_in_param_flag(true);
while (num->simplify(true, false, 1, -1, false, true)) { }
while (num->simplify(true, 1, -1, false)) { }
if (num->type != AST_CONSTANT) {
if (!must_succeed)
@ -5622,7 +5613,7 @@ AstNode *AstNode::eval_const_function(AstNode *fcall, bool must_succeed)
if (!expr->replace_variables(variables, fcall, must_succeed))
goto finished;
expr->set_in_param_flag(true);
while (expr->simplify(true, false, 1, -1, false, true)) { }
while (expr->simplify(true, 1, -1, false)) { }
AstNode *sel_case = NULL;
for (size_t i = 1; i < stmt->children.size(); i++)
@ -5643,7 +5634,7 @@ AstNode *AstNode::eval_const_function(AstNode *fcall, bool must_succeed)
cond = new AstNode(AST_EQ, expr->clone(), cond);
cond->set_in_param_flag(true);
while (cond->simplify(true, false, 1, -1, false, true)) { }
while (cond->simplify(true, 1, -1, false)) { }
if (cond->type != AST_CONSTANT) {
if (!must_succeed)