aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/arr01/arr11.vhdl
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/synth/arr01/arr11.vhdl')
-rw-r--r--testsuite/synth/arr01/arr11.vhdl33
1 files changed, 33 insertions, 0 deletions
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;