diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-02-17 19:05:56 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-02-17 19:05:56 +0100 |
commit | 43f3ab99bf70faba67910b8051bfcca17fb3799a (patch) | |
tree | 9a4f019d0f7a6bea3a75bc14117b7330d43a15bc /testsuite | |
parent | 96bc04c69adfabc6e66e545d7240f9474c54d9ef (diff) | |
download | ghdl-43f3ab99bf70faba67910b8051bfcca17fb3799a.tar.gz ghdl-43f3ab99bf70faba67910b8051bfcca17fb3799a.tar.bz2 ghdl-43f3ab99bf70faba67910b8051bfcca17fb3799a.zip |
testsuite/synth: add a test for #1977
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/synth/issue1977/testsuite.sh | 8 | ||||
-rw-r--r-- | testsuite/synth/issue1977/triangularcounter.vhdl | 48 |
2 files changed, 56 insertions, 0 deletions
diff --git a/testsuite/synth/issue1977/testsuite.sh b/testsuite/synth/issue1977/testsuite.sh new file mode 100755 index 000000000..665792ea1 --- /dev/null +++ b/testsuite/synth/issue1977/testsuite.sh @@ -0,0 +1,8 @@ +#! /bin/sh + +. ../../testenv.sh + +GHDL_STD_FLAGS=--std=08 +synth_only triangularcounter + +echo "Test successful" diff --git a/testsuite/synth/issue1977/triangularcounter.vhdl b/testsuite/synth/issue1977/triangularcounter.vhdl new file mode 100644 index 000000000..c1851de19 --- /dev/null +++ b/testsuite/synth/issue1977/triangularcounter.vhdl @@ -0,0 +1,48 @@ +library IEEE; +context IEEE.IEEE_std_context; + +entity TriangularCounter is + generic ( + g_Precision : natural := 11 + ); + port ( + CLK : in std_logic; + RST : in std_logic; + EN : in std_logic; + REF : out unsigned(g_Precision-1 downto 0); + TRIGGER : out std_logic + ); +end entity; + +architecture arch of TriangularCounter is + + signal dir : std_logic; + signal cnt : unsigned(REF'range); + signal tg_max : std_logic; + signal tg_min : std_logic; + +begin + + process(RST, CLK) + begin + if RST then + cnt <= (others=>'0'); + dir <= '0'; + elsif rising_edge(CLK) then + if EN then + cnt <= cnt-1 when dir else cnt+1; + if tg_min or tg_max then + dir <= not dir; + end if; + end if; + end if; + end process; + + tg_max <= (not dir) and (cnt ?= to_unsigned(2**g_Precision-2, REF)); + tg_min <= dir and (cnt ?= 1); + + REF <= cnt; + TRIGGER <= tg_min; + +end architecture; + |