aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-08-14 21:10:53 +0200
committerTristan Gingold <tgingold@free.fr>2021-08-14 21:10:53 +0200
commit4b9b6309698e604f6eb87c664f6128efd2b57547 (patch)
tree8c0c200dffe9f3efaa7470199c4cf1e1fa5549cf /testsuite
parent075becc3eb59711a743f277d697b957e95b906d9 (diff)
downloadghdl-4b9b6309698e604f6eb87c664f6128efd2b57547.tar.gz
ghdl-4b9b6309698e604f6eb87c664f6128efd2b57547.tar.bz2
ghdl-4b9b6309698e604f6eb87c664f6128efd2b57547.zip
testsuite/gna: add a test for #1833
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gna/issue1833/test.vhdl74
-rwxr-xr-xtestsuite/gna/issue1833/testsuite.sh11
2 files changed, 85 insertions, 0 deletions
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"