Skip to content

Commit c37f1c9

Browse files
committed
An input port driven by a variable is not collapsible
1 parent b7dec18 commit c37f1c9

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

PExpr.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ NetNet* PExpr::elaborate_bi_net(Design*, NetScope*) const
7272
return 0;
7373
}
7474

75-
bool PExpr::is_collapsible_net(Design*, NetScope*) const
75+
bool PExpr::is_collapsible_net(Design*, NetScope*, NetNet::PortType) const
7676
{
7777
return false;
7878
}

PExpr.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef IVL_PExpr_H
22
#define IVL_PExpr_H
33
/*
4-
* Copyright (c) 1998-2019 Stephen Williams <[email protected]>
4+
* Copyright (c) 1998-2020 Stephen Williams <[email protected]>
55
* Copyright CERN 2013 / Stephen Williams ([email protected])
66
*
77
* This source code is free software; you can redistribute it
@@ -181,7 +181,8 @@ class PExpr : public LineInfo {
181181
// structural net that can have multiple drivers. This is
182182
// used to test whether an input port connection can be
183183
// collapsed to a single wire.
184-
virtual bool is_collapsible_net(Design*des, NetScope*scope) const;
184+
virtual bool is_collapsible_net(Design*des, NetScope*scope,
185+
NetNet::PortType port_type) const;
185186

186187
// This method returns true if that expression is the same as
187188
// this expression. This method is used for comparing
@@ -256,7 +257,8 @@ class PEConcat : public PExpr {
256257
NetScope*scope,
257258
bool is_cassign,
258259
bool is_force) const;
259-
virtual bool is_collapsible_net(Design*des, NetScope*scope) const;
260+
virtual bool is_collapsible_net(Design*des, NetScope*scope,
261+
NetNet::PortType port_type) const;
260262
private:
261263
NetNet* elaborate_lnet_common_(Design*des, NetScope*scope,
262264
bool bidirectional_flag) const;
@@ -377,7 +379,8 @@ class PEIdent : public PExpr {
377379

378380
verinum* eval_const(Design*des, NetScope*sc) const;
379381

380-
virtual bool is_collapsible_net(Design*des, NetScope*scope) const;
382+
virtual bool is_collapsible_net(Design*des, NetScope*scope,
383+
NetNet::PortType port_type) const;
381384

382385
const PPackage* package() const { return package_; }
383386

elab_net.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999-2014 Stephen Williams ([email protected])
2+
* Copyright (c) 1999-2020 Stephen Williams ([email protected])
33
* Copyright CERN 2012 / Stephen Williams ([email protected])
44
*
55
* This source code is free software; you can redistribute it
@@ -168,7 +168,8 @@ NetNet* PEConcat::elaborate_bi_net(Design*des, NetScope*scope) const
168168
return elaborate_lnet_common_(des, scope, true);
169169
}
170170

171-
bool PEConcat::is_collapsible_net(Design*des, NetScope*scope) const
171+
bool PEConcat::is_collapsible_net(Design*des, NetScope*scope,
172+
NetNet::PortType port_type) const
172173
{
173174
assert(scope);
174175

@@ -183,7 +184,7 @@ bool PEConcat::is_collapsible_net(Design*des, NetScope*scope) const
183184
if (parms_[idx] == 0)
184185
return false;
185186

186-
if (!parms_[idx]->is_collapsible_net(des, scope))
187+
if (!parms_[idx]->is_collapsible_net(des, scope, port_type))
187188
return false;
188189
}
189190

@@ -1065,7 +1066,8 @@ NetNet*PEIdent::elaborate_unpacked_net(Design*des, NetScope*scope) const
10651066
return sig;
10661067
}
10671068

1068-
bool PEIdent::is_collapsible_net(Design*des, NetScope*scope) const
1069+
bool PEIdent::is_collapsible_net(Design*des, NetScope*scope,
1070+
NetNet::PortType port_type) const
10691071
{
10701072
assert(scope);
10711073

@@ -1086,9 +1088,10 @@ bool PEIdent::is_collapsible_net(Design*des, NetScope*scope) const
10861088
/* If this is SystemVerilog and the variable is not yet
10871089
assigned by anything, then convert it to an unresolved
10881090
wire. */
1089-
if (gn_var_can_be_uwire()
1090-
&& (sig->type() == NetNet::REG)
1091-
&& (sig->peek_eref() == 0) ) {
1091+
if (gn_var_can_be_uwire() &&
1092+
(sig->type() == NetNet::REG) &&
1093+
(sig->peek_eref() == 0) &&
1094+
(port_type == NetNet::POUTPUT)) {
10921095
sig->type(NetNet::UNRESOLVED_WIRE);
10931096
}
10941097

elaborate.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,18 +1446,20 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
14461446
assert(prts_vector_width % instance.size() == 0);
14471447

14481448
if (!prts.empty() && (prts[0]->port_type() == NetNet::PINPUT)
1449-
&& prts[0]->pin(0).nexus()->drivers_present()
1450-
&& pins[idx]->is_collapsible_net(des, scope)) {
1449+
&& prts[0]->pin(0).nexus()->drivers_present()
1450+
&& pins[idx]->is_collapsible_net(des, scope,
1451+
prts[0]->port_type())) {
14511452
prts[0]->port_type(NetNet::PINOUT);
14521453

14531454
cerr << pins[idx]->get_fileline() << ": warning: input port "
14541455
<< prts[0]->name() << " is coerced to inout." << endl;
14551456
}
14561457

14571458
if (!prts.empty() && (prts[0]->port_type() == NetNet::POUTPUT)
1458-
&& (prts[0]->type() != NetNet::REG)
1459-
&& prts[0]->pin(0).nexus()->has_floating_input()
1460-
&& pins[idx]->is_collapsible_net(des, scope)) {
1459+
&& (prts[0]->type() != NetNet::REG)
1460+
&& prts[0]->pin(0).nexus()->has_floating_input()
1461+
&& pins[idx]->is_collapsible_net(des, scope,
1462+
prts[0]->port_type())) {
14611463
prts[0]->port_type(NetNet::PINOUT);
14621464

14631465
cerr << pins[idx]->get_fileline() << ": warning: output port "

0 commit comments

Comments
 (0)