Forum Discussion
Altera_Forum
Honored Contributor
15 years agoVHDL code for logarithme
Hi, There are somoene that release a vhdl code for log or have any idea about it. I need any tutorial or helps to start release it. Thank you.
Altera_Forum
Honored Contributor
15 years ago --- Quote Start --- like log base 2? this function will return the nearest log2 of a number (but I wouldnt recommend synthesising as a real time function) Its useful for determining how many bits you need for a vector.
function log2(x : integer) return integer is
variable temp : integer :=x;
variable n : integer := 1;
begin
while temp > 1 loop
temp := temp/2;
n := n + 1;
end loop;
return n;
end function log2;
--- Quote End --- Think you very much for your reply, ok for this function it is clear, but that i need is a function that can execute during a minimum of clock cycle. ThAnk you