aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/issue1650
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-02-19 08:59:35 +0100
committerTristan Gingold <tgingold@free.fr>2021-02-19 08:59:35 +0100
commit4974ee462a6674d4c85d4178c57e22a9ae7e1cba (patch)
tree5fcea7086500b08ccbe154e6a42627f20267335f /testsuite/synth/issue1650
parentc254871698f100d3600edf29f7f467564531418c (diff)
downloadghdl-4974ee462a6674d4c85d4178c57e22a9ae7e1cba.tar.gz
ghdl-4974ee462a6674d4c85d4178c57e22a9ae7e1cba.tar.bz2
ghdl-4974ee462a6674d4c85d4178c57e22a9ae7e1cba.zip
testsuite/synth: add a test for #1650
Diffstat (limited to 'testsuite/synth/issue1650')
-rw-r--r--testsuite/synth/issue1650/debounce.vhdl43
-rwxr-xr-xtestsuite/synth/issue1650/testsuite.sh9
2 files changed, 52 insertions, 0 deletions
diff --git a/testsuite/synth/issue1650/debounce.vhdl b/testsuite/synth/issue1650/debounce.vhdl
new file mode 100644
index 000000000..0ea40d1a5
--- /dev/null
+++ b/testsuite/synth/issue1650/debounce.vhdl
@@ -0,0 +1,43 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity debounce is
+ generic (
+ N_CYCLES: integer := 255
+ );
+ port
+ (
+ clk: in std_ulogic;
+ reset_n: in std_ulogic;
+ debounce_in: in std_ulogic;
+ debounced_out: buffer std_ulogic
+ );
+end debounce;
+
+architecture rtl of debounce is
+ signal counter: integer range 0 to N_CYCLES;
+ signal previous_debounce_in: std_ulogic := '0';
+begin
+ process(clk, reset_n)
+ begin
+ if (reset_n = '0') then
+ previous_debounce_in <= '0';
+ debounced_out <= '0';
+ counter <= 0;
+ elsif rising_edge(clk) then
+
+ if debounce_in = previous_debounce_in then
+ if counter = N_CYCLES then
+ debounced_out <= debounce_in;
+ else
+ counter <= counter + 1;
+ end if;
+ else
+ counter <= 0;
+ end if;
+
+ previous_debounce_in <= debounce_in;
+ end if;
+ end process;
+end rtl;
diff --git a/testsuite/synth/issue1650/testsuite.sh b/testsuite/synth/issue1650/testsuite.sh
new file mode 100755
index 000000000..190a675ec
--- /dev/null
+++ b/testsuite/synth/issue1650/testsuite.sh
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+synth_failure --vendor-library=missing_lib debounce.vhdl -e
+
+synth_only debounce
+
+echo "Test successful"