aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/issue1080
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-01-12 15:10:38 +0100
committerTristan Gingold <tgingold@free.fr>2020-01-12 15:10:38 +0100
commiteae3be4bb02f5dc701d59bffc43e9d45f4da0563 (patch)
tree538acb5289ad5e91005b6366b2da4ffa4eccf3b1 /testsuite/synth/issue1080
parent3ba257c6da4408d2014eedb4c8fc4a97f9110454 (diff)
downloadghdl-eae3be4bb02f5dc701d59bffc43e9d45f4da0563.tar.gz
ghdl-eae3be4bb02f5dc701d59bffc43e9d45f4da0563.tar.bz2
ghdl-eae3be4bb02f5dc701d59bffc43e9d45f4da0563.zip
testsuite/synth: add test for #1080
Diffstat (limited to 'testsuite/synth/issue1080')
-rw-r--r--testsuite/synth/issue1080/repro3.vhdl33
-rw-r--r--testsuite/synth/issue1080/repro3_1.vhdl30
-rw-r--r--testsuite/synth/issue1080/tb_repro3_1.vhdl30
-rwxr-xr-xtestsuite/synth/issue1080/testsuite.sh13
4 files changed, 105 insertions, 1 deletions
diff --git a/testsuite/synth/issue1080/repro3.vhdl b/testsuite/synth/issue1080/repro3.vhdl
new file mode 100644
index 000000000..252f705c8
--- /dev/null
+++ b/testsuite/synth/issue1080/repro3.vhdl
@@ -0,0 +1,33 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity repro3 is
+ port (
+ clk : std_logic;
+ led : out std_logic);
+end;
+
+architecture behav of repro3 is
+ constant LOOKUP_LEN : integer := 6;
+ constant LOOKUP_TABLE : unsigned(LOOKUP_LEN*8-1 downto 0) :=
+ x"010205" & x"060708";
+
+ signal brt : unsigned(7 downto 0) := (others => '0');
+
+begin
+ led <= brt (0);
+ lookup_p : process(Clk)
+ variable idx : integer range 0 to LOOKUP_LEN-1 := LOOKUP_LEN-1;
+ begin
+ if rising_edge(Clk) then
+ brt <= lookup_table(8*idx+7 downto 8*idx);
+
+ if idx /= 0 then
+ idx := idx - 1;
+ else
+ idx := LOOKUP_LEN-1;
+ end if;
+ end if;
+ end process;
+end behav;
diff --git a/testsuite/synth/issue1080/repro3_1.vhdl b/testsuite/synth/issue1080/repro3_1.vhdl
new file mode 100644
index 000000000..6a21d0f4c
--- /dev/null
+++ b/testsuite/synth/issue1080/repro3_1.vhdl
@@ -0,0 +1,30 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity repro3_1 is
+ port (
+ clk : std_logic;
+ led : out std_logic_vector(7 downto 0));
+end;
+
+architecture behav of repro3_1 is
+ constant LOOKUP_LEN : integer := 6;
+ constant LOOKUP_TABLE : std_logic_vector(LOOKUP_LEN*8-1 downto 0) :=
+ x"010205" & x"060708";
+ -- x"010205060708";
+ -- -> const_bit (0x5060708, 0x102)
+begin
+ lookup_p : process(Clk)
+ variable idx : integer range 0 to LOOKUP_LEN-1 := LOOKUP_LEN-1;
+ begin
+ if rising_edge(Clk) then
+ led <= lookup_table(8*idx+7 downto 8*idx);
+
+ if idx /= 0 then
+ idx := idx - 1;
+ else
+ idx := LOOKUP_LEN-1;
+ end if;
+ end if;
+ end process;
+end behav;
diff --git a/testsuite/synth/issue1080/tb_repro3_1.vhdl b/testsuite/synth/issue1080/tb_repro3_1.vhdl
new file mode 100644
index 000000000..229dcf17c
--- /dev/null
+++ b/testsuite/synth/issue1080/tb_repro3_1.vhdl
@@ -0,0 +1,30 @@
+entity tb_repro3_1 is
+end tb_repro3_1;
+
+library ieee;
+use ieee.std_logic_1164.all;
+
+architecture behav of tb_repro3_1 is
+ signal clk : std_logic;
+ signal led : std_logic_vector(7 downto 0);
+begin
+ dut: entity work.repro3_1
+ port map (clk, led);
+
+ process
+ procedure pulse is
+ begin
+ clk <= '0';
+ wait for 1 ns;
+ clk <= '1';
+ wait for 1 ns;
+ end pulse;
+ begin
+ pulse;
+ assert led = x"01" severity failure;
+
+ pulse;
+ assert led = x"02" severity failure;
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/synth/issue1080/testsuite.sh b/testsuite/synth/issue1080/testsuite.sh
index 24843415d..edb7da40a 100755
--- a/testsuite/synth/issue1080/testsuite.sh
+++ b/testsuite/synth/issue1080/testsuite.sh
@@ -2,10 +2,21 @@
. ../../testenv.sh
-for t in repro repro2 repro2_1; do
+for t in repro repro2 repro2_1 repro3; do
synth $t.vhdl -e $t > syn_$t.vhdl
analyze syn_$t.vhdl
clean
done
+for t in repro3_1; do
+ analyze $t.vhdl tb_$t.vhdl
+ elab_simulate tb_$t
+ clean
+
+ synth $t.vhdl -e $t > syn_$t.vhdl
+ analyze syn_$t.vhdl tb_$t.vhdl
+ elab_simulate tb_$t --ieee-asserts=disable-at-0
+ clean
+done
+
echo "Test successful"