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