From 2ceb90b95ef9bdeacfd9619b932ea8f783c8983c Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Wed, 24 Aug 2022 15:21:16 +0100 Subject: [PATCH] Fix assertion failure on multiple instantiation of implicitly real-typed parameter declaration (issue #732) If the parameter has no explicit type, the type is inferred from the RHS expression. The first time the parameter is evaluated, the RHS hasn't yet been elaborated, so the type is unknown. This causes the evaluation to be performed by NetScope::evaluate_parameter_logic_, which correctly handles both logic and real types. However, on subsequent evaluations of the parameter, the expression type is now known, so the evaluation was being performed by NetScope::evaluate_parameter_real_. This function requires the parameter to have an explicit type. For now, rather than add more code to NetScope::evaluate_parameter_real_ to handle an implicit type, force NetScope::evaluate_parameter_logic_ to be used whenever we have an implicit type. This should probably be reworked if support for more complex types is added. --- net_design.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net_design.cc b/net_design.cc index ac579bb51..a546f7110 100644 --- a/net_design.cc +++ b/net_design.cc @@ -842,12 +842,12 @@ void NetScope::evaluate_parameter_(Design*des, param_ref_t cur) // Guess the varaiable type of the parameter. If the parameter has no // given type, then guess the type from the expression and use that to - // evaluate. + // evaluate (this is currently handled in evaluate_parameter_logic_()). ivl_variable_type_t use_type; if (param_type) use_type = param_type->base_type(); else - use_type = cur->second.val_expr->expr_type(); + use_type = IVL_VT_NO_TYPE; if (cur->second.solving) { cerr << cur->second.get_fileline() << ": error: "