library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.NUMERIC_STD.ALL; package array_functions is constant MAX_RANGE : integer := 255; type array_of_integers is array(integer range <>) of integer range -MAX_RANGE to MAX_RANGE; function array_sum ( K : in array_of_integers ) return integer; function reorder_array ( K : in array_of_integers ; simetric : in boolean ) return array_of_integers; end package; package body array_functions is function array_sum ( K : in array_of_integers ) return integer is variable sum : integer := 0; begin for i in 0 to K'length-1 loop sum := sum + K(K'left + i); end loop; return sum; end array_sum; function reorder_array ( K : in array_of_integers ; simetric : in boolean ) return array_of_integers is constant M : integer := 1 + 2*((K'length)-1); constant N : integer := K'length; variable arr_s : array_of_integers( 0 to M-1 ); variable arr_a : array_of_integers( 0 to N-1 ); begin if ( simetric ) then for i in 0 to N-1 loop arr_s( i ) := K( K'left + i ); end loop; for i in 1 to N-1 loop arr_s( n + i - 1 ) := K( K'right - i ); end loop; return arr_s; else for i in 0 to N-1 loop arr_a( i ) := K( K'left + i ); end loop; return arr_a; end if; end reorder_array; end array_functions;