aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-11-16 18:36:16 +0100
committerTristan Gingold <tgingold@free.fr>2021-11-16 18:36:16 +0100
commit6093b398e4745ff56bf5c6f320f6949a11abb135 (patch)
tree189db0d93fee47a6043beede4d216fa935d69d81 /testsuite/synth
parent7aa4b1e64d5aaf35acb7ebe25c861336fcabfcc4 (diff)
downloadghdl-6093b398e4745ff56bf5c6f320f6949a11abb135.tar.gz
ghdl-6093b398e4745ff56bf5c6f320f6949a11abb135.tar.bz2
ghdl-6093b398e4745ff56bf5c6f320f6949a11abb135.zip
testsuite/synth: add a test for #1912
Diffstat (limited to 'testsuite/synth')
-rw-r--r--testsuite/synth/issue1912/popcount.vhdl75
-rwxr-xr-xtestsuite/synth/issue1912/testsuite.sh7
2 files changed, 82 insertions, 0 deletions
diff --git a/testsuite/synth/issue1912/popcount.vhdl b/testsuite/synth/issue1912/popcount.vhdl
new file mode 100644
index 000000000..174b50f51
--- /dev/null
+++ b/testsuite/synth/issue1912/popcount.vhdl
@@ -0,0 +1,75 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+library work;
+use work.all;
+
+entity popcount is
+ generic (
+ SIZE : natural := 32
+ );
+ port (
+ -- Input data
+ data : in std_logic_vector(SIZE-1 downto 0);
+ -- Results
+ num : out std_logic
+ );
+end entity;
+
+architecture synth of popcount is
+
+ -- Component declaration of itself, for recursive instantiation
+
+ component popcount is
+ generic (
+ SIZE : natural := 32
+ );
+ port (
+ -- Input data
+ data : in std_logic_vector(SIZE-1 downto 0);
+ -- Results
+ num : out std_logic
+ );
+ end component;
+
+begin
+
+ n5 : if SIZE <= 5 generate
+
+ num <= '1';
+
+ end generate;
+
+ more : if SIZE >= 6 generate
+
+ signal num_1 : std_logic;
+ signal num_2 : std_logic;
+
+ constant SIZE_LOWER : natural := 4 * (SIZE / 5);
+
+ begin
+
+ inst1 : popcount
+ generic map (
+ SIZE => SIZE_LOWER
+ )
+ port map (
+ data => data(SIZE_LOWER-1 downto 0),
+ num => num_1
+ );
+
+ inst2 : popcount
+ generic map (
+ SIZE => SIZE - SIZE_LOWER
+ )
+ port map (
+ data => data(SIZE-1 downto SIZE_LOWER),
+ num => num_2
+ );
+
+ num <= num_1 or num_2;
+
+ end generate;
+
+end architecture;
diff --git a/testsuite/synth/issue1912/testsuite.sh b/testsuite/synth/issue1912/testsuite.sh
new file mode 100755
index 000000000..e41b66aee
--- /dev/null
+++ b/testsuite/synth/issue1912/testsuite.sh
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+synth popcount.vhdl -e popcount > syn_popcount.vhdl
+
+echo "Test successful"