From 4b9b6309698e604f6eb87c664f6128efd2b57547 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 14 Aug 2021 21:10:53 +0200 Subject: testsuite/gna: add a test for #1833 --- testsuite/gna/issue1833/test.vhdl | 74 ++++++++++++++++++++++++++++++++++++ testsuite/gna/issue1833/testsuite.sh | 11 ++++++ 2 files changed, 85 insertions(+) create mode 100644 testsuite/gna/issue1833/test.vhdl create mode 100755 testsuite/gna/issue1833/testsuite.sh diff --git a/testsuite/gna/issue1833/test.vhdl b/testsuite/gna/issue1833/test.vhdl new file mode 100644 index 000000000..15e3edb8a --- /dev/null +++ b/testsuite/gna/issue1833/test.vhdl @@ -0,0 +1,74 @@ +library ieee; + +entity shared2 is + + type scounter is protected + use ieee.std_logic_1164.all; ---<<<< test target + impure function inc (by : integer) return integer; + impure function get return integer; + end protected; + + type scounter is protected body + variable cnt : integer := 0; + + impure function inc (by : integer) return integer is + begin + cnt := cnt + by; + return cnt; + end function; + + impure function get return integer is + begin + return cnt; + end function; + end protected body; + +end entity shared2; + +architecture rtl of shared2 is + + shared variable tcnt : scounter; + signal clk : bit := '0'; + signal term : integer := 0; + +begin + + process(clk) + variable tv : integer; + begin + if clk'event and clk = '1' then + tv := tcnt.inc(1); + end if; + end process; + + + process(clk) + variable tv : integer; + begin + if clk'event and clk = '0' then + tv := tcnt.inc(2); + end if; + end process; + + + process + begin + clk <= not clk; + wait for 1 ns; + end process; + + process + begin + if clk'event and clk = '0' then + if term >= 20 then + report "Sim end ...."; -- severity failure; + std.env.finish; + end if; + term <= term + 1; + report integer'image(tcnt.get); + end if; + wait on clk; + end process; + + +end rtl; diff --git a/testsuite/gna/issue1833/testsuite.sh b/testsuite/gna/issue1833/testsuite.sh new file mode 100755 index 000000000..616a32b8c --- /dev/null +++ b/testsuite/gna/issue1833/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze test.vhdl +elab_simulate shared2 + +clean + +echo "Test successful" -- cgit v1.2.3