YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Arithmetic Circuits II

Anselmo Lastra

Page 2: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

2 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Overflow

• Two cases of overflow for addition of signed numbers♦ Two large positive numbers overflow

into sign bit• Not enough room for result

♦ Two large negative numbers added• Same – not enough bits

• Carry out can be OK

Page 3: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

3 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Examples

• 4-bit signed numbers• 7 + 7• 7 – 7♦ Generates carry but result OK

• -7 -7• 4 + 4♦ Generates no Cout, but overflowed

Page 4: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

4 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Overflow Detection

• Condition is that either Cn-1 or Cn is high, but not both

Page 5: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

5 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Multiplier

• Multiply by doing single-bit multiplies and shifts

• Look at combinational circuit to do this

Page 6: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

6 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Combinational Multiplier

AND computes A0 B0

Half adder computes sum. Will need FA for larger multiplier.

Page 7: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

7 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Larger Multiplier

Page 8: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

8 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Sequential Multiply

• Imagine doing over time rather than in parallel♦ Bitwise multiply♦ Shift♦ Add

• If we have time later in semester we’ll look at fancier multipliers

Page 9: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

9 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Contraction

• Can implement other functions♦ Like increment, decrement

• By using basic arithmetic circuits♦ Adder

• And removing unused portions• This is called contraction

Page 10: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

10 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Example: Incrementing

• Very common♦ Next address computation

• Specialize an adder

Page 11: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

11 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Eliminate Unneeded Gates

Page 12: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

12 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Multiplication by Constant

• What if constant is a power of two?

• What is the circuit?

Page 13: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

13 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Multiplication by Pwr of 2

• Just wires

• Division by pwr of 2 similar

Page 14: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

14 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Arbitrary Constant

Page 15: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

15 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Contraction Not Always Best

• Sometimes it pays to rethink the function

• Example of decrementer in book

Page 16: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

16 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Sign Extension

• Changing size of number common in instruction sets♦ 16-bit immediate to register, for example

• Can’t just add zeros (zero fill)♦ Would turn 4-bit -5 (1011) to 8-bit +11

(00001011)

• Sign extend (fill with left digit)♦ 1011 to 11111011

Page 17: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.

17 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

We’ve Covered

• Adders♦ Ripple carry♦ Carry lookahead

• Subtracting unsigned numbers♦ New design for adder-subtractor

• Signed numbers♦ Signed addition/subtraction

• Multiplication – just basic• Modified Circuits


Related Documents