Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17255 Discussions

Online arithmetic with radix 2 addition

Altera_Forum
Honored Contributor II
1,292 Views

I am having trouble working with OLA(online arithmetic addition) radix 2 SD(signed digit) addition MSDF(most significant digit first). 

If I have an 8 bits range unsigned number and a redundant and symmetric set of {−1,0,+1} with the following table: 

+1 ---> 01 

0 ---> 00 

0 ---> 11 

-1 ---> 10 

If I want to make a−b=c, I do not understand how the operation of a−b is performed in binary. 

If we have 25−10=15, 

25=00011001 

10=00001010 

If we map each two consecutive digits to the those in the table, how do I perform the computation so that I could implement it in hardware?
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
551 Views

To subtract two unsigned numbers, I believe you do subtraction by indirect addition (a + (-b) = c where a is the minuend and b is the subtrahend). Meaning, convert the subtrahend using 2's complement and add to the minuend.  

 

For example, to do 25 - 10, where 25 is 0001 1001 and 10 is 0000 1010 represented in binary, first convert 10 using 2's complement. 2's complement is a technique to negate a number in binary. The easiest way to take a 2's complement on a binary number is to go from left to right until you reach the first one in the number. So, for 10 it would be 10. Next, invert all bits after the first one. So, 10 would be 1111 0110. After you have negated the subtrahend, add to the minuend. So, 25: 0001 1001 + (-10): 1111 0110 = 0000 1111, or 15. Watch out for invalid answers. Hope this helps! 

 

111 

0001 1001 + -for each column, add the numbers at the place value, if you get 1+1 = 10 (2), this generates a carry 

1111 0110 =  

0000 1111 

 

-video on adding/subtracting binary numbers  

http://us.yhs4.search.yahoo.com/yhs/search?hspart=ironsource&hsimp=yhs-fullyhosted_003&type=spd_wnzp01_14_26_ie&param1=1&param2=sid%3d4fc8850fbcd434850ee83ded58973a84%26ulng%3den-us%252cen%253bq%253d0.8%252cde%253bq%253d0.6%252cfr%253bq%253d0%26b%3dchrome%26ip%3d98.234.211.8%26p%3dspeedial%26x%3dac811232dd57e1a5%26dt%3ds908%26f%3d4%26a%3dspd_wnzp01...
0 Kudos
Reply