Title: Arithmetic Circuits
1Arithmetic Circuits
2Interest
- Simplified CPU, showing only the arithmetic-logic
unit (ALU) and how it connects with the registers
(collectively called the register file).
3Arithmetic circuits in the computer
- Adders Subtracters Add subtract in binary.
- CPU does this in arithmetic logic unit (ALU)
- ALU
- Add subtract
- Multiply divide
- Complement compare.
- Shift rotate.
- Increment and decrement.
- Perform logic operations (AND, OR, XOR)
4Binary Addition
11 carry 11010 1100 100110
26 12 38
- Double check answer in base 10 number
5Questions
- Q. What is the sum of binary 110001100
101010101? - A. 1011100001
- Q. What is the base 10 number of the sum of
binary 110001100 101010101? - A. 51212864321737.
- Q. What is the sum of binary 11111 110011?
- A. 1010010
- Q. What is the base 10 number of the sum of
binary 11111 110011? - A. 6416282.
6Half Adders
Block Diagram
Truth Table
Inputs
Outputs
S (Sum)
A
Half Adder
B
Co (Carry out)
Logic Diagram
Inputs
Half Adder
Outputs
A
S (Sum)
XOR
B
AND
Co (Carry out)
- The half adder circuit adds only the LSB (1s)
- A full adder must be used for 2s, 4s, 8s, 16s
higher places in binary addition.
7Full Adders
Truth Table
Block Diagram
Inputs
Outputs
Cin
S (Sum)
Full Adder
A
Co (Carry out)
B
Logic Diagram
Inputs
Full Adder
Outputs
Half Adder
Cin
A
S
S
B
Half Adder
A
S
B
Co
Co
Co
8Three-Bit Adders
- Half and full adders are connected to form adders
that add several binary digits (bits) at one
time. - Organized as you would add and carry by hand.
- In a parallel adder, all bits are applied to the
inputs at the same time.
9Parallel Three-Bit Adder
Problem
A1
A2
A3
B1
B2
B3
A
S
Half Adder1s
Co
B
Inputs
Cin
S
Full Adder
A
Co
B
Cin
S
Full Adder
A
Co
B
8s
4s
2s
1s
Sum Output
10Binary Subtraction
11010 - 1100 1110
26 - 12 14
- Double check answer in base 10 number
11Questions
- Q. What is the solution for binary 1100100 -
1010101? - A. 1111
- Q. What is the base 10 number of the subtraction
of binary 1100100 - 1010101? - A. 842115.
- Q. What is the solution for binary 11001 - 1011?
- A. 1110
- Q. What is the base 10 number of the subtraction
of binary 11001 - 1011? - A. 84214.
12Half Subtractors
Block Diagram
Truth Table
Inputs
Outputs
Di (Difference)
A
Half Subtractor
B
Bo (Borrow)
Logic Diagram
Inputs
Half Subtractor
Outputs
A
Di (Difference)
XOR
B
AND
Bo (Borrow)
- Adders and subtractors are very similar.
- When subtracting several columns of binary
digits, take into account borrowing.
13Full Subtractors
Truth Table
Block Diagram
Inputs
Outputs
Bin
Di (Difference)
Full Subtractor
A
Bo (Borrow)
B
Logic Diagram
Inputs
Full Subtractor
Outputs
Half Subtractor
Bin
A
Di
Di
B
Half Subtractor
A
Di
B
Bo
Bo
Bo
14Parallel Four-Bit Subtractor
Problem
A2
A1
A0
A3
-
B3
B2
B1
B0
Di
Half Subtractor 1s
A
Bo
B
Bin
Di
Full Subtractor 2s
A
Bo
Inputs
B
Bin
Di
Full Subtractor4S
A
Bo
B
Bin
Di
Full Subtractor8S
A
Bo
B
Output Difference
8s
4s
2s
1s
15Using adders for subtraction
Decimal subtraction
Binary subtraction
Special technique subtraction
1010 1001 10011
1010 - 0110 100
10 - 6 4
1s complement And add
End around carry
1
100
Difference
- 1s complement is illustrated above.
- With 2s complement numbers, you can add
subtract signed numbers (i.e. -1)
16IC Adders
Problem
7483 4-bit binary adder
A2
A1
A0
A3
-
B3
B2
B1
B0
A1
Vcc
S1
B1
S2
A2
S3
B2
A3
Inputs
S4
B3
C4
A4
7483
B4
Carry input
C0
GND
4s
2s
8s
1s
16s
Output
17Binary Multiplication
- Binary multiplication is just repeated addition.
6 x 5 30
6
6
6
6
6
30
Multiplicand
Multiplier
Product
110 x 101 110 000 110 11110
Multiplicand
Multiplier
First partial product 1s
Second partial product 2s
Third partial product 4s
Product
18Questions
- Q. What is the product of binary 10111 1010?
- Q. What is the product of the above question
using decimal numbers?
19Binary Multipliers
Repeated Addition-type Multiplier System Block
Diagram
Disadvantage Slow with large numbers.
110 x 101 11110
Problem
6 x 5 30
20Add Shift-Type Multiplier Circuit
Operation
Multiplicand Register
Multiplier Register
Accumulator Register
Control Line
Start
1
1
0
1
0
0
1
0
0
0
Clear Load
1 Add 0 Do not add
1s
Parallel Adder
Control 1
ParallelAdder
2s
4s
Multiplier Register
Accumulator Register
Control 1 Add 0110
1s
2s
1
1
0
1
Add
0
0
1
4s
8s
Multiplier Register
Accumulator Register
The 1 is lost.
Multiplier Register
Accumulator Register
0
0
0
1
Shift Right
1
1
0
1
Parallel Adder
Control 0
1
0
0
1
0
0
0
Multiplier Register
Accumulator Register
Control 0 Do not add.
0
0
0
1
1
1
0
Add
Multiplier Register
Accumulator Register
The 0 is lost.
1
1
0
0
0
1
0
Shift Right
0
Control 1
Parallel Adder
110 x 101 11110
Problem
6 x 5 30
Multiplier Register
Accumulator Register
Control 1 Add 0110
1
1
0
1
0
1
1
Add
The 1 is lost.
Multiplier Register
Accumulator Register
Finish
1
0
0
1
1
1
0
Shift Right
1
Final Product
212s Complement
- 2s complement is widely used in microprocessors.
- Microprocessors must process both negative and
positive numbers. - 2s complement represents
- Sign of the number.
- Magnitude of the number.
- 2s complement procedure
- Convert decimal to binary numbers.
- Change to 1s complement.
- Add 1.
222s Complement 4-bit
Sign Bit 1(-) 0)
Accumulator Register
0
0
0
MSB
LSB
23Questions
- Q. What is 2s complement in a 4 bit register for
negative 5?
- Q. What is 2s complement in a 4 bit register for
negative 9?
- A. Need an 8-bit register to do this operation.
242s Complement Addition
- 2s complement notation is easily used in addition
and subtraction of signed numbers. - 2s complement is in the sum of sample problems.
0001 0101 0110
1 5 6
1110 1101 11011
(-2) (-3) -5
Discard
0110 1101 10011
(6) (-3) 3
(2) (-4) -2
0010 1100 1110
Discard
252s Complement Subtraction
- An adder is used for subtraction. This is done by
converting the subtrahend to its 2s complement
and adding.
0110 1110 10100
6 - 2 4
1110 1111 11101
(-2) -(1) -3
Discard
Discard
1010 0011 1101
(-6) -(-3) -3
(-4) -(-4) 0
1100 0100 10000
Discard
26Questions
- Q. Using 2s complement, what is the sum of
negative 5 and negative 1?
- Q. Using 2s complement, what is the sum of
negative 1 and positive 1?
27Questions Continued
- Q. Using 2s complement, what is the difference of
negative 5 and negative 1?
- Q. Using 2s complement, what is the difference of
negative 1 and positive 1?
282s Complement 8-bit
Sign Bit 1() 0(-)
Accumulator Register
0
0
0
0
0
0
0
2s
64s
1s
32s
16s
8s
4s
MSB
LSB
29Questions
- Q. Using 2s complement, what is the sum of
positive 55 and positive 21?
- Q. Using 2s complement, what is the sum of
negative 71 and positive 63?
30Questions Continued
- Q. Using 2s complement, what is the difference of
positive 125 and positive 127?
- Q. Using 2s complement, what is the difference of
negative 6 and positive 31?
Discard
312s Complement Adder/Subtractor
Problem
A2
A1
A0
A3
2s Complement Inputs
B3
B2
B1
B0
Cin
S
/-
A0
Full Adder 1s
A
Co
B
B0
Cin
S
A1
Full Adder 2s
A
Co
B
B1
Cin
S
A2
Full Adder 4S
A
Co
B
B2
Cin
S
A3
Full Adder8S
A
Co
B
Mode Control
2s Complement OutputSum or Difference
B3
sign
4s
2s
1s
Subtract1Add 0
32Troubleshooting a Full Adder
- Visual Inspection Use all senses.
- Check power supply and ground.
- Check inputs for outputs in truth table using a
logic probe. - Isolate to the AND or XOR or OR gate.
33Conclusions
- Q. What are the logic components that make up a
half adder? - A. An Exclusive OR gate and AND gate.