diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-03-25 12:38:20 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-03-25 12:38:20 +0100 |
commit | 88430d7566d72714268f6be31e542600745a1036 (patch) | |
tree | 057878b560dea7c10c497359a16f21b632dac3fc /testsuite | |
parent | 341b324ee2e0245c6d8b5dbee76bcf066e263b26 (diff) | |
download | ghdl-88430d7566d72714268f6be31e542600745a1036.tar.gz ghdl-88430d7566d72714268f6be31e542600745a1036.tar.bz2 ghdl-88430d7566d72714268f6be31e542600745a1036.zip |
testsuite/synth: add tests for previous commit.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/synth/arr01/arr10.vhdl | 31 | ||||
-rw-r--r-- | testsuite/synth/arr01/arr11.vhdl | 33 | ||||
-rwxr-xr-x | testsuite/synth/arr01/testsuite.sh | 3 |
3 files changed, 67 insertions, 0 deletions
diff --git a/testsuite/synth/arr01/arr10.vhdl b/testsuite/synth/arr01/arr10.vhdl new file mode 100644 index 000000000..4004b916b --- /dev/null +++ b/testsuite/synth/arr01/arr10.vhdl @@ -0,0 +1,31 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity arr10 is + port (val : std_logic_vector(3 downto 0); + res : out natural); +end arr10; + +architecture behav of arr10 is + function find (s : string; c : character) return natural is + begin + for i in s'range loop + if s (i) = c then + return i; + end if; + end loop; + return 0; + end find; + + constant str1 : string := "hello world"; + constant pos1 : natural := find (str1, 'w'); + + alias str2 : string (str1'length downto 1) is str1; + constant pos2 : natural := find (str2, 'w'); +begin + assert pos1 = 7; + assert pos2 = 5; + + res <= pos1; +end behav; diff --git a/testsuite/synth/arr01/arr11.vhdl b/testsuite/synth/arr01/arr11.vhdl new file mode 100644 index 000000000..1b8c758a7 --- /dev/null +++ b/testsuite/synth/arr01/arr11.vhdl @@ -0,0 +1,33 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity arr11 is + port (val : std_logic_vector(3 downto 0); + res : out natural); +end arr11; + +architecture behav of arr11 is + function find (s : string; c : character) return natural is + begin + for i in s'range loop + if s (i) = c then + return i; + end if; + end loop; + return 0; + end find; + + constant str1 : string := "hello world"; + constant pos1 : natural := find (str1, 'w'); + + alias str2 : string (str1'length downto 1) is str1; + constant str3 : string := str2; + + constant pos3 : natural := find (str3, 'w'); +begin + assert pos1 = 7; + assert pos3 = 5; + + res <= pos1; +end behav; diff --git a/testsuite/synth/arr01/testsuite.sh b/testsuite/synth/arr01/testsuite.sh index 9e8ea74c5..04d7f4242 100755 --- a/testsuite/synth/arr01/testsuite.sh +++ b/testsuite/synth/arr01/testsuite.sh @@ -6,4 +6,7 @@ for t in arr01 arr02 arr04 arr05 arr06 arr07 arr09; do synth_tb $t done +synth_analyze arr10 +synth_analyze arr11 + echo "Test successful" |