Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Fractions

Reply
Thread Tools

Fractions

 
 
Iqbal
Guest
Posts: n/a
 
      04-10-2007
Hi all,

I need to do arithmetic using fractions eg. adding +1/4 of an 8 bit
value to another 8 bit value or subtracting
-1/16 of an 8 bit value from another 8 bit value.

Can anyone tell me how I can do this in VHDL or point me in the right
direction ?

Thanks

 
Reply With Quote
 
 
 
 
Benjamin Todd
Guest
Posts: n/a
 
      04-10-2007
Your examples are pretty simple, are you trying to make a generic 'fraction'
or is there only a certain set of values you can accept?

I'd be thinking about 1/(2^n) fractions as an approximation...

Considering that you only have an 8-bit number to start with, this means you
can only go from 0-255... this is probably an exploitable limitation.

Ben

"Iqbal" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi all,
>
> I need to do arithmetic using fractions eg. adding +1/4 of an 8 bit
> value to another 8 bit value or subtracting
> -1/16 of an 8 bit value from another 8 bit value.
>
> Can anyone tell me how I can do this in VHDL or point me in the right
> direction ?
>
> Thanks
>



 
Reply With Quote
 
 
 
 
Thomas Stanka
Guest
Posts: n/a
 
      04-10-2007
On 10 Apr., 12:19, "Iqbal" <(E-Mail Removed)> wrote:
> I need to do arithmetic using fractions eg. adding +1/4 of an 8 bit
> value to another 8 bit value or subtracting
> -1/16 of an 8 bit value from another 8 bit value.
>
> Can anyone tell me how I can do this in VHDL or point me in the right
> direction ?


Z= X + Y/4 for 8 bit unsigned:

Z <= X + "00"&Y(7 downto 2);

bye Thomas



 
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
Font with fractions JP Computer Support 3 02-08-2009 02:15 PM
XSL-FO...Fractions? Lee Jackson XML 3 12-17-2004 12:18 PM
fractions - entering your own numbers in Word? John Computer Information 3 04-29-2004 11:50 PM
Decimal places and huge fractions. Eoin Mcloughlin Perl 5 02-13-2004 08:33 PM
Adding two fractions karp C++ 2 11-22-2003 06:47 AM



Advertisments