Mode:
Duration:
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
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity ArraySum is
Port (
sum_out : out INTEGER
);
end ArraySum;
architecture Behavioral of ArraySum is
type int_array is array (0 to 4) of INTEGER;
signal nums : int_array := (1,2,3,4,5);
signal sum : INTEGER := 0;
begin
process(nums)
begin
sum <= 0;
for i in 0 to 4 loop
sum <= sum + nums(i);
end loop;
end process;
sum_out <= sum;
end Behavioral;Coding works best on desktop or with an external keyboard.