You are on page 1of 1

function f_onescount(inp : in std_logic_vector(3 downto 0))

return std_logic_vector is
variable j: integer;
variable total:std_logic_vector(3 downto 0);

begin
total:= "0000";
for j in 0 to 7 loop
if (inp(j) = '1') then total := total + 1;
end if;
end loop;
return total;
end f_onescount;

You might also like