KJ said:
Write a function that implements whatever it is you want to do....example to
simply 'or' together all of the even numbered bits in a std_logic_vector is
below
function My_Func(V: std_logic_vector) return std_logic is
variable RetVal: std_logic := '0';
begin
for i in V'range loop
if ((i mod 2) = 0) then
RetVal := RetVal or V(i);
end if;
end loop;
return(RetVal);
end function My_Func;
Then call this function wherever you need it as you would any other
function.
signal y: std_logic;
signal Some_Vector: std_logic_vector(....);
....
y <= My_Func(Some_Vector)
Kevin Jennings
And how about:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY or_vec IS
PORT(
v : IN std_logic_vector;
vor : OUT std_logic
);
END ENTITY or_vec;
ARCHITECTURE behavior OF or_vec IS
COMPONENT or_vec IS
PORT(
v : IN std_logic_vector;
vor : OUT std_logic
);
END COMPONENT or_vec;
BEGIN
base_case: IF v'length = 1 GENERATE
BEGIN
vor <= v(v'low);
END GENERATE base_case;
induction_case: IF v'length > 1 GENERATE
CONSTANT mid : integer := (v'high + v'low)/2;
SIGNAL vor_l : std_logic;
SIGNAL vor_h : std_logic;
BEGIN
or_lo: or_vec PORT MAP(v(mid-1 DOWNTO v'low), vor_l);
or_hi: or_vec PORT MAP(v(v'high DOWNTO mid), vor_h);
vor <= vor_l or vor_h;
END GENERATE induction_case;
END ARCHITECTURE behavior;