Velocity Reviews > VHDL > logarithms PACKAGE MATH_REAL

# logarithms PACKAGE MATH_REAL

create
Guest
Posts: n/a

 01-28-2008
Hello,
there are two functions for logarithms in PACKAGE MATH_REAL:

function LOG (X : real ) return real;
-- returns natural logarithm of X; X > 0

function LOG (BASE: positive; X : real) return real;
-- returns logarithm base BASE of X; X > 0In my project i used
first:constant CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(realCONST_NUMBER_SAMPLES))));
and it is correct.But I can not make second version:constant
CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(2,real(CONST_NUMBER_SAMPLES))));O Rconstant
CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(real(2),real(CONST_NUMBER_SAMPLES ))));How should I write
LOG with base = 2?Thanks,Create

KJ
Guest
Posts: n/a

 01-29-2008

"create" <paraliczb@NO_SPAM_orange.pl> wrote in message
news:fnlq2p\$9kr\$(E-Mail Removed)...
> Hello,
> there are two functions for logarithms in PACKAGE MATH_REAL:
>
> function LOG (X : real ) return real;
> -- returns natural logarithm of X; X > 0
>
> function LOG (BASE: positive; X : real) return real;
> -- returns logarithm base BASE of X; X

Here are the log functions prototypes from math_real....note, 'base' is not
a positive, it's real.
function log (x : in real ) return real;
function log2 (x : in real ) return real;
function log10 (x : in real ) return real;
function log (x: in real; base: in real) return real;

> In my project i used first:constant CONST_LOG_NUMBER_SAMPLES : Natural :=
> Natural(ceil(LOG(realCONST_NUMBER_SAMPLES))));
> and it is correct.But I can not make second version:constant
> CONST_LOG_NUMBER_SAMPLES : Natural :=
> Natural(ceil(LOG(2,real(CONST_NUMBER_SAMPLES))));O Rconstant
> CONST_LOG_NUMBER_SAMPLES : Natural :=
> Natural(ceil(LOG(real(2),real(CONST_NUMBER_SAMPLES ))));How should I write
> LOG with base = 2?Thanks,Create

Note that '2.0' is used as the base, not '2'.
constant CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(2.0,real(CONST_NUMBER_SAMPLES)))) ;

Alternatively you could use the log2 function (see above).

KJ