package dumb is
  procedure COUNT_ONES_P (X : in BIT_VECTOR; COUNT : out integer);
end dumb;

package body dumb is
  procedure COUNT_ONES_P (X : in BIT_VECTOR; COUNT : out integer) is
    variable internal_count : integer := 0;
  begin
    for  i in X'range loop
      if (X(i) = '1') then
        internal_COUNT := internal_count + 1;
      end if;
    end loop;
    count := internal_count;
  end count_ones_p;
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_ones_p(test1, count);
    count_ones_p(test2, count);
    wait;
  end process;
end ones_count;
