[an error occurred while processing this directive]
|
function log2 (s : natural) return natural is
variable ret : natural:=1;
variable k : natural;
begin
k:= s;
while true loop
k:=k/2;
ret:=inc(ret);
exit when k < 2;
end loop;
return ret;
end;
subtype TCnt is integer range 0 to 2**8
signal Cnt : TCnt;
и далее к примеру кольцевой счетчик
COUNTER:
process(clk) begin
if clk='1' and clk'event then
if Cnt = 0 then
Cnt <= TCnt'high;
else
Cnt <= Cnt-1;
end if;
end if;
end process;
E-mail: info@telesys.ru