logarithms PACKAGE MATH_REAL

Discussion in 'VHDL' started by create, Jan 28, 2008.

  1. create

    create Guest

    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))));ORconstant
    CONST_LOG_NUMBER_SAMPLES : Natural :=
    Natural(ceil(LOG(real(2),real(CONST_NUMBER_SAMPLES))));How should I write
    LOG with base = 2?Thanks,Create
     
    create, Jan 28, 2008
    #1
    1. Advertising

  2. create

    KJ Guest

    "create" <paraliczb@NO_SPAM_orange.pl> wrote in message
    news:fnlq2p$9kr$...
    > 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))));ORconstant
    > 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
     
    KJ, Jan 29, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juan Carlos Allica

    PACKAGE MATH_REAL problems

    Juan Carlos Allica, Jul 13, 2005, in forum: VHDL
    Replies:
    2
    Views:
    1,713
    David Bishop
    Jul 13, 2005
  2. Andreas

    Newbie: ieee.math_real + ghdl

    Andreas, Jan 6, 2006, in forum: VHDL
    Replies:
    10
    Views:
    2,560
    Phil Tomson
    Jan 8, 2006
  3. Nicolas Matringe

    Synthesis of math_real package

    Nicolas Matringe, Feb 5, 2008, in forum: VHDL
    Replies:
    9
    Views:
    2,521
    Nicolas Matringe
    Feb 6, 2008
  4. Replies:
    30
    Views:
    2,691
    Arne Vajhøj
    Aug 4, 2008
  5. Mr.SpOOn
    Replies:
    0
    Views:
    292
    Mr.SpOOn
    Dec 17, 2008
Loading...

Share This Page