Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - ceil and floor

 
Thread Tools Search this Thread
Old 09-15-2007, 12:50 PM   #1
Default ceil and floor


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
  Reply With Quote
Old 09-15-2007, 12:53 PM   #2
zlotawy
 
Posts: n/a
Default Re: ceil and floor

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
  Reply With Quote
Old 09-15-2007, 02:36 PM   #3
David Bishop
 
Posts: n/a
Default Re: ceil and floor
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
  Reply With Quote
Old 09-15-2007, 03:48 PM   #4
zlotawy
 
Posts: n/a
Default Re: ceil and floor

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
  Reply With Quote
Old 09-15-2007, 04:35 PM   #5
KJ
 
Posts: n/a
Default Re: ceil and floor

"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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46