Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > ceil and floor

Reply
Thread Tools

ceil and floor

 
 
zlotawy
Guest
Posts: n/a
 
      09-15-2007
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



 
Reply With Quote
 
 
 
 
zlotawy
Guest
Posts: n/a
 
      09-15-2007

Użytkownik "zlotawy" <(E-Mail Removed)_SPAM.pl> napisał w wiadomości
news:fcggup$fp6$(E-Mail Removed)...

For me

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

zlotawy




 
Reply With Quote
 
 
 
 
David Bishop
Guest
Posts: n/a
 
      09-15-2007
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.

 
Reply With Quote
 
zlotawy
Guest
Posts: n/a
 
      09-15-2007

Uzytkownik "David Bishop" <(E-Mail Removed)> napisal w wiadomosci
news:46ebdfc0$0$32511$(E-Mail Removed)...


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


 
Reply With Quote
 
KJ
Guest
Posts: n/a
 
      09-15-2007

"zlotawy" <(E-Mail Removed)_SPAM.pl> wrote in message
news:fcgrc2$mkn$(E-Mail Removed)...
>
> Uzytkownik "David Bishop" <(E-Mail Removed)> napisal w wiadomosci
> news:46ebdfc0$0$32511$(E-Mail Removed)...
>
>
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
use POSIX qw(ceil floor) john.swilting Perl Misc 2 04-26-2007 12:12 PM
floor or ceil for integer division PengYu.UT@gmail.com C++ 9 10-23-2006 06:47 AM
Math.ceil/floor Vs parseInt Vs plus/minus RobG Javascript 6 07-09-2005 01:08 PM
How to import floor, ceil, etc with MIDP? SpaceCowboy Java 6 08-15-2003 07:55 AM



Advertisments