opt_expr: Fix handling of $_XNOR_ cells with A = B.
authorMarcelina Kościelnicka <mwk@0x04.net>
Wed, 29 Jul 2020 08:00:01 +0000 (10:00 +0200)
committerMarcelina Kościelnicka <mwk@0x04.net>
Wed, 29 Jul 2020 10:41:43 +0000 (12:41 +0200)
Fixes #2311.

passes/opt/opt_expr.cc
tests/opt/bug2311.ys [new file with mode: 0644]

index 649ad83a69fb36859455340cb152770df37ea3f0..8aae1a731dca9365d2762a88648c5add012090cc 100644 (file)
@@ -604,7 +604,7 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
                                if (cell->type.in(ID($xnor), ID($_XNOR_))) {
                                        cover("opt.opt_expr.const_xnor");
                                        // For consistency since simplemap does $xnor -> $_XOR_ + $_NOT_
-                                       int width = cell->getParam(ID::Y_WIDTH).as_int();
+                                       int width = GetSize(cell->getPort(ID::Y));
                                        replace_cell(assign_map, module, cell, "const_xnor", ID::Y, SigSpec(RTLIL::State::S1, width));
                                        goto next_cell;
                                }
diff --git a/tests/opt/bug2311.ys b/tests/opt/bug2311.ys
new file mode 100644 (file)
index 0000000..455147c
--- /dev/null
@@ -0,0 +1,14 @@
+read_verilog -icells << EOT
+
+module top(...);
+
+input A;
+output Y;
+
+$_XNOR_ x (.A(A), .B(A), .Y(Y));
+
+endmodule
+
+EOT
+
+equiv_opt -assert opt_expr