cxxrtl: treat wires with multiple defs as not inlinable.
authorwhitequark <whitequark@whitequark.org>
Tue, 20 Jul 2021 10:30:39 +0000 (10:30 +0000)
committerwhitequark <whitequark@whitequark.org>
Tue, 20 Jul 2021 10:30:39 +0000 (10:30 +0000)
Fixes #2883.

backends/cxxrtl/cxxrtl_backend.cc

index 56305258a4a62f054d8d61064d7f0179e154320a..46759e8fae630f95a53b356c54729babac1031c9 100644 (file)
@@ -326,8 +326,14 @@ struct FlowGraph {
                for (auto bit : sig.bits())
                        bit_has_state[bit] |= is_ff;
                // Only comb defs of an entire wire in the right order can be inlined.
-               if (!is_ff && sig.is_wire())
-                       wire_def_inlinable[sig.as_wire()] = inlinable;
+               if (!is_ff && sig.is_wire()) {
+                       // Only a single def of a wire can be inlined. (Multiple defs of a wire are unsound, but we
+                       // handle them anyway to avoid assertion failures later.)
+                       if (!wire_def_inlinable.count(sig.as_wire()))
+                               wire_def_inlinable[sig.as_wire()] = inlinable;
+                       else
+                               wire_def_inlinable[sig.as_wire()] = false;
+               }
        }
 
        void add_uses(Node *node, const RTLIL::SigSpec &sig)