dffinit: Avoid setting init parameter to zero-length value.
authorMarcelina Kościelnicka <mwk@0x04.net>
Tue, 14 Apr 2020 14:33:09 +0000 (16:33 +0200)
committerMarcelina Kościelnicka <mwk@0x04.net>
Tue, 14 Apr 2020 17:52:19 +0000 (19:52 +0200)
Fixes #1704.

passes/techmap/dffinit.cc
tests/techmap/dffinit.ys [new file with mode: 0644]

index 0424ce43403bab1b0418e9904623f6a8786e00cf..35645582b2ba7c57853bd056f92da82bfb9f9d47 100644 (file)
@@ -154,9 +154,11 @@ struct DffinitPass : public Pass {
                                                        value = Const(low_string);
                                        }
 
-                                       log("Setting %s.%s.%s (port=%s, net=%s) to %s.\n", log_id(module), log_id(cell), log_id(it.second),
-                                                       log_id(it.first), log_signal(sig), log_signal(value));
-                                       cell->setParam(it.second, value);
+                                       if (value.size() != 0) {
+                                               log("Setting %s.%s.%s (port=%s, net=%s) to %s.\n", log_id(module), log_id(cell), log_id(it.second),
+                                                               log_id(it.first), log_signal(sig), log_signal(value));
+                                               cell->setParam(it.second, value);
+                                       }
                                }
                        }
 
diff --git a/tests/techmap/dffinit.ys b/tests/techmap/dffinit.ys
new file mode 100644 (file)
index 0000000..218d411
--- /dev/null
@@ -0,0 +1,25 @@
+read_verilog <<EOT
+
+module ff(...);
+input d;
+output q;
+
+endmodule
+
+module top(...);
+input d;
+output q1;
+(* init = 1'b1 *)
+output q2;
+
+ff my_ff1(.d(d), .q(q1));
+ff my_ff2(.d(d), .q(q2));
+
+endmodule
+
+EOT
+
+dffinit -ff ff q init
+select -assert-count 2 t:ff
+select -assert-count 1 t:ff r:init %i
+select -assert-count 1 t:ff r:init=1'b1 %i