[an error occurred while processing this directive]
|
---------------------------------------------------------------------------
-- This is regular implementation of Log2 function.
-- It'll probably work fine with Sinplicity but not with Synopsys.
-- For Synopsys (and Synplicity ) use recursive variant.
-- Of course, arg must be positive integer (> 0);
-- function LOG2(arg: integer) return integer is
-- variable temp, log : integer;
-- begin
--
-- assert arg /= 0
-- report "Error : function missuse : log2(zero)"
-- severity failure;
-- temp := arg;
-- log := 0;
-- while (temp /= 0) loop
-- temp := temp/2;
-- log := log+1;
-- end loop;
-- return log;
-- end log2;
-------------------------
-- Recursive variant of Log2 function.
function log2(arg: integer) return integer is
begin
if arg=1 then return 0; else return 1+log2(arg/2); end if;
end log2;
---------------------------------------------------------------------------
-- This is function that slightly different from Log2.
-- What it does - it returns min number of bits to represent integer "arg".
-- arg = not negative integer >= 0;
function log2dpm(arg: integer) return integer is
begin
if arg<=1 then
return 0;
else
return (1+log2(arg-1));
end if;
end log2dpm;
E-mail: info@telesys.ru