Add quick-and-dirty specify tests
authorEddie Hung <eddie@fpgeh.com>
Fri, 3 May 2019 22:35:26 +0000 (15:35 -0700)
committerEddie Hung <eddie@fpgeh.com>
Fri, 3 May 2019 22:35:26 +0000 (15:35 -0700)
tests/various/specify.v [new file with mode: 0644]
tests/various/specify.ys [new file with mode: 0644]

diff --git a/tests/various/specify.v b/tests/various/specify.v
new file mode 100644 (file)
index 0000000..aea0d0f
--- /dev/null
@@ -0,0 +1,28 @@
+module test (
+       input EN, CLK,
+       input [3:0] D,
+       output reg [3:0] Q
+);
+       always @(posedge CLK)
+               if (EN) Q <= D;
+
+       specify
+               if (EN) (CLK *> (Q : D)) = (1, 2:3:4);
+               $setup(D, posedge CLK &&& EN, 5);
+               $hold(posedge CLK, D &&& EN, 6);
+       endspecify
+endmodule
+
+module test2 (
+    input A, B,
+       output Q
+);
+    xor (Q, A, B);
+       specify
+               //specparam T_rise = 1;
+        //specparam T_fall = 2;
+        `define T_rise 1
+        `define T_fall 2
+        (A => Q) = (`T_rise,`T_fall);
+       endspecify
+endmodule
diff --git a/tests/various/specify.ys b/tests/various/specify.ys
new file mode 100644 (file)
index 0000000..c4e9017
--- /dev/null
@@ -0,0 +1,25 @@
+read_verilog -specify specify.v
+prep
+cd test
+select t:$specify2 -assert-count 0
+select t:$specify3 -assert-count 1
+select t:$specrule -assert-count 2
+cd test2
+select t:$specify2 -assert-count 1
+select t:$specify3 -assert-count 0
+select t:$specrule -assert-count 0
+write_verilog specify.out
+design -stash gold
+
+read_verilog -specify specify.out
+cd test
+select t:$specify2 -assert-count 0
+select t:$specify3 -assert-count 1
+select t:$specrule -assert-count 2
+cd test2
+select t:$specify2 -assert-count 1
+select t:$specify3 -assert-count 0
+select t:$specrule -assert-count 0
+design -stash gate
+
+# TODO: How to check $specify and $specrule-s are equivalent?