FUNCTION adder (CONSTANT a : UNSIGNED(15 DOWNTO 0); CONSTANT b : UNSIGNED(11 DOWNTO 0)) RETURN UNSIGNED IS
        VARIABLE result         : UNSIGNED(16 DOWNTO 0) := "00000000000000000";
BEGIN
        result := "0" & a;
        result := result + b;
        IF result(result'HIGH) = '1' THEN -- here is the problem
                RETURN "0000000000000000";
        END IF;
        RETURN result(15 DOWNTO 0);
END FUNCTION;

Add a code snippet to your website: www.paste.org