ceil and floor

Discussion in 'VHDL' started by zlotawy, Sep 15, 2007.

  1. zlotawy

    zlotawy Guest

    Hello,

    there are three constants:

    constant one : Natural := 36;
    constant two : Natural := 14;
    constant three: Natural := one/two;


    After synthesise three equels 2.

    BEcause 36/14 is more than 2 I have question, how to get this value?

    Thanks
    zlotawy
    zlotawy, Sep 15, 2007
    #1
    1. Advertising

  2. zlotawy

    zlotawy Guest

    U¿ytkownik "zlotawy" <_SPAM.pl> napisa³ w wiadomo¶ci
    news:fcggup$fp6$...

    For me

    36/14 = 3 :)
    36/12 = 3
    36/18 = 2
    36/35 = 2

    zlotawy
    zlotawy, Sep 15, 2007
    #2
    1. Advertising

  3. zlotawy

    David Bishop Guest

    zlotawy wrote:
    > Hello,
    >
    > there are three constants:
    >
    > constant one : Natural := 36;
    > constant two : Natural := 14;
    > constant three: Natural := one/two;
    >
    >
    > After synthesise three equels 2.
    >
    > BEcause 36/14 is more than 2 I have question, how to get this value?


    It just takes the integer value. In the "math_real" package you will
    find "ceil" and "floor" functions with take in REAL numbers and return
    real numbers (which are the integer values).

    If you are trying to synthesize a number that is less than 1, I would
    recommend that you try a fixed point number.
    David Bishop, Sep 15, 2007
    #3
  4. zlotawy

    zlotawy Guest

    Uzytkownik "David Bishop" <> napisal w wiadomosci
    news:46ebdfc0$0$32511$...


    hmm.. thanks but i can not use it.. :(

    library IEEE;
    use IEEE.STD_LOGIC_1164.all;
    use IEEE.MATH_REAL.ALL;
    package PKG is
    constant one: Integer := ceil(7/ 2);
    end PKG_SRAM;



    And i receive error: "ceil can not have such operands in this context.". Can
    I not generateconstatnt by ceil function?


    Thanks,
    zlotawy
    zlotawy, Sep 15, 2007
    #4
  5. zlotawy

    KJ Guest

    "zlotawy" <_SPAM.pl> wrote in message
    news:fcgrc2$mkn$...
    >
    > Uzytkownik "David Bishop" <> napisal w wiadomosci
    > news:46ebdfc0$0$32511$...
    >
    >
    > hmm.. thanks but i can not use it.. :(
    >
    > library IEEE;
    > use IEEE.STD_LOGIC_1164.all;
    > use IEEE.MATH_REAL.ALL;
    > package PKG is
    > constant one: Integer := ceil(7/ 2);
    > end PKG_SRAM;
    >
    >
    >
    > And i receive error: "ceil can not have such operands in this context.".
    > Can I not generateconstatnt by ceil function?
    >

    Yes, you can. The errors you're getting are because the data types that you
    are using do not have a 'ceil' function defined for it. The function
    declaration for 'ceil' in the ieee.math_real package.

    function CEIL (X : real ) return real;

    In ieee.math_real ceil takes a 'real' as the input parameter and returns a
    real type. Since you'd like to use integers you simply need to cast them
    appropriately.

    The correct way for your example would be
    constant one: Integer := natural(ceil(real(7)/real(2)));
    or equivalently...
    constant one: Integer := natural(ceil(7.0/2.0));

    KJ
    KJ, Sep 15, 2007
    #5
    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. SpaceCowboy
    Replies:
    6
    Views:
    1,082
    Josef Garvi
    Aug 15, 2003
  2. Replies:
    9
    Views:
    740
    Andrey Tarasevich
    Oct 23, 2006
  3. ptn

    ceil() and log10() - undefined?

    ptn, Oct 3, 2007, in forum: C Programming
    Replies:
    14
    Views:
    7,647
    Keith Thompson
    Oct 4, 2007
  4. john.swilting

    use POSIX qw(ceil floor)

    john.swilting, Apr 21, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    169
    john.swilting
    Apr 26, 2007
  5. RobG
    Replies:
    6
    Views:
    227
Loading...

Share This Page