From e7852f8f9c2b3dec52f098f726b971e2008dfa79 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 17 Sep 2016 19:20:48 +0100 Subject: [PATCH] Fix for GitHub issue #127 - coerce output ports to inout when necessary. (cherry picked from commit 080dd0323dae72f5448e6f4053ce315ddb844d13) --- elaborate.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/elaborate.cc b/elaborate.cc index 0faa7ed2a..f4f99f85f 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -1425,6 +1425,16 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const << prts[0]->name() << " is coerced to inout." << endl; } + if (!prts.empty() && (prts[0]->port_type() == NetNet::POUTPUT) + && (prts[0]->type() != NetNet::REG) + && prts[0]->pin(0).nexus()->has_floating_input() + && pins[idx]->is_collapsible_net(des, scope)) { + prts[0]->port_type(NetNet::PINOUT); + + cerr << pins[idx]->get_fileline() << ": warning: output port " + << prts[0]->name() << " is coerced to inout." << endl; + } + // Elaborate the expression that connects to the // module[s] port. sig is the thing outside the module // that connects to the port.