
library ieee;
use ieee.std_logic_1164.all;

-- package declaration
package count_type is
  constant max : integer := 5;
  function incr (n: std_ulogic_vector(max-1 downto 0))
                 return std_ulogic_vector;
end count_type;

--package_definition
package body count_type is

  -- implements "plus 1"
  function incr (n: std_ulogic_vector(max-1 downto 0)) return std_ulogic_vector is
    variable s: std_ulogic_vector(max-1 downto 0);
    variable c: std_ulogic;
  begin
    c := '1';
    for i in 0 to max-1 loop
      s(i) := n(i) xor c;
      c := n(i) and c;
    end loop;
    return s;
  end;

end count_type;
