deminout: prevent any constant assignment from demoting to input
authorMarcin Kościelnicki <mwk@0x04.net>
Mon, 30 Mar 2020 13:02:24 +0000 (15:02 +0200)
committerMarcin Kościelnicki <mwk@0x04.net>
Mon, 30 Mar 2020 13:04:31 +0000 (15:04 +0200)
Before this patch,

```
module top(inout io);
assign io = 1'bx;
endmodule
```

would have the `io` pin demoted to input (same happens for `1'bz`,
but not for `1'b0` or `1'b1`), resulting in check failures later on.

Part of fix for #1841.

passes/techmap/deminout.cc

index 35d43b1066742b1f9f9e26da74da4a2aff48ed4f..a7dce9c81710ad9a3276cfcba97ccab2f3578377 100644 (file)
@@ -113,7 +113,7 @@ struct DeminoutPass : public Pass {
                                                {
                                                        if (bits_numports[bit] > 1 || bits_inout.count(bit))
                                                                new_input = true, new_output = true;
-                                                       if (bit == State::S0 || bit == State::S1)
+                                                       if (!bit.wire)
                                                                new_output = true;
                                                        if (bits_written.count(bit)) {
                                                                new_output = true;