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

Reply

VHDL - Type convertion when doing arimetic on intergers.

 
Thread Tools Search this Thread
Old 10-25-2006, 12:31 PM   #1
Default Type convertion when doing arimetic on intergers.


Dear All,

What is the resulting range of an arithmetic operation on ranged
integers?
E.g. with the following two signals.

signal X : integer range 1 to 255;
signal Y : integer range 1 to 255;

And then some ware in the code.

if ( X > Y/2) then .......

Our linding tools report a warning here stating the X is 8 bit wide and
Y/2 is only 7 bit.
So the simple question is now.

What is the range of Y/2?

The general question is. What is the range of any arithmetic operation
on ranged integers?
Which rules control this?
Where in the LRM is this described?

Regards,
Mogens.



MLyngsie
  Reply With Quote
Old 10-25-2006, 06:02 PM   #2
Dave Pollum
 
Posts: n/a
Default Re: Type convertion when doing arimetic on intergers.

MLyngsie wrote:
> Dear All,
>
> What is the resulting range of an arithmetic operation on ranged
> integers?
> E.g. with the following two signals.
>
> signal X : integer range 1 to 255;
> signal Y : integer range 1 to 255;
>
> And then some ware in the code.
>
> if ( X > Y/2) then .......
>
> Our linding tools report a warning here stating the X is 8 bit wide and
> Y/2 is only 7 bit.
> So the simple question is now.
>
> What is the range of Y/2?
>
> The general question is. What is the range of any arithmetic operation
> on ranged integers?
> Which rules control this?
> Where in the LRM is this described?
>
> Regards,
> Mogens.


Since Y is 8-bits, then (Y/2) is an 7-bit value. If Y is not used
except in your if statement, then the HDL compiler figures out that it
only needs 7-bits for Y.
BTW, why is the low range for both X and Y '1', instead of '0'?

-Dave Pollum



Dave Pollum
  Reply With Quote
Old 10-26-2006, 09:12 AM   #3
MLyngsie
 
Posts: n/a
Default Re: Type convertion when doing arimetic on intergers.
Hi Dave,
Thank you for the answer.

This is also what I assumed. But where is this stated in the LRM.
It you lock in section 7.2.6 "Multiplying operators" of the LRM it is
just stated that the result is of the same type as the operands. This
section doesn't really describe anything about the range of integers.

Regarding the lower range of the type definition. It is just there so
that an error will be issued if a value that is out of the expected
range is assigned.

Regards,
Mogens



MLyngsie
  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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: expected constructor, destructor or type conversion before '(' token suse Software 0 03-09-2009 03:25 AM
Eclipse - Axis2 - Java Webservices Error amanjsingh Software 1 10-09-2007 09:03 AM
Need help on Modelsim VHDL syntax? ASAP:) kaji General Help Related Topics 0 03-14-2007 10:43 PM
Need help on a Modelsim VHDL Syntax? ASAP:) kaji Software 0 03-14-2007 10:43 PM
Need Help on a Modelsim VHDL Syntax....ASAP:) kaji Hardware 0 03-14-2007 10:41 PM




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