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

Reply

VHDL - Fractions

 
Thread Tools Search this Thread
Old 04-10-2007, 11:19 AM   #1
Default Fractions


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



Iqbal
  Reply With Quote
Old 04-10-2007, 11:35 AM   #2
Benjamin Todd
 
Posts: n/a
Default Re: Fractions
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" <> wrote in message
news: 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
>





Benjamin Todd
  Reply With Quote
Old 04-10-2007, 12:30 PM   #3
Thomas Stanka
 
Posts: n/a
Default Re: Fractions
On 10 Apr., 12:19, "Iqbal" <javid...@hotmail.com> 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





Thomas Stanka
  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
signed divider with fractions in vhdl sueco_ Hardware 0 07-07-2009 12:05 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