blob: 1b8c758a77804a42ed9b77c747fb9b7f73d49c5a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
|