package dumb is
  function count_ones (x : in BIT_VECTOR) return integer;
end dumb;

package body dumb is
  function count_ones (x : in BIT_VECTOR) return integer is
    variable count : integer;
  begin
    count := 0;
    for  i in x'range loop
      if (x(i) = '1') then
        count := count + 1;
      end if;
    end loop;
    return count;
  end count_ones;
end dumb;

use work.dumb.all;

entity test is
end test;

architecture ones_count of test is
  signal test1 : bit_vector(7 downto 0) := "01010111";
  signal test2 : bit_vector(7 downto 0) := "00000000";
begin
  process
    variable count : integer;
  begin
    count := count_ones(test1);
    count := count_ones(test2);
    wait;
  end process;
end ones_count;
