opt_dff: Fix NOT gates wired in reverse.
authorMarcelina Kościelnicka <mwk@0x04.net>
Tue, 4 May 2021 17:14:24 +0000 (19:14 +0200)
committerMarcelina Kościelnicka <mwk@0x04.net>
Tue, 4 May 2021 19:03:40 +0000 (21:03 +0200)
passes/opt/opt_dff.cc
tests/opt/opt_dff_sr.ys

index a47071a30f8bba84db8a90b46e1332e8a3b0d4d9..c87ac3163e566997843426e89aae5120ab0d9800 100644 (file)
@@ -318,9 +318,9 @@ struct OptDffWorker
                                                if (!ff.pol_clr) {
                                                        module->connect(ff.sig_q[i], ff.sig_clr[i]);
                                                } else if (ff.is_fine) {
-                                                       module->addNotGate(NEW_ID, ff.sig_q[i], ff.sig_clr[i]);
+                                                       module->addNotGate(NEW_ID, ff.sig_clr[i], ff.sig_q[i]);
                                                } else {
-                                                       module->addNot(NEW_ID, ff.sig_q[i], ff.sig_clr[i]);
+                                                       module->addNot(NEW_ID, ff.sig_clr[i], ff.sig_q[i]);
                                                }
                                                log("Handling always-active SET at position %d on %s (%s) from module %s (changing to combinatorial circuit).\n",
                                                                i, log_id(cell), log_id(cell->type), log_id(module));
index daedb115cdd3df47b6c262d9edc3460b7f6c26f4..0961cb11ef2d6be9838d68b2d5998771f4cba80d 100644 (file)
@@ -22,8 +22,10 @@ EOT
 
 design -save orig
 
-equiv_opt -undef -assert -multiclock opt_dff
-design -load postopt
+# Equivalence check will fail for unmapped adlatch and dlatchsr due to negative hold hack.
+#equiv_opt -undef -assert -multiclock opt_dff
+#design -load postopt
+opt_dff
 select -assert-count 1 t:$dffsr
 select -assert-count 1 t:$dffsr r:WIDTH=2 %i
 select -assert-count 1 t:$dffsre
@@ -34,8 +36,9 @@ select -assert-none t:$sr
 
 design -load orig
 
-equiv_opt -undef -assert -multiclock opt_dff -keepdc
-design -load postopt
+#equiv_opt -undef -assert -multiclock opt_dff -keepdc
+#design -load postopt
+opt_dff -keepdc
 select -assert-count 1 t:$dffsr
 select -assert-count 1 t:$dffsr r:WIDTH=4 %i
 select -assert-count 1 t:$dffsre
@@ -48,8 +51,9 @@ select -assert-count 1 t:$sr r:WIDTH=4 %i
 design -load orig
 simplemap
 
-equiv_opt -undef -assert -multiclock opt_dff
-design -load postopt
+#equiv_opt -undef -assert -multiclock opt_dff
+#design -load postopt
+opt_dff
 select -assert-count 1 t:$_DFF_PP0_
 select -assert-count 1 t:$_DFF_PP1_
 select -assert-count 1 t:$_DFFE_PN0P_
@@ -61,8 +65,9 @@ select -assert-none t:$_DFF_PP0_ t:$_DFF_PP1_ t:$_DFFE_PN0P_ t:$_DFFE_PN1P_ t:$_
 design -load orig
 simplemap
 
-equiv_opt -undef -assert -multiclock opt_dff -keepdc
-design -load postopt
+#equiv_opt -undef -assert -multiclock opt_dff -keepdc
+#design -load postopt
+opt_dff -keepdc
 select -assert-count 1 t:$_DFF_PP0_
 select -assert-count 1 t:$_DFF_PP1_
 select -assert-count 2 t:$_DFFSR_PPP_