library ieee;
use ieee.std_logic_1164.all;
--library SYNOPSYS;
--use SYNOPSYS.attributes.all;

--use ieee.std_logic_unsigned.all;
--use ieee.std_logic_misc.xor_reduce;


PACKAGE pack IS

    FUNCTION sumprod ( A, B: std_logic_vector  ) RETURN std_logic;
    FUNCTION prodsum ( A, B: std_logic_vector  ) RETURN std_logic;
    FUNCTION multi_or ( dat: std_logic_vector; ena: std_logic  ) RETURN std_logic_vector;
    FUNCTION multi_and ( dat: std_logic_vector; ena: std_logic  ) RETURN std_logic_vector;

    
END pack;


PACKAGE BODY pack IS

    FUNCTION sumprod  ( A, B : std_logic_vector ) RETURN  std_logic is --ux01 IS
    VARIABLE result : std_logic ;
    BEGIN
        result := '0';
        FOR i IN A'RANGE LOOP
            result :=  result or (A(i) and B(i));
        END LOOP;
        RETURN result;
    END sumprod;

    FUNCTION prodsum  ( A, B : std_logic_vector ) RETURN  std_logic is --ux01 IS
    VARIABLE result : std_logic ;
    BEGIN
        result := '1';
        FOR i IN A'RANGE LOOP
            result :=  result and (A(i) or B(i));
        END LOOP;
        RETURN result;
    END prodsum;

    FUNCTION multi_or ( dat: std_logic_vector; ena: std_logic) RETURN  std_logic_vector is --ux01 IS
    VARIABLE result : std_logic_vector(dat'range) ;
    BEGIN
--        result := (others => '1');
        FOR i IN dat'RANGE LOOP
            result(i) :=  dat(i) or ena;
        END LOOP;
        RETURN result;
    END multi_or;

    FUNCTION multi_and ( dat: std_logic_vector; ena: std_logic) RETURN  std_logic_vector is --ux01 IS
    VARIABLE result : std_logic_vector(dat'range) ;
    BEGIN
        FOR i IN dat'RANGE LOOP
            result(i) :=  dat(i) and ena;
        END LOOP;
        RETURN result;
    END multi_and;

END pack;
