You are on page 1of 24

Conditional-Sum-Adder 1

• can we improve the linear depth of our adder, making it run faster?
• the circuit may have a higher cost

Tilman Schieber (TU Berlin) Computer Engineering 2016 58


Conditional-Sum-Adder 1

• can we improve the linear depth of our adder, making it run faster?
• the circuit may have a higher cost
• Idea: We split the addition in two parts that can run in parallel.
• but: We can’t calculate the upper half of the sum if we don’t know
the carry-bit from the lower half.
• Solution: We calculate the upper half two times, once for carry=0
and once for carry=1

Tilman Schieber (TU Berlin) Computer Engineering 2016 58


Conditional-Sum-Adder 2

8-bit Conditional Sum Adder

Tilman Schieber (TU Berlin) Computer Engineering 2016 59


CS-Adder: Depth 1

• So why build a more complicated adder?

Tilman Schieber (TU Berlin) Computer Engineering 2016 60


CS-Adder: Depth 1

• So why build a more complicated adder?


• For a 32-bit carry-ripple-adder we found depth(CR32 ) = 2 · 32 = 64
• For a 32-bit conditional-sum-adder:
depth(CS32 ) = depth(CR16 ) + depth(MUX2 to 1 ) = 32 + 3 = 35

Tilman Schieber (TU Berlin) Computer Engineering 2016 60


Carry-Lookahead 1

• Carry-Lookahead is another strategy to make an adder faster.


• Idea: Look at the pair of numbers at a position and decide if they will
generate or propagate a carry.
• This will speed up calculating the carry bits.
• No need to wait for the carry to “ripple”.
• So, for each position i we will calculate the functions:
• gi which is true when a carry bit is generated
• pi which is true when a carry bit is propagated

Tilman Schieber (TU Berlin) Computer Engineering 2016 61


Carry-Lookahead 2

4-bit Carry Lookahead Adder

Tilman Schieber (TU Berlin) Computer Engineering 2016 62


Multiplication

• Multiplication by hand:

1 2 1 4·
2 1
4 8
1 6 8
• Binary Multiplication works the same way. Lets look at 101·101:

1 0 1 · 1 0 1
1 0 1
0 0 0
1 0 1
1 1 0 0 1

Tilman Schieber (TU Berlin) Computer Engineering 2016 63


Shifting Numbers

• To realize a multiplication we need to shift numbers to the left and


add the results
• left-shifting is abbreviated LSH, right-shifting RSH
• Example: LSH(00111011)=01110110
• LSH multiplies a number with two, ignoring overflow.

Circuit for LSH

Tilman Schieber (TU Berlin) Computer Engineering 2016 64


A Left/Right Shifter

this shifter with control line can perform LSH or RSH, c decides which
function to perform.

Tilman Schieber (TU Berlin) Computer Engineering 2016 65


Multiplication Algorithm

To multiply the binary numbers A and B and save the result into C :
1 Set i to 0 and C to 0
2 if bit i of B is 1, C =C +A
3 A=LSH(A)
4 i=i+1
5 if B has a bit i, goto 2.
6 C contains the product
This can be easily implemented with an adder, shifter and a place to store
the temporary result.

Tilman Schieber (TU Berlin) Computer Engineering 2016 66


A Multiplication Circuit

• While our approach to Multiplication is easy, it needs one addition for


each input bit.
• Idea: Exploit the properties of binary multiplication
• While multiplying multi-bit numbers (using the school method) we
multiply all the bits of each number with each other exactly once.
• The results of this multiplications are called partial products and
easily realized with AND-gates.

Tilman Schieber (TU Berlin) Computer Engineering 2016 67


Wallace Tree Multiplier

Partial Products in Binary Multiplication


A n B A n B 2n ÿ
ÿ ÿ ÿ
k k
ak 2 · bk 2 = ai bj 2k
k=0 k=0 k=0 i+j=k
qn qn
with k=0 ak 2k and k=0 bk 2k , ak , bk œ {0, 1} the binary representations
of the numbers a and b.

1 Calculate the partial products ai · bj · 2i+j for every pair of digits in a


and b.
2 Add the partial products in a special tree structure until you get two
2n-numbers (8-bit in the example)
3 Add the 2 numbers with a normal 2n-bit-adder.

Tilman Schieber (TU Berlin) Computer Engineering 2016 68


Wallace Tree Multiplier

4-bit Wallace Tree Multiplier


Tilman Schieber (TU Berlin) Computer Engineering 2016 69
Number Representation

Number Representation

Tilman Schieber (TU Berlin) Computer Engineering 2016 70


Number Representation Signed Numbers

Overview

Signed Numbers

Tilman Schieber (TU Berlin) Computer Engineering 2016 71


Number Representation Signed Numbers

Substracting Numbers

• We already know how to add numbers


• We can substract by adding the negative of a number
• How can we represent negative numbers?

Tilman Schieber (TU Berlin) Computer Engineering 2016 72


Number Representation Signed Numbers

Signed Magnitude

8-Bit Signed Magnitude


signed magn. decimal
• We can use one bit to save the sign (+ 00000001 1
or ≠) and the rest to save the number 10000001 -1
• two representations of 0 01111111 127
• impractical for arithmetics 11111111 -127
00000000 0
10000000 -0

Tilman Schieber (TU Berlin) Computer Engineering 2016 73


Number Representation Signed Numbers

One’s Complement

8-Bit One’s Complement


• We use again the most significant bit for 1’s comp. decimal
+/-. If the number is negative the rest of 00000001 1
the bits is inverted. 11111110 -1
01111111 127
• Can be used to do arithmetic
10000000 -127
• still two representations for 0
00000000 0
11111111 -0

Tilman Schieber (TU Berlin) Computer Engineering 2016 74


Number Representation Signed Numbers

One’s Complement: Addition

• Numbers in 1’s complement representation can be added


• there is one special rule, the end-around-carry
• If a carry occurs at the most significant bit, add it to the result

Example: One’s Complement Addition

Tilman Schieber (TU Berlin) Computer Engineering 2016 75


Number Representation Signed Numbers

Two’s Complement

• like one’s complement, but 1 is added to 8-Bit Two’s Complement


the result 2’s compl. decimal
• If a carry occurs at the MSB ignore it. 00000001 1
• So to get -5: 11111111 -1
1 00000101 (5) 01111111 127
2 11111010 (1’s comp.) 10000001 -127
3 11111011 (2’s comp.) 00000000 0

Tilman Schieber (TU Berlin) Computer Engineering 2016 76


Number Representation Signed Numbers

Using Two’s Complement

• The advantage of two’s complement is that we can add with it like


with normal binary numbers. The leftmost carry is thrown away.

00011001 25
11111010 -6
00010011 19

• another example:

00000101 5
11111010 -6
11111111 -1

Tilman Schieber (TU Berlin) Computer Engineering 2016 77


Number Representation Signed Numbers

Addition Overflow

• Look at the following addition

01000000 64
01000001 65
10000001 -127
• The result is wrong! We call this an overflow error.
• When two numbers with the same sign are added and the result has
the other sign, overflow has occured.
• When two numbers with different signs are added, overflow cannot
occur.

Tilman Schieber (TU Berlin) Computer Engineering 2016 78


Number Representation Signed Numbers

Excess-n

• Excess-n represents a number x as the Excess-127 (8-bit)


positive binary number x + n
Excess-127 decimal
• e.g. Excess-7 for 4 bits represents ≠7 as 10000000 1
0000 and 1 as 1000 01111110 -1
• Excess-2(m≠1) corresponds to m-bit two’s 11111111 128
complement with the sign-bit inverted. 00000000 -127
• e.g.: Excess-127 (see table) 01111111 0

Tilman Schieber (TU Berlin) Computer Engineering 2016 79

You might also like