zinit: resolve one more comment by @mwkmwkmwk
authorEddie Hung <eddie@fpgeh.com>
Mon, 13 Apr 2020 22:25:37 +0000 (15:25 -0700)
committerEddie Hung <eddie@fpgeh.com>
Mon, 13 Apr 2020 22:25:37 +0000 (15:25 -0700)
passes/techmap/zinit.cc
tests/techmap/zinit.ys

index b7beb4e9df983eb9c186fc1464a9ba6eecfe814f..9eb47ff6d810bc5e44a516be02b63e0045746e7d 100644 (file)
@@ -153,9 +153,11 @@ struct ZinitPass : public Pass {
                                else if (cell->type.in(ID($_DFF_NN0_), ID($_DFF_NN1_), ID($_DFF_NP0_), ID($_DFF_NP1_),
                                                        ID($_DFF_PN0_), ID($_DFF_PN1_), ID($_DFF_PP0_), ID($_DFF_PP1_)))
                                {
-                                       std::string t = cell->type.str();
-                                       t[8] = (t[8] == '0' ? '1' : '0');
-                                       cell->type = t;
+                                       if (initval == State::S1) {
+                                               std::string t = cell->type.str();
+                                               t[8] = (t[8] == '0' ? '1' : '0');
+                                               cell->type = t;
+                                       }
                                }
                        }
                }
index c74218f7cfe4d9f0f2b9f898d03fd1fcb55bd13f..18b17621fc7e9b8acb09b3cf9cf8d332947d2ff4 100644 (file)
@@ -23,6 +23,8 @@ design -load postopt
 select -assert-count 20 t:$_NOT_
 select -assert-count 1 w:unused a:init %i
 select -assert-count 1 w:Q a:init=13'bxxxx1xxxxxxxx %i
+select -assert-count 4 c:dff0 c:dff2 c:dff4 c:dff6 %% t:$_DFF_??1_ %i
+select -assert-count 4 c:dff1 c:dff3 c:dff5 c:dff7 %% t:$_DFF_??0_ %i
 
 
 design -reset
@@ -45,6 +47,11 @@ $adff #(.WIDTH(2), .CLK_POLARITY(1), .ARST_POLARITY(1'b0), .ARST_VALUE(2'b10)) d
 $adff #(.WIDTH(2), .CLK_POLARITY(0), .ARST_POLARITY(1'b1), .ARST_VALUE(2'b01)) dff9 (.CLK(C), .ARST(R), .D(D), .Q(Q[12:11]));
 endmodule
 EOT
+equiv_opt -assert -map +/simcells.v -multiclock zinit
+design -load postopt
+
 select -assert-count 0 t:$_NOT_
 select -assert-count 1 w:unused a:init %i
-select -assert-count 1 w:Q a:init=13'bx00x100000000 %i
+select -assert-count 1 w:Q a:init=13'bxxxx1xxxxxxxx %i
+select -assert-count 4 c:dff0 c:dff2 c:dff4 c:dff6 %% t:$_DFF_??0_ %i
+select -assert-count 4 c:dff1 c:dff3 c:dff5 c:dff7 %% t:$_DFF_??1_ %i