From 68286209772f07f1c682dc1b8804823acf382e38 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 19 Feb 2009 09:32:53 -0800 Subject: [PATCH] Properly detect wire arrays in l-values. Wires are not allowed as l-values of procedural assignments, even if the wire is an array. Fix the checker to detect this case event when the l-value is an array. --- elab_lval.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/elab_lval.cc b/elab_lval.cc index e351d3cd2..cd31f37ce 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -179,6 +179,19 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, return 0; } + /* Get the signal referenced by the identifier, and make sure + it is a register. Wires are not allows in this context, + unless this is the l-value of a force. */ + if ((reg->type() != NetNet::REG) && !is_force) { + cerr << get_fileline() << ": error: " << path_ << + " is not a valid l-value in " << scope_path(scope) << + "." << endl; + cerr << reg->get_fileline() << ": : " << path_ << + " is declared here as " << reg->type() << "." << endl; + des->errors += 1; + return 0; + } + if (reg->array_dimensions() > 0) return elaborate_lval_net_word_(des, scope, reg); @@ -195,19 +208,6 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, return lv; } - /* Get the signal referenced by the identifier, and make sure - it is a register. Wires are not allows in this context, - unless this is the l-value of a force. */ - if ((reg->type() != NetNet::REG) && !is_force) { - cerr << get_fileline() << ": error: " << path_ << - " is not a valid l-value in " << scope_path(scope) << - "." << endl; - cerr << reg->get_fileline() << ": : " << path_ << - " is declared here as " << reg->type() << "." << endl; - des->errors += 1; - return 0; - } - if (use_sel == index_component_t::SEL_BIT) { NetAssign_*lv = new NetAssign_(reg); @@ -274,7 +274,7 @@ NetAssign_* PEIdent::elaborate_lval_net_word_(Design*des, if (NetEConst*word_const = dynamic_cast(word)) { verinum word_val = word_const->value(); long index = word_val.as_long(); - assert (reg->array_count() <= LONG_MAX); + if (index < 0 || index >= (long) reg->array_count()) { cerr << get_fileline() << ": warning: Constant array index " << (index + reg->array_first())