From b629d913d254d47477e37f080c0a2b6ae3b05d73 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 24 Jul 2009 11:59:10 -0700 Subject: [PATCH] Fix CA replication of zero issues. This patch fixes a CA to evaluate and ignore a replication of zero. It also fixes a minor glitch in the data type calculation code. This was causing a problem if a zero width replication was the first element in a concatenation/replication since the data type was hard coded to the first element of the concatenation/replication. It now uses the first defined element in the concatenation/replication to determine the data type. --- expr_synth.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/expr_synth.cc b/expr_synth.cc index 3affe9086..70b5dff76 100644 --- a/expr_synth.cc +++ b/expr_synth.cc @@ -722,25 +722,35 @@ NetNet* NetEConcat::synthesize(Design*des, NetScope*scope, NetExpr*root) unsigned nparms = parms_.count(); NetNet**tmp = new NetNet*[parms_.count()]; bool flag = true; + ivl_variable_type_t data_type = IVL_VT_NO_TYPE; for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { if (parms_[idx]->expr_width() == 0) { - tmp[idx] = 0; + /* We need to synthesize a replication of zero. */ + tmp[idx] = parms_[idx]->synthesize(des, scope, root); + assert(tmp[idx] == 0); nparms -= 1; } else { tmp[idx] = parms_[idx]->synthesize(des, scope, root); if (tmp[idx] == 0) flag = false; + /* Set the data type to the first one found. */ + if (data_type == IVL_VT_NO_TYPE) { + data_type = tmp[idx]->data_type(); + } } } if (flag == false) return 0; - ivl_assert(*this, tmp[0]); + ivl_assert(*this, data_type != IVL_VT_NO_TYPE); + + /* If this is a replication of zero just return 0. */ + if (expr_width() == 0) return 0; /* Make a NetNet object to carry the output vector. */ perm_string path = scope->local_symbol(); NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, expr_width()); osig->local_flag(true); - osig->data_type(tmp[0]->data_type()); + osig->data_type(data_type); NetConcat*concat = new NetConcat(scope, scope->local_symbol(), osig->vector_width(),