diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-07-25 08:05:23 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-07-25 08:05:23 +0200 |
commit | 780165a75ed4eeb1657d9dde79576ff9883ec82b (patch) | |
tree | b9cadc46cd4f796a1f8a9c3b953a47d12fe35a34 /testsuite | |
parent | 50f95f658d69d7c3ab1369e14ac64e3f6bf0bd0e (diff) | |
download | ghdl-780165a75ed4eeb1657d9dde79576ff9883ec82b.tar.gz ghdl-780165a75ed4eeb1657d9dde79576ff9883ec82b.tar.bz2 ghdl-780165a75ed4eeb1657d9dde79576ff9883ec82b.zip |
testsuite/gna: add a test for #2138
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/gna/issue2138/testsuite.sh | 11 | ||||
-rw-r--r-- | testsuite/gna/issue2138/variable_assignment_with_when.vhdl | 29 |
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; |