Fix connecting single element array ports

The current check to decide whether a port is an array or a scalar signal
uses the number of pins on the NetNet. If it is larger than one the code
assumes that it is an array.

But for arrays with on a single element the number of pins will be 1 and
the port is incorrectly treated as a scalar signal which results in an
error.

Instead of using the number of pins check for the number of unpacked
dimensions to decide whether the port is an array.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2023-05-06 09:25:26 -07:00
parent b210eb8264
commit 829af9f438
1 changed files with 2 additions and 2 deletions

View File

@ -1538,7 +1538,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
// array, then there should be no sub-ports and // array, then there should be no sub-ports and
// the r-value expression is processed // the r-value expression is processed
// differently. // differently.
if (prts.size() >= 1 && prts[0]->pin_count()>1) { if (prts.size() >= 1 && prts[0]->unpacked_dimensions() > 0) {
ivl_assert(*this, prts.size()==1); ivl_assert(*this, prts.size()==1);
elaborate_unpacked_port(des, scope, prts[0], pins[idx], elaborate_unpacked_port(des, scope, prts[0], pins[idx],
ptype, rmod, idx); ptype, rmod, idx);
@ -1703,7 +1703,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
// differently. Note that we are calling it the // differently. Note that we are calling it the
// "r-value" expression, but since this is an // "r-value" expression, but since this is an
// output port, we assign to it from the internal object. // output port, we assign to it from the internal object.
if (prts[0]->pin_count() > 1) { if (prts[0]->unpacked_dimensions() > 0) {
elaborate_unpacked_port(des, scope, prts[0], pins[idx], elaborate_unpacked_port(des, scope, prts[0], pins[idx],
ptype, rmod, idx); ptype, rmod, idx);
continue; continue;