[an error occurred while processing this directive]
|
constant CODE_LENGTH: integer:=3;
constant BUS_LENGTH: integer:=2**CODE_LENGTH;
subtype BusType is std_logic_vector(BUS_LENGTH-1 downto 0);
subtype CodeType is std_logic_vector(CODE_LENGTH downto 0);
subtype CountType is integer range 0 to BUS_LENGTH;
function one_amount (BD: in BusType) return CodeType is
variable C: CountType;
begin
C:=0;
GEN: for i in 0 to BusType'high loop
if BD(i)='1' then C:=C+1; end if;
end loop GEN;
return CONV_STD_LOGIC_VECTOR(C,CODE_LENGTH+1);
end function one_amount;
E-mail: info@telesys.ru