function function_name (parameter_list) return type is declarations begin sequential statements end function_name; 1. A function can only have input parameters, so the mode (direction) is not specified. 2. A function may declare local variables. 3. A function may contain any sequential statement except signal assignment and wait. library ieee; use ieee.std_logic_1164.all; package MY_PACK is function PARITY (X : std_logic_vector) return std_logic; end MY_PACK; package body MY_PACK is function PARITY (X : std_logic_vector) return std_logic is variable TMP : std_logic; begin --TMP:= '0'; TMP := X(0); --for J in X'range loop for J in 1 to X'high loop TMP := TMP xor X(J); end loop; -- works for any size X return TMP; end PARITY; end MY_PACK; library ieee; use ieee.std_logic_1164.all; use work.MY_PACK.all; entity PAR is port( db: in std_logic_vector(7 downto 0); dw: in std_logic_vector(15 downto 0); pb, pw: out std_logic); end PAR; architecture ARCH1 of PAR is begin pb <= PARITY(db); pw <= PARITY(dw); end ARCH1;