From f132e09475e0e4cb186109a0906262ec8f76837c Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 5 Jun 2008 14:38:56 -0700 Subject: [PATCH] Fix default parameter type if localparams are present. localparam declarations were messing up the state of parser variables so that the default types of following parameters got messed up. --- Module.h | 2 +- net_design.cc | 4 ++++ net_scope.cc | 3 +++ parse.y | 6 +++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Module.h b/Module.h index daca15078..cd8ae1fb5 100644 --- a/Module.h +++ b/Module.h @@ -94,7 +94,7 @@ class Module : public PScope, public LineInfo { module is elaborated. During parsing, I put the parameters into this map. */ struct param_expr_t : public LineInfo { - param_expr_t() : range(0) { } + param_expr_t() : type(IVL_VT_NO_TYPE), msb(0), lsb(0), signed_flag(false), expr(0), range(0) { } // Type information ivl_variable_type_t type; PExpr*msb; diff --git a/net_design.cc b/net_design.cc index 25845240a..05cd2cfb8 100644 --- a/net_design.cc +++ b/net_design.cc @@ -529,6 +529,10 @@ void NetScope::evaluate_parameters(Design*des) cerr << (*cur).second.get_fileline() << ": internal error: " << "Unexpected expression type " << (*cur).second.type << "." << endl; + cerr << (*cur).second.get_fileline() << ": : " + << "Parameter name: " << (*cur).first << endl; + cerr << (*cur).second.get_fileline() << ": : " + << "Expression is: " << *(*cur).second.expr << endl; ivl_assert((*cur).second, 0); break; } diff --git a/net_scope.cc b/net_scope.cc index 4425a2a49..c8a986fb2 100644 --- a/net_scope.cc +++ b/net_scope.cc @@ -121,6 +121,9 @@ NetExpr* NetScope::set_parameter(perm_string key, NetExpr*expr, ivl_assert(file_line, ref.range == 0); ref.range = range_list; ref.set_line(file_line); + + ivl_assert(file_line, type != IVL_VT_NO_TYPE); + return res; } diff --git a/parse.y b/parse.y index 648a9c657..7e81e9a3f 100644 --- a/parse.y +++ b/parse.y @@ -2480,7 +2480,7 @@ localparam_assign_decl localparam_assign_list { param_active_range = 0; param_active_signed = false; - param_active_type = IVL_VT_NO_TYPE; + param_active_type = IVL_VT_LOGIC; } | K_integer { param_active_range = 0; @@ -2490,7 +2490,7 @@ localparam_assign_decl localparam_assign_list { param_active_range = 0; param_active_signed = false; - param_active_type = IVL_VT_NO_TYPE; + param_active_type = IVL_VT_LOGIC; } | K_real { param_active_range = 0; @@ -2500,7 +2500,7 @@ localparam_assign_decl localparam_assign_list { param_active_range = 0; param_active_signed = false; - param_active_type = IVL_VT_NO_TYPE; + param_active_type = IVL_VT_LOGIC; } ;