aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-07-25 08:05:23 +0200
committerTristan Gingold <tgingold@free.fr>2022-07-25 08:05:23 +0200
commit780165a75ed4eeb1657d9dde79576ff9883ec82b (patch)
treeb9cadc46cd4f796a1f8a9c3b953a47d12fe35a34 /testsuite/gna
parent50f95f658d69d7c3ab1369e14ac64e3f6bf0bd0e (diff)
downloadghdl-780165a75ed4eeb1657d9dde79576ff9883ec82b.tar.gz
ghdl-780165a75ed4eeb1657d9dde79576ff9883ec82b.tar.bz2
ghdl-780165a75ed4eeb1657d9dde79576ff9883ec82b.zip
testsuite/gna: add a test for #2138
Diffstat (limited to 'testsuite/gna')
-rwxr-xr-xtestsuite/gna/issue2138/testsuite.sh11
-rw-r--r--testsuite/gna/issue2138/variable_assignment_with_when.vhdl29
2 files changed, 40 insertions, 0 deletions
diff --git a/testsuite/gna/issue2138/testsuite.sh b/testsuite/gna/issue2138/testsuite.sh
new file mode 100755
index 000000000..0d1ff08be
--- /dev/null
+++ b/testsuite/gna/issue2138/testsuite.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=08
+analyze variable_assignment_with_when.vhdl
+elab_simulate variable_assignment_with_when
+
+clean
+
+echo "Test successful"
diff --git a/testsuite/gna/issue2138/variable_assignment_with_when.vhdl b/testsuite/gna/issue2138/variable_assignment_with_when.vhdl
new file mode 100644
index 000000000..06349788a
--- /dev/null
+++ b/testsuite/gna/issue2138/variable_assignment_with_when.vhdl
@@ -0,0 +1,29 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity variable_assignment_with_when is
+ port(
+ x : in std_logic_vector(7 downto 0);
+ y : out std_logic_vector(3 downto 0)
+ );
+end entity;
+
+architecture arch of variable_assignment_with_when is
+begin
+
+ process (all) is
+ variable sum : natural;
+ begin
+ sum := 0;
+ for i in x'range loop
+ sum := sum + 1 when x(i) = '1';
+ -- this works:
+ -- if x(i) then
+ -- sum := sum + 1;
+ -- end if;
+ end loop;
+ y <= std_logic_vector(to_unsigned(sum, y'length));
+ end process;
+
+end architecture;