architecture behavior of count_ones is process (vec) variable result: unsigned(4 downto 0); begin result := to_unsigned(0, result’length)); for i in 15 downto 0 loop if vec(i) = ‘1’ then result := result +1; end if; end loop-- DA Test: OK count <= result; -- but more complicate end process; end;