aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;