diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-09-06 02:46:25 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-09-06 02:46:25 +0200 |
commit | db2eca37c676a54827989349e3ced9860e3aa314 (patch) | |
tree | 4a4ceac8a6d0564538cc242000fc85f9ae6e8ff3 | |
parent | 8c8691504466dd345891b02aee111ab5076f082f (diff) | |
download | ghdl-db2eca37c676a54827989349e3ced9860e3aa314.tar.gz ghdl-db2eca37c676a54827989349e3ced9860e3aa314.tar.bz2 ghdl-db2eca37c676a54827989349e3ced9860e3aa314.zip |
testsuite: add testcase for ghdl/ghdl-language-server#27
-rw-r--r-- | testsuite/gna/lsp27/mwe.vhdl | 85 | ||||
-rwxr-xr-x | testsuite/gna/lsp27/testsuite.sh | 11 |
2 files changed, 96 insertions, 0 deletions
diff --git a/testsuite/gna/lsp27/mwe.vhdl b/testsuite/gna/lsp27/mwe.vhdl new file mode 100644 index 000000000..17093399b --- /dev/null +++ b/testsuite/gna/lsp27/mwe.vhdl @@ -0,0 +1,85 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity mwe is + generic ( + skip : integer := 10 + ); + port ( + nreset : in std_logic; + clk : in std_logic; + pulse_in : in std_logic; + pulse_out : out std_logic + ); +end mwe; + + +architecture behav of mwe is + type shared_counter is protected + procedure reset; + procedure increment; + impure function value return integer; + impure function pulsed return boolean; + end protected shared_counter; + + type shared_counter is protected body + variable cnt : integer range 0 to skip-1 := 0; + variable flag_pulse : boolean := false; + procedure reset is + begin + cnt := 0; + flag_pulse := false; + end reset; + + procedure increment is + begin + if cnt < skip-1 then + cnt := cnt + 1; + else + cnt := 0; + flag_pulse := true; + report "Pulse detected"; + end if; + end increment; + + impure function value return integer is + begin + return cnt; + end function value; + + impure function pulsed return boolean is + variable pulsed_state : boolean; + begin + pulsed_state := flag_pulse; + flag_pulse := false; + return pulsed_state; + end function pulsed; + end protected body shared_counter; + + shared variable shrd_cnt : shared_counter; +begin + + output:process(clk,nreset) + begin + if nreset /= '1' then + shrd_cnt.reset; + pulse_out <= '0'; + elsif rising_edge(clk) then + pulse_out <= '0'; + if shrd_cnt.pulsed then + pulse_out <= '1'; + end if; + end if; + end process; + + pulse_cnt_update:process(nreset,pulse_in) + begin + if nreset = '1' then + if pulse_in = '1' then + shrd_cnt.increment; + end if; + end if ; + end process; + +end behav; diff --git a/testsuite/gna/lsp27/testsuite.sh b/testsuite/gna/lsp27/testsuite.sh new file mode 100755 index 000000000..f972191c8 --- /dev/null +++ b/testsuite/gna/lsp27/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=02 +analyze -Wunused -Werror mwe.vhdl +elab_simulate mwe + +clean + +echo "Test successful" |