What library do I need to declare the following signal:
constant L: integer:=log2(N); --ceiling log2(N)
Sadly, that one is missing... but this will work
in both synthesis and simulation:
package usefuls is
--- find minimum number of bits required to
--- represent N as an unsigned binary number
---
function log2_ceil(N: natural) return positive;
end;
package body usefuls is
--- find minimum number of bits required to
--- represent N as an unsigned binary number
---
function log2_ceil(N: natural) return positive is
begin
if N < 2 then
return 1;
else
return 1 + log2_ceil(N/2);
end if;
end;
end;
Converting my tail-recursive function into
an iterative implementation is left as an exercise
for the student

--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
[email protected]
Fax: +44 (0)1425 471573 Web:
http://www.doulos.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.