aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/stmt01/forloop2.vhdl
blob: 67ed6b4854411156ce7f74ade1bb04ca74356732 (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
library ieee;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity forloop2 is
  port (vin: in STD_LOGIC_VECTOR (7 downto 0);
        vout: out STD_LOGIC_VECTOR (3 downto 0);
        clk: in STD_LOGIC);
end forloop2;

architecture behav of forloop2 is
begin
  process (clk, vin)
    variable count: unsigned (vout'range);
  begin
    if rising_edge (clk)
    then
      count := (others => '0');
      for I in vin'range loop
        count := count + unsigned'(0 => vin (i));
      end loop;
      vout <= std_logic_vector (count);
    end if;
  end process;
end behav;