Keep zero-width wires in opt_clean if and only if they are ports, fixes #1023
authorClifford Wolf <clifford@clifford.at>
Wed, 22 May 2019 11:56:56 +0000 (13:56 +0200)
committerClifford Wolf <clifford@clifford.at>
Wed, 22 May 2019 11:57:36 +0000 (13:57 +0200)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
passes/opt/opt_clean.cc

index bf802016985471ddb95eb752c430dc6214cef93f..7011d4602a36ab58bc9351189f923b656dc4f326 100644 (file)
@@ -319,8 +319,9 @@ bool rmunused_module_signals(RTLIL::Module *module, bool purge_mode, bool verbos
                        wire->attributes.erase("\\init");
 
                if (GetSize(wire) == 0) {
-                       // delete zero-width wires
-                       goto delete_this_wire;
+                       // delete zero-width wires, unless they are module ports
+                       if (wire->port_id == 0)
+                               goto delete_this_wire;
                } else
                if (wire->port_id != 0 || wire->get_bool_attribute("\\keep") || !initval.is_fully_undef()) {
                        // do not delete anything with "keep" or module ports or initialized wires