aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddie Hung <eddie@fpgeh.com>2019-07-16 13:52:43 -0700
committerGitHub <noreply@github.com>2019-07-16 13:52:43 -0700
commitf8e470c1d1178680034a28a9f28b161acf667701 (patch)
tree56df7f3af384b991d1271f7d53b80ee5dd0f0fd4
parent5939b5d636f80d4f9345f5b8d0247332d533b68c (diff)
parent7a58ee78dc8bd2c257498dc947081a1bba7bb54f (diff)
downloadyosys-f8e470c1d1178680034a28a9f28b161acf667701.tar.gz
yosys-f8e470c1d1178680034a28a9f28b161acf667701.tar.bz2
yosys-f8e470c1d1178680034a28a9f28b161acf667701.zip
Merge pull request #1202 from YosysHQ/cmp2lut_lut6
cmp2lut transformation to support >32 bit LUT masks
-rw-r--r--techlibs/common/cmp2lut.v2
-rw-r--r--tests/lut/check_map_lut6.ys7
-rw-r--r--tests/lut/map_cmp.v47
-rwxr-xr-xtests/lut/run-test.sh5
4 files changed, 37 insertions, 24 deletions
diff --git a/techlibs/common/cmp2lut.v b/techlibs/common/cmp2lut.v
index 8aa1eb957..0d0757767 100644
--- a/techlibs/common/cmp2lut.v
+++ b/techlibs/common/cmp2lut.v
@@ -27,7 +27,7 @@ parameter _TECHMAP_CONSTVAL_A_ = 0;
parameter _TECHMAP_CONSTMSK_B_ = 0;
parameter _TECHMAP_CONSTVAL_B_ = 0;
-function automatic integer gen_lut;
+function automatic [(1 << `LUT_WIDTH)-1:0] gen_lut;
input integer width;
input integer operation;
input integer swap;
diff --git a/tests/lut/check_map_lut6.ys b/tests/lut/check_map_lut6.ys
new file mode 100644
index 000000000..8a32e4d10
--- /dev/null
+++ b/tests/lut/check_map_lut6.ys
@@ -0,0 +1,7 @@
+chparam -set LUT_WIDTH 6 top
+simplemap
+equiv_opt -assert techmap -D LUT_WIDTH=6 -map +/cmp2lut.v
+design -load postopt
+equiv_opt -assert techmap -D LUT_WIDTH=6 -map +/gate2lut.v
+design -load postopt
+select -assert-count 0 t:* t:$lut %d
diff --git a/tests/lut/map_cmp.v b/tests/lut/map_cmp.v
index 5e413f894..0014eb9ac 100644
--- a/tests/lut/map_cmp.v
+++ b/tests/lut/map_cmp.v
@@ -1,29 +1,30 @@
module top(...);
- input [3:0] a;
+ parameter LUT_WIDTH = 4; // Multiples of 2 only
+ input [LUT_WIDTH-1:0] a;
- output o1_1 = 4'b1010 <= a;
- output o1_2 = 4'b1010 < a;
- output o1_3 = 4'b1010 >= a;
- output o1_4 = 4'b1010 > a;
- output o1_5 = 4'b1010 == a;
- output o1_6 = 4'b1010 != a;
+ output o1_1 = {(LUT_WIDTH/2){2'b10}} <= a;
+ output o1_2 = {(LUT_WIDTH/2){2'b10}} < a;
+ output o1_3 = {(LUT_WIDTH/2){2'b10}} >= a;
+ output o1_4 = {(LUT_WIDTH/2){2'b10}} > a;
+ output o1_5 = {(LUT_WIDTH/2){2'b10}} == a;
+ output o1_6 = {(LUT_WIDTH/2){2'b10}} != a;
- output o2_1 = a <= 4'b1010;
- output o2_2 = a < 4'b1010;
- output o2_3 = a >= 4'b1010;
- output o2_4 = a > 4'b1010;
- output o2_5 = a == 4'b1010;
- output o2_6 = a != 4'b1010;
+ output o2_1 = a <= {(LUT_WIDTH/2){2'b10}};
+ output o2_2 = a < {(LUT_WIDTH/2){2'b10}};
+ output o2_3 = a >= {(LUT_WIDTH/2){2'b10}};
+ output o2_4 = a > {(LUT_WIDTH/2){2'b10}};
+ output o2_5 = a == {(LUT_WIDTH/2){2'b10}};
+ output o2_6 = a != {(LUT_WIDTH/2){2'b10}};
- output o3_1 = 4'sb0101 <= $signed(a);
- output o3_2 = 4'sb0101 < $signed(a);
- output o3_3 = 4'sb0101 >= $signed(a);
- output o3_4 = 4'sb0101 > $signed(a);
- output o3_5 = 4'sb0101 == $signed(a);
- output o3_6 = 4'sb0101 != $signed(a);
+ output o3_1 = {(LUT_WIDTH/2){2'sb01}} <= $signed(a);
+ output o3_2 = {(LUT_WIDTH/2){2'sb01}} < $signed(a);
+ output o3_3 = {(LUT_WIDTH/2){2'sb01}} >= $signed(a);
+ output o3_4 = {(LUT_WIDTH/2){2'sb01}} > $signed(a);
+ output o3_5 = {(LUT_WIDTH/2){2'sb01}} == $signed(a);
+ output o3_6 = {(LUT_WIDTH/2){2'sb01}} != $signed(a);
- output o4_1 = $signed(a) <= 4'sb0000;
- output o4_2 = $signed(a) < 4'sb0000;
- output o4_3 = $signed(a) >= 4'sb0000;
- output o4_4 = $signed(a) > 4'sb0000;
+ output o4_1 = $signed(a) <= {LUT_WIDTH{1'sb0}};
+ output o4_2 = $signed(a) < {LUT_WIDTH{1'sb0}};
+ output o4_3 = $signed(a) >= {LUT_WIDTH{1'sb0}};
+ output o4_4 = $signed(a) > {LUT_WIDTH{1'sb0}};
endmodule
diff --git a/tests/lut/run-test.sh b/tests/lut/run-test.sh
index 207417fa6..f8964f146 100755
--- a/tests/lut/run-test.sh
+++ b/tests/lut/run-test.sh
@@ -4,3 +4,8 @@ for x in *.v; do
echo "Running $x.."
../../yosys -q -s check_map.ys -l ${x%.v}.log $x
done
+
+for x in map_cmp.v; do
+ echo "Running $x.."
+ ../../yosys -q -s check_map_lut6.ys -l ${x%.v}_lut6.log $x
+done