aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEddie Hung <eddie@fpgeh.com>2019-08-20 20:18:17 -0700
committerEddie Hung <eddie@fpgeh.com>2019-08-20 20:18:17 -0700
commitb7a48e3e0f49f09e12a2b394b62256a87c398dbc (patch)
tree9667249b7e1ab86c264f44d0a2f03b326e2763fa /tests
parentc320abc3f490b09b21804581c2b386c30d186a1e (diff)
parent33960dd3d84b628f6e5de45c112368dc80626457 (diff)
downloadyosys-b7a48e3e0f49f09e12a2b394b62256a87c398dbc.tar.gz
yosys-b7a48e3e0f49f09e12a2b394b62256a87c398dbc.tar.bz2
yosys-b7a48e3e0f49f09e12a2b394b62256a87c398dbc.zip
Merge remote-tracking branch 'origin/master' into xc7dsp
Diffstat (limited to 'tests')
-rwxr-xr-xtests/fsm/run-test.sh2
-rw-r--r--tests/opt/opt_expr.ys (renamed from tests/various/opt_expr.ys)0
-rw-r--r--tests/opt/opt_ff.v21
-rw-r--r--tests/opt/opt_ff.ys3
-rw-r--r--tests/opt/opt_lut.ys4
-rw-r--r--tests/opt/opt_rmdff.v (renamed from tests/various/opt_rmdff.v)0
-rw-r--r--tests/opt/opt_rmdff.ys (renamed from tests/various/opt_rmdff.ys)10
-rw-r--r--tests/opt/opt_rmdff_sat.v (renamed from tests/opt/opt_ff_sat.v)0
-rw-r--r--tests/opt/opt_rmdff_sat.ys (renamed from tests/opt/opt_ff_sat.ys)2
-rw-r--r--tests/opt/opt_share_add_sub.v10
-rw-r--r--tests/opt/opt_share_add_sub.ys13
-rw-r--r--tests/opt/opt_share_cat.v15
-rw-r--r--tests/opt/opt_share_cat.ys13
-rw-r--r--tests/opt/opt_share_cat_multiuser.v22
-rw-r--r--tests/opt/opt_share_cat_multiuser.ys13
-rw-r--r--tests/opt/opt_share_diff_port_widths.v21
-rw-r--r--tests/opt/opt_share_diff_port_widths.ys13
-rw-r--r--tests/opt/opt_share_extend.v18
-rw-r--r--tests/opt/opt_share_extend.ys13
-rw-r--r--tests/opt/opt_share_large_pmux_cat.v21
-rw-r--r--tests/opt/opt_share_large_pmux_cat.ys13
-rw-r--r--tests/opt/opt_share_large_pmux_cat_multipart.v25
-rw-r--r--tests/opt/opt_share_large_pmux_cat_multipart.ys14
-rw-r--r--tests/opt/opt_share_large_pmux_multipart.v23
-rw-r--r--tests/opt/opt_share_large_pmux_multipart.ys13
-rw-r--r--tests/opt/opt_share_large_pmux_part.v21
-rw-r--r--tests/opt/opt_share_large_pmux_part.ys13
-rw-r--r--tests/opt/opt_share_mux_tree.v18
-rw-r--r--tests/opt/opt_share_mux_tree.ys13
-rw-r--r--tests/opt_share/.gitignore1
-rw-r--r--tests/opt_share/generate.py86
-rwxr-xr-xtests/opt_share/run-test.sh39
-rw-r--r--tests/proc/.gitignore1
-rw-r--r--tests/proc/bug_1268.v23
-rw-r--r--tests/proc/bug_1268.ys5
-rwxr-xr-xtests/proc/run-test.sh6
-rw-r--r--tests/simple/realexpr.v11
-rw-r--r--tests/simple_abc9/.gitignore1
-rwxr-xr-xtests/simple_abc9/run-test.sh3
-rw-r--r--tests/various/.gitignore1
-rw-r--r--tests/various/muxpack.ys30
-rw-r--r--tests/various/pmgen_reduce.ys21
-rwxr-xr-xtests/various/run-test.sh16
-rw-r--r--tests/various/shregmap.ys22
-rw-r--r--tests/various/wreduce.ys33
-rw-r--r--tests/various/write_gzip.ys4
46 files changed, 601 insertions, 69 deletions
diff --git a/tests/fsm/run-test.sh b/tests/fsm/run-test.sh
index cf506470d..fbdcbf048 100755
--- a/tests/fsm/run-test.sh
+++ b/tests/fsm/run-test.sh
@@ -6,7 +6,7 @@
set -e
OPTIND=1
-count=100
+count=50
seed="" # default to no seed specified
while getopts "c:S:" opt
do
diff --git a/tests/various/opt_expr.ys b/tests/opt/opt_expr.ys
index f0306efa1..f0306efa1 100644
--- a/tests/various/opt_expr.ys
+++ b/tests/opt/opt_expr.ys
diff --git a/tests/opt/opt_ff.v b/tests/opt/opt_ff.v
deleted file mode 100644
index a01b64b61..000000000
--- a/tests/opt/opt_ff.v
+++ /dev/null
@@ -1,21 +0,0 @@
-module top(
- input clk,
- input rst,
- input [2:0] a,
- output [1:0] b
-);
- reg [2:0] b_reg;
- initial begin
- b_reg <= 3'b0;
- end
-
- assign b = b_reg[1:0];
- always @(posedge clk or posedge rst) begin
- if(rst) begin
- b_reg <= 3'b0;
- end else begin
- b_reg <= a;
- end
- end
-endmodule
-
diff --git a/tests/opt/opt_ff.ys b/tests/opt/opt_ff.ys
deleted file mode 100644
index 704c7acf3..000000000
--- a/tests/opt/opt_ff.ys
+++ /dev/null
@@ -1,3 +0,0 @@
-read_verilog opt_ff.v
-synth_ice40
-ice40_unlut
diff --git a/tests/opt/opt_lut.ys b/tests/opt/opt_lut.ys
index 59b12c351..a9fccbb62 100644
--- a/tests/opt/opt_lut.ys
+++ b/tests/opt/opt_lut.ys
@@ -1,4 +1,2 @@
read_verilog opt_lut.v
-synth_ice40
-ice40_unlut
-equiv_opt -map +/ice40/cells_sim.v -assert opt_lut -dlogic SB_CARRY:I0=1:I1=2:CI=3
+equiv_opt -map +/ice40/cells_sim.v -assert synth_ice40
diff --git a/tests/various/opt_rmdff.v b/tests/opt/opt_rmdff.v
index b1c06703c..b1c06703c 100644
--- a/tests/various/opt_rmdff.v
+++ b/tests/opt/opt_rmdff.v
diff --git a/tests/various/opt_rmdff.ys b/tests/opt/opt_rmdff.ys
index 081f81782..83a162f44 100644
--- a/tests/various/opt_rmdff.ys
+++ b/tests/opt/opt_rmdff.ys
@@ -19,8 +19,8 @@ hierarchy -top equiv
equiv_simple -undef
equiv_status -assert
-design -load gold
-stat
-
-design -load gate
-stat
+#design -load gold
+#stat
+#
+#design -load gate
+#stat
diff --git a/tests/opt/opt_ff_sat.v b/tests/opt/opt_rmdff_sat.v
index 5a0a6fe37..5a0a6fe37 100644
--- a/tests/opt/opt_ff_sat.v
+++ b/tests/opt/opt_rmdff_sat.v
diff --git a/tests/opt/opt_ff_sat.ys b/tests/opt/opt_rmdff_sat.ys
index 4e7cc6ca4..1c3dd9c05 100644
--- a/tests/opt/opt_ff_sat.ys
+++ b/tests/opt/opt_rmdff_sat.ys
@@ -1,4 +1,4 @@
-read_verilog opt_ff_sat.v
+read_verilog opt_rmdff_sat.v
prep -flatten
opt_rmdff -sat
synth
diff --git a/tests/opt/opt_share_add_sub.v b/tests/opt/opt_share_add_sub.v
new file mode 100644
index 000000000..d918f27cc
--- /dev/null
+++ b/tests/opt/opt_share_add_sub.v
@@ -0,0 +1,10 @@
+module opt_share_test(
+ input [15:0] a,
+ input [15:0] b,
+ input sel,
+ output [15:0] res,
+ );
+
+ assign res = {sel ? a + b : a - b};
+
+endmodule
diff --git a/tests/opt/opt_share_add_sub.ys b/tests/opt/opt_share_add_sub.ys
new file mode 100644
index 000000000..4a5406791
--- /dev/null
+++ b/tests/opt/opt_share_add_sub.ys
@@ -0,0 +1,13 @@
+read_verilog opt_share_add_sub.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 1 -module merged t:$alu
diff --git a/tests/opt/opt_share_cat.v b/tests/opt/opt_share_cat.v
new file mode 100644
index 000000000..7fb97fef5
--- /dev/null
+++ b/tests/opt/opt_share_cat.v
@@ -0,0 +1,15 @@
+module opt_share_test(
+ input [15:0] a,
+ input [15:0] b,
+ input [15:0] c,
+ input [15:0] d,
+ input sel,
+ output [63:0] res,
+ );
+
+ reg [31: 0] cat1 = {a+b, c+d};
+ reg [31: 0] cat2 = {a-b, c-d};
+
+ assign res = {b, sel ? cat1 : cat2, a};
+
+endmodule
diff --git a/tests/opt/opt_share_cat.ys b/tests/opt/opt_share_cat.ys
new file mode 100644
index 000000000..7de69bfde
--- /dev/null
+++ b/tests/opt/opt_share_cat.ys
@@ -0,0 +1,13 @@
+read_verilog opt_share_cat.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 2 -module merged t:$alu
diff --git a/tests/opt/opt_share_cat_multiuser.v b/tests/opt/opt_share_cat_multiuser.v
new file mode 100644
index 000000000..b250689d9
--- /dev/null
+++ b/tests/opt/opt_share_cat_multiuser.v
@@ -0,0 +1,22 @@
+module opt_share_test(
+ input [15:0] a,
+ input [15:0] b,
+ input [15:0] c,
+ input [15:0] d,
+ input sel,
+ output reg [47:0] res,
+ );
+
+ wire [15:0] add_res = a+b;
+ wire [15:0] sub_res = a-b;
+ wire [31: 0] cat1 = {add_res, c+d};
+ wire [31: 0] cat2 = {sub_res, c-d};
+
+ always @* begin
+ case(sel)
+ 0: res = {cat1, add_res};
+ 1: res = {cat2, add_res};
+ endcase
+ end
+
+endmodule
diff --git a/tests/opt/opt_share_cat_multiuser.ys b/tests/opt/opt_share_cat_multiuser.ys
new file mode 100644
index 000000000..6a82fbd79
--- /dev/null
+++ b/tests/opt/opt_share_cat_multiuser.ys
@@ -0,0 +1,13 @@
+read_verilog opt_share_cat_multiuser.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 3 -module merged t:$alu
diff --git a/tests/opt/opt_share_diff_port_widths.v b/tests/opt/opt_share_diff_port_widths.v
new file mode 100644
index 000000000..1a37c80a6
--- /dev/null
+++ b/tests/opt/opt_share_diff_port_widths.v
@@ -0,0 +1,21 @@
+module opt_share_test(
+ input [15:0] a,
+ input [15:0] b,
+ input [15:0] c,
+ input [1:0] sel,
+ output reg [15:0] res
+ );
+
+ wire [15:0] add0_res = a+b;
+ wire [15:0] add1_res = a+c;
+
+ always @* begin
+ case(sel)
+ 0: res = add0_res[10:0];
+ 1: res = add1_res[10:0];
+ 2: res = a - b;
+ default: res = 32'bx;
+ endcase
+ end
+
+endmodule
diff --git a/tests/opt/opt_share_diff_port_widths.ys b/tests/opt/opt_share_diff_port_widths.ys
new file mode 100644
index 000000000..ec5e9f7b0
--- /dev/null
+++ b/tests/opt/opt_share_diff_port_widths.ys
@@ -0,0 +1,13 @@
+read_verilog opt_share_diff_port_widths.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 2 -module merged t:$alu
diff --git a/tests/opt/opt_share_extend.v b/tests/opt/opt_share_extend.v
new file mode 100644
index 000000000..d39f19069
--- /dev/null
+++ b/tests/opt/opt_share_extend.v
@@ -0,0 +1,18 @@
+module opt_share_test(
+ input signed [7:0] a,
+ input signed [10:0] b,
+ input signed [15:0] c,
+ input [1:0] sel,
+ output reg signed [15:0] res
+ );
+
+ always @* begin
+ case(sel)
+ 0: res = a + b;
+ 1: res = a - b;
+ 2: res = a + c;
+ default: res = 16'bx;
+ endcase
+ end
+
+endmodule
diff --git a/tests/opt/opt_share_extend.ys b/tests/opt/opt_share_extend.ys
new file mode 100644
index 000000000..c553ee0fb
--- /dev/null
+++ b/tests/opt/opt_share_extend.ys
@@ -0,0 +1,13 @@
+read_verilog opt_share_extend.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 1 -module merged t:$alu
diff --git a/tests/opt/opt_share_large_pmux_cat.v b/tests/opt/opt_share_large_pmux_cat.v
new file mode 100644
index 000000000..416ba3766
--- /dev/null
+++ b/tests/opt/opt_share_large_pmux_cat.v
@@ -0,0 +1,21 @@
+module opt_share_test(
+ input [15:0] a,
+ input [15:0] b,
+ input [15:0] c,
+ input [2:0] sel,
+ output reg [31:0] res
+ );
+
+ always @* begin
+ case(sel)
+ 0: res = {a + b, a};
+ 1: res = {a - b, b};
+ 2: res = {a + c, c};
+ 3: res = {a - c, a};
+ 4: res = {b, b};
+ 5: res = {c, c};
+ default: res = 32'bx;
+ endcase
+ end
+
+endmodule
diff --git a/tests/opt/opt_share_large_pmux_cat.ys b/tests/opt/opt_share_large_pmux_cat.ys
new file mode 100644
index 000000000..4186ca52e
--- /dev/null
+++ b/tests/opt/opt_share_large_pmux_cat.ys
@@ -0,0 +1,13 @@
+read_verilog opt_share_large_pmux_cat.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 1 -module merged t:$alu
diff --git a/tests/opt/opt_share_large_pmux_cat_multipart.v b/tests/opt/opt_share_large_pmux_cat_multipart.v
new file mode 100644
index 000000000..34d2bd9a8
--- /dev/null
+++ b/tests/opt/opt_share_large_pmux_cat_multipart.v
@@ -0,0 +1,25 @@
+module opt_share_test(
+ input [15:0] a,
+ input [15:0] b,
+ input [15:0] c,
+ input [15:0] d,
+ input [2:0] sel,
+ output reg [31:0] res
+ );
+
+ wire [15:0] add0_res = a+d;
+
+ always @* begin
+ case(sel)
+ 0: res = {add0_res, a};
+ 1: res = {a - b, add0_res[7], 15'b0};
+ 2: res = {b-a, b};
+ 3: res = {d, b - c};
+ 4: res = {d, b - a};
+ 5: res = {c, d};
+ 6: res = {a - c, b-d};
+ default: res = 32'bx;
+ endcase
+ end
+
+endmodule
diff --git a/tests/opt/opt_share_large_pmux_cat_multipart.ys b/tests/opt/opt_share_large_pmux_cat_multipart.ys
new file mode 100644
index 000000000..610bb8c6c
--- /dev/null
+++ b/tests/opt/opt_share_large_pmux_cat_multipart.ys
@@ -0,0 +1,14 @@
+read_verilog opt_share_large_pmux_cat_multipart.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 4 -module merged t:$alu
diff --git a/tests/opt/opt_share_large_pmux_multipart.v b/tests/opt/opt_share_large_pmux_multipart.v
new file mode 100644
index 000000000..535adf96f
--- /dev/null
+++ b/tests/opt/opt_share_large_pmux_multipart.v
@@ -0,0 +1,23 @@
+module opt_share_test(
+ input [15:0] a,
+ input [15:0] b,
+ input [15:0] c,
+ input [15:0] d,
+ input [2:0] sel,
+ output reg [15:0] res
+ );
+
+ always @* begin
+ case(sel)
+ 0: res = a + d;
+ 1: res = a - b;
+ 2: res = b;
+ 3: res = b - c;
+ 4: res = b - a;
+ 5: res = c;
+ 6: res = a - c;
+ default: res = 16'bx;
+ endcase
+ end
+
+endmodule
diff --git a/tests/opt/opt_share_large_pmux_multipart.ys b/tests/opt/opt_share_large_pmux_multipart.ys
new file mode 100644
index 000000000..11182df1a
--- /dev/null
+++ b/tests/opt/opt_share_large_pmux_multipart.ys
@@ -0,0 +1,13 @@
+read_verilog opt_share_large_pmux_multipart.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 2 -module merged t:$alu
diff --git a/tests/opt/opt_share_large_pmux_part.v b/tests/opt/opt_share_large_pmux_part.v
new file mode 100644
index 000000000..a9008fb5a
--- /dev/null
+++ b/tests/opt/opt_share_large_pmux_part.v
@@ -0,0 +1,21 @@
+module opt_share_test(
+ input [15:0] a,
+ input [15:0] b,
+ input [15:0] c,
+ input [2:0] sel,
+ output reg [15:0] res
+ );
+
+ always @* begin
+ case(sel)
+ 0: res = a + b;
+ 1: res = a - b;
+ 2: res = a + c;
+ 3: res = a - c;
+ 4: res = b;
+ 5: res = c;
+ default: res = 16'bx;
+ endcase
+ end
+
+endmodule
diff --git a/tests/opt/opt_share_large_pmux_part.ys b/tests/opt/opt_share_large_pmux_part.ys
new file mode 100644
index 000000000..6b594a3d6
--- /dev/null
+++ b/tests/opt/opt_share_large_pmux_part.ys
@@ -0,0 +1,13 @@
+read_verilog opt_share_large_pmux_part.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 1 -module merged t:$alu
diff --git a/tests/opt/opt_share_mux_tree.v b/tests/opt/opt_share_mux_tree.v
new file mode 100644
index 000000000..cc5ae4eb9
--- /dev/null
+++ b/tests/opt/opt_share_mux_tree.v
@@ -0,0 +1,18 @@
+module opt_share_test(
+ input [15:0] a,
+ input [15:0] b,
+ input [15:0] c,
+ input [1:0] sel,
+ output reg [15:0] res
+ );
+
+ always @* begin
+ case(sel)
+ 0: res = a + b;
+ 1: res = a - b;
+ 2: res = a + c;
+ default: res = 16'bx;
+ endcase
+ end
+
+endmodule
diff --git a/tests/opt/opt_share_mux_tree.ys b/tests/opt/opt_share_mux_tree.ys
new file mode 100644
index 000000000..58473039f
--- /dev/null
+++ b/tests/opt/opt_share_mux_tree.ys
@@ -0,0 +1,13 @@
+read_verilog opt_share_mux_tree.v
+proc;;
+copy opt_share_test merged
+
+alumacc merged
+opt merged
+opt_share merged
+opt_clean merged
+
+miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp opt_share_test merged miter
+sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter
+
+select -assert-count 1 -module merged t:$alu
diff --git a/tests/opt_share/.gitignore b/tests/opt_share/.gitignore
new file mode 100644
index 000000000..9c595a6fb
--- /dev/null
+++ b/tests/opt_share/.gitignore
@@ -0,0 +1 @@
+temp
diff --git a/tests/opt_share/generate.py b/tests/opt_share/generate.py
new file mode 100644
index 000000000..2ec92f7de
--- /dev/null
+++ b/tests/opt_share/generate.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+
+import argparse
+import sys
+import random
+from contextlib import contextmanager
+
+
+@contextmanager
+def redirect_stdout(new_target):
+ old_target, sys.stdout = sys.stdout, new_target
+ try:
+ yield new_target
+ finally:
+ sys.stdout = old_target
+
+
+def random_plus_x():
+ return "%s x" % random.choice(['+', '+', '+', '-', '-', '|', '&', '^'])
+
+
+def maybe_plus_x(expr):
+ if random.randint(0, 4) == 0:
+ return "(%s %s)" % (expr, random_plus_x())
+ else:
+ return expr
+
+
+parser = argparse.ArgumentParser(
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+parser.add_argument('-S', '--seed', type=int, help='seed for PRNG')
+parser.add_argument('-c',
+ '--count',
+ type=int,
+ default=100,
+ help='number of test cases to generate')
+args = parser.parse_args()
+
+if args.seed is not None:
+ print("PRNG seed: %d" % args.seed)
+ random.seed(args.seed)
+
+for idx in range(args.count):
+ with open('temp/uut_%05d.v' % idx, 'w') as f:
+ with redirect_stdout(f):
+ print('module uut_%05d(a, b, c, s, y);' % (idx))
+ op = random.choice([
+ random.choice(['+', '-', '*', '/', '%']),
+ random.choice(['<', '<=', '==', '!=', '===', '!==', '>=',
+ '>']),
+ random.choice(['<<', '>>', '<<<', '>>>']),
+ random.choice(['|', '&', '^', '~^', '||', '&&']),
+ ])
+ print(' input%s [%d:0] a;' % (random.choice(['', ' signed']), 8))
+ print(' input%s [%d:0] b;' % (random.choice(['', ' signed']), 8))
+ print(' input%s [%d:0] c;' % (random.choice(['', ' signed']), 8))
+ print(' input s;')
+ print(' output [%d:0] y;' % 8)
+ ops1 = ['a', 'b']
+ ops2 = ['a', 'c']
+ random.shuffle(ops1)
+ random.shuffle(ops2)
+ cast1 = random.choice(['', '$signed', '$unsigned'])
+ cast2 = random.choice(['', '$signed', '$unsigned'])
+ print(' assign y = (s ? %s(%s %s %s) : %s(%s %s %s));' %
+ (cast1, ops1[0], op, ops1[1],
+ cast2, ops2[0], op, ops2[1]))
+ print('endmodule')
+
+ with open('temp/uut_%05d.ys' % idx, 'w') as f:
+ with redirect_stdout(f):
+ print('read_verilog temp/uut_%05d.v' % idx)
+ print('proc;;')
+ print('copy uut_%05d gold' % idx)
+ print('rename uut_%05d gate' % idx)
+ print('tee -a temp/all_share_log.txt log')
+ print('tee -a temp/all_share_log.txt log #job# uut_%05d' % idx)
+ print('tee -a temp/all_share_log.txt opt gate')
+ print('tee -a temp/all_share_log.txt opt_share gate')
+ print('tee -a temp/all_share_log.txt opt_clean gate')
+ print(
+ 'miter -equiv -flatten -ignore_gold_x -make_outputs -make_outcmp gold gate miter'
+ )
+ print(
+ 'sat -set-def-inputs -verify -prove trigger 0 -show-inputs -show-outputs miter'
+ )
diff --git a/tests/opt_share/run-test.sh b/tests/opt_share/run-test.sh
new file mode 100755
index 000000000..e01552646
--- /dev/null
+++ b/tests/opt_share/run-test.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+# run this test many times:
+# time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
+
+set -e
+
+OPTIND=1
+count=100
+seed="" # default to no seed specified
+while getopts "c:S:" opt
+do
+ case "$opt" in
+ c) count="$OPTARG" ;;
+ S) seed="-S $OPTARG" ;;
+ esac
+done
+shift "$((OPTIND-1))"
+
+rm -rf temp
+mkdir -p temp
+echo "generating tests.."
+python3 generate.py -c $count $seed
+
+echo "running tests.."
+for i in $( ls temp/*.ys | sed 's,[^0-9],,g; s,^0*\(.\),\1,g;' ); do
+ echo -n "[$i]"
+ idx=$( printf "%05d" $i )
+ ../../yosys -ql temp/uut_${idx}.log temp/uut_${idx}.ys
+done
+echo
+
+failed_share=$( echo $( gawk '/^#job#/ { j=$2; db[j]=0; } /^Removing [246] cells/ { delete db[j]; } END { for (j in db) print(j); }' temp/all_share_log.txt ) )
+if [ -n "$failed_share" ]; then
+ echo "Resource sharing failed for the following test cases: $failed_share"
+ false
+fi
+
+exit 0
diff --git a/tests/proc/.gitignore b/tests/proc/.gitignore
new file mode 100644
index 000000000..397b4a762
--- /dev/null
+++ b/tests/proc/.gitignore
@@ -0,0 +1 @@
+*.log
diff --git a/tests/proc/bug_1268.v b/tests/proc/bug_1268.v
new file mode 100644
index 000000000..698ac937a
--- /dev/null
+++ b/tests/proc/bug_1268.v
@@ -0,0 +1,23 @@
+module gold (input clock, ctrl, din, output reg dout);
+ always @(posedge clock) begin
+ if (1'b1) begin
+ if (1'b0) begin end else begin
+ dout <= 0;
+ end
+ if (ctrl)
+ dout <= din;
+ end
+ end
+endmodule
+
+module gate (input clock, ctrl, din, output reg dout);
+ always @(posedge clock) begin
+ if (1'b1) begin
+ if (1'b0) begin end else begin
+ dout <= 0;
+ end
+ end
+ if (ctrl)
+ dout <= din;
+ end
+endmodule
diff --git a/tests/proc/bug_1268.ys b/tests/proc/bug_1268.ys
new file mode 100644
index 000000000..b73e94449
--- /dev/null
+++ b/tests/proc/bug_1268.ys
@@ -0,0 +1,5 @@
+read_verilog bug_1268.v
+proc
+equiv_make gold gate equiv
+equiv_induct
+equiv_status -assert
diff --git a/tests/proc/run-test.sh b/tests/proc/run-test.sh
new file mode 100755
index 000000000..44ce7e674
--- /dev/null
+++ b/tests/proc/run-test.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+set -e
+for x in *.ys; do
+ echo "Running $x.."
+ ../../yosys -ql ${x%.ys}.log $x
+done
diff --git a/tests/simple/realexpr.v b/tests/simple/realexpr.v
index 5b756e6be..74ed8faa5 100644
--- a/tests/simple/realexpr.v
+++ b/tests/simple/realexpr.v
@@ -1,4 +1,3 @@
-
module demo_001(y1, y2, y3, y4);
output [7:0] y1, y2, y3, y4;
@@ -22,3 +21,13 @@ module demo_002(y0, y1, y2, y3);
assign y3 = 1 ? -1 : 'd0;
endmodule
+module demo_003(output A, B);
+ parameter real p = 0;
+ assign A = (p==1.0);
+ assign B = (p!="1.000000");
+endmodule
+
+module demo_004(output A, B, C, D);
+ demo_003 #(1.0) demo_real (A, B);
+ demo_003 #(1) demo_int (C, D);
+endmodule
diff --git a/tests/simple_abc9/.gitignore b/tests/simple_abc9/.gitignore
index 598951333..2355aea29 100644
--- a/tests/simple_abc9/.gitignore
+++ b/tests/simple_abc9/.gitignore
@@ -1,3 +1,4 @@
*.v
+*.sv
*.log
*.out
diff --git a/tests/simple_abc9/run-test.sh b/tests/simple_abc9/run-test.sh
index 4935d41ad..49ae23338 100755
--- a/tests/simple_abc9/run-test.sh
+++ b/tests/simple_abc9/run-test.sh
@@ -18,5 +18,6 @@ if ! which iverilog > /dev/null ; then
fi
cp ../simple/*.v .
+cp ../simple/*.sv .
DOLLAR='?'
-exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.v EXTRA_FLAGS="-p 'hierarchy; synth -run coarse; opt -full; techmap; abc9 -lut 4 -box ../abc.box; stat; check -assert; select -assert-none t:${DOLLAR}_NOT_ t:${DOLLAR}_AND_ %%'"
+exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.v EXTRA_FLAGS="-n 300 -p 'hierarchy; synth -run coarse; opt -full; techmap; abc9 -lut 4 -box ../abc.box; stat; check -assert; select -assert-none t:${DOLLAR}_NOT_ t:${DOLLAR}_AND_ %%'"
diff --git a/tests/various/.gitignore b/tests/various/.gitignore
index 31078b298..4b286fd61 100644
--- a/tests/various/.gitignore
+++ b/tests/various/.gitignore
@@ -2,3 +2,4 @@
/*.out
/write_gzip.v
/write_gzip.v.gz
+/run-test.mk
diff --git a/tests/various/muxpack.ys b/tests/various/muxpack.ys
index af23fcec8..3e90419af 100644
--- a/tests/various/muxpack.ys
+++ b/tests/various/muxpack.ys
@@ -6,7 +6,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 1 t:$pmux
design -stash gate
@@ -21,7 +21,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 1 t:$pmux
design -stash gate
@@ -52,7 +52,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 2 t:$pmux
design -stash gate
@@ -67,7 +67,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 1 t:$pmux
design -stash gate
@@ -82,7 +82,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 1 t:$pmux
design -stash gate
@@ -97,7 +97,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 1 t:$pmux
design -stash gate
@@ -112,7 +112,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 1 t:$pmux
design -stash gate
@@ -127,7 +127,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 1 t:$pmux
design -stash gate
@@ -142,7 +142,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 7 t:$mux
select -assert-count 0 t:$pmux
design -stash gate
@@ -157,7 +157,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 4 t:$mux
select -assert-count 0 t:$pmux
design -stash gate
@@ -172,7 +172,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 3 t:$mux
select -assert-count 0 t:$pmux
design -stash gate
@@ -204,7 +204,7 @@ prep
design -save gold
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 2 t:$pmux
design -stash gate
@@ -222,7 +222,7 @@ opt -fast -mux_undef
select -assert-count 2 t:$pmux
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 1 t:$pmux
design -stash gate
@@ -240,7 +240,7 @@ opt -fast -mux_undef
select -assert-count 2 t:$pmux
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 2 t:$pmux
design -stash gate
@@ -258,7 +258,7 @@ opt -fast -mux_undef
select -assert-count 2 t:$pmux
muxpack
opt
-stat
+#stat
select -assert-count 0 t:$mux
select -assert-count 2 t:$pmux
design -stash gate
diff --git a/tests/various/pmgen_reduce.ys b/tests/various/pmgen_reduce.ys
new file mode 100644
index 000000000..c214d3f25
--- /dev/null
+++ b/tests/various/pmgen_reduce.ys
@@ -0,0 +1,21 @@
+test_pmgen -generate reduce
+hierarchy -top pmtest_test_pmgen_pm_reduce
+flatten; opt_clean
+
+design -save gold
+test_pmgen -reduce_chain
+design -stash gate
+
+design -copy-from gold -as gold pmtest_test_pmgen_pm_reduce
+design -copy-from gate -as gate pmtest_test_pmgen_pm_reduce
+miter -equiv -flatten -make_assert gold gate miter
+sat -verify -prove-asserts miter
+
+design -load gold
+test_pmgen -reduce_tree
+design -stash gate
+
+design -copy-from gold -as gold pmtest_test_pmgen_pm_reduce
+design -copy-from gate -as gate pmtest_test_pmgen_pm_reduce
+miter -equiv -flatten -make_assert gold gate miter
+sat -verify -prove-asserts miter
diff --git a/tests/various/run-test.sh b/tests/various/run-test.sh
index 92b905765..ea56b70f0 100755
--- a/tests/various/run-test.sh
+++ b/tests/various/run-test.sh
@@ -1,12 +1,20 @@
#!/usr/bin/env bash
set -e
+{
+echo "all::"
for x in *.ys; do
- echo "Running $x.."
- ../../yosys -ql ${x%.ys}.log $x
+ echo "all:: run-$x"
+ echo "run-$x:"
+ echo " @echo 'Running $x..'"
+ echo " @../../yosys -ql ${x%.ys}.log $x"
done
for s in *.sh; do
if [ "$s" != "run-test.sh" ]; then
- echo "Running $s.."
- bash $s
+ echo "all:: run-$s"
+ echo "run-$s:"
+ echo " @echo 'Running $s..'"
+ echo " @bash $s"
fi
done
+} > run-test.mk
+exec ${MAKE:-make} -f run-test.mk
diff --git a/tests/various/shregmap.ys b/tests/various/shregmap.ys
index d644a88aa..0e5fe882b 100644
--- a/tests/various/shregmap.ys
+++ b/tests/various/shregmap.ys
@@ -11,7 +11,7 @@ shregmap -init
opt
-stat
+# stat
# show -width
select -assert-count 1 t:$_DFF_P_
select -assert-count 2 t:$__SHREG_DFF_P_
@@ -26,11 +26,11 @@ prep
miter -equiv -flatten -make_assert -make_outputs gold gate miter
sat -verify -prove-asserts -show-ports -seq 5 miter
-design -load gold
-stat
+#design -load gold
+#stat
-design -load gate
-stat
+#design -load gate
+#stat
##########
@@ -43,9 +43,9 @@ design -save gold
simplemap t:$dff t:$dffe
shregmap -tech xilinx
-stat
+#stat
# show -width
-write_verilog -noexpr -norename
+# write_verilog -noexpr -norename
select -assert-count 1 t:$_DFF_P_
select -assert-count 2 t:$__XILINX_SHREG_
@@ -59,8 +59,8 @@ prep
miter -equiv -flatten -make_assert -make_outputs gold gate miter
sat -verify -prove-asserts -show-ports -seq 5 miter
-design -load gold
-stat
+# design -load gold
+# stat
-design -load gate
-stat
+# design -load gate
+# stat
diff --git a/tests/various/wreduce.ys b/tests/various/wreduce.ys
index 4257292f5..2e0812c48 100644
--- a/tests/various/wreduce.ys
+++ b/tests/various/wreduce.ys
@@ -36,7 +36,6 @@ design -save gold
opt_expr
wreduce
-dump
select -assert-count 1 t:$sub r:A_WIDTH=4 r:B_WIDTH=4 r:Y_WIDTH=5 %i %i %i
design -stash gate
@@ -46,3 +45,35 @@ design -import gate -as gate
miter -equiv -flatten -make_assert -make_outputs gold gate miter
sat -verify -prove-asserts -show-ports miter
+
+##########
+
+# Testcase from: https://github.com/YosysHQ/yosys/commit/25680f6a078bb32f157bd580705656496717bafb
+design -reset
+read_verilog <<EOT
+module top(
+ input clk,
+ input rst,
+ input [2:0] a,
+ output [1:0] b
+);
+ reg [2:0] b_reg;
+ initial begin
+ b_reg <= 3'b0;
+ end
+
+ assign b = b_reg[1:0];
+ always @(posedge clk or posedge rst) begin
+ if(rst) begin
+ b_reg <= 3'b0;
+ end else begin
+ b_reg <= a;
+ end
+ end
+endmodule
+EOT
+
+proc
+wreduce
+
+select -assert-count 1 t:$adff r:ARST_VALUE=2'b00 %i
diff --git a/tests/various/write_gzip.ys b/tests/various/write_gzip.ys
index 030ec318e..524ecc33e 100644
--- a/tests/various/write_gzip.ys
+++ b/tests/various/write_gzip.ys
@@ -1,4 +1,4 @@
-read -vlog2k <<EOT
+read_verilog <<EOT
module top(input a, output y);
assign y = !a;
endmodule
@@ -10,7 +10,7 @@ design -reset
! rm -f write_gzip.v
! gunzip write_gzip.v.gz
-read -vlog2k write_gzip.v
+read_verilog write_gzip.v
! rm -f write_gzip.v
hierarchy -top top
select -assert-any top