Lecture 04
Lecture 04
Óbuda University,
Microelectronics and Technology Institute
• Arithmetic circuits
– General aspects, and elementary circuits
– Addition/subtraction
– BCD arithmetics
– Multipliers
– Division
1
ARITHMETIC CIRCUITS
ARITHMETIC CIRCUITS:
BASIC BUILDING BLOCKS
Below I will discuss those combinational logic building
blocks that can be used to perform addition and subtraction
operations on binary numbers. Addition and subtraction are
the two most commonly used arithmetic operations, as the
other two, namely multiplication and division, are
respectively the processes of repeated addition and
repeated subtraction.
We will begin with the basic building blocks that form the
basis of all hardware used to perform the aforesaid
arithmetic operations on binary numbers. These include
half-adder, full adder, half-subtractor, full subtractor and
controlled inverter.
2
HALF-ADDER AND FULL-ADDER
Half-adder
This circuit needs 2 binary inputs and 2 binary outputs.
The input variables designate the augend and addend bits: the
output variables produce the sum and carry.
Full-adder
Is a combinational circuit that forms the arithmetic sum of 3 bits.
Consists of 3 inputs and 2 outputs.
When all input bits are 0, the output is 0.
The output S equal to 1 when only one input is equal to 1 or
when all 3 inputs are equal to 1.
The C output has a carry of 1 if 2 or 3 inputs are equal to 1.
3
ON THE IMPLEMENTATION
OF THE FULL ADDER
xi yi ci-1
xi yi ci-1 ci si yi
si
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1 ci-1
FA 0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
ci
si (e) ci
(d)
(f)
xi
yi si
ci-1 8
(g)
4
FULL ADDER IMPLEMENTATIONS
A
• Standard approach B
S
– 6 gates Cin
Cout = A B + C(A + B)
5
FULL ADDER IMPLEMENTED IN CMOS
11
Cout = A B + C(A + B)
___
S = (A + B +C )Cout + A B C
6
28 TRANSISTOR CMOS FULL ADDER
VDD
VDD
Ci A B
A B
A
B
Ci B
VDD
A
X
Ci
Ci A S
Ci
A B B VDD
A B Ci A
Co B
Cout = A B + C(A + B)
___ 28 transistors
S = (A + B +C )Cout + A B C
7
HALF-SUBTRACTOR
A half-subtractor is a combinational circuit that can be used
to subtract one binary digit from another to produce a
DIFFERENCE output and a BORROW output. The
BORROW output here specifies whether a ‘1’ has been
borrowed to perform the subtraction.
Control 0 ADD
Control 1 SUBTRACT
8
FULL SUBTRACTOR
FULL SUBTRACTOR
9
FULL SUBTRACTOR
CONTROLLED INVERTER
A controlled inverter is needed when an adder is to be used as
a subtractor. Subtraction is addition of the 2’s complement of
the subtrahend to the minuend. Thus, the first step towards
implementation of a subtractor is to determine the 2’s
complement of the subtrahend. And for this, one needs firstly to
find 1’s complement. A controlled inverter is used to find 1’s
complement. A one-bit controlled inverter is a two-input EX-OR
gate with one of its inputs treated as a control input.
10
ADDER/SUBTRACTOR
• Use an adder to do subtraction thanks to 2s complement
representation
– A – B = A + (– B) = A + B' + 1
– Control signal selects B or 2s complement of B
A3 B3B3' A2 B2B2' A1 B1B1' A0 B0B0'
A B A B A B A B
Add'
Cout Cin Cout Cin Cout Cin Cout Cin
Subtract
Sum Sum Sum Sum
S3 S2 S1 S0
Overflow
TWO’S COMPLEMENT
ADDER/SUBTRACTOR
Q = (q3 q2 q1 q0)2
P = (p3 p2 p1 p0)2
4A3A2A 1A 4B 3B 2B 1B
Select
MUX (74157) S
4Y 3Y 2Y 1Y G
A4 A3 A2 A1 B4 B3 B2 B1
C4 ADDER (7483) C0
Select Function
S4 S3 S2 S1
0 R=P+Q
1 R=P+Q+1
R = (r4 r3 r2 r1)2
11
RIPPLE CARRY ADDER
The full adder is for adding two operands that are only one bit
wide. To add two operands that are, say four bits wide, we
connect four full adders together in series. The resulting circuit
is called a ripple carry adder for adding two 4-bit operands.
The ripple-carry adder is slow because the carry-in for each full
adder is dependent on the carry-out signal from the previous
FA. So before FAi can output valid data, it must wait for FAi–1 to
have valid data.
CARRY-LOOKAHEAD ADDER
The layout of a ripple carry adder is simple, which allows
for fast design time, however, the ripple carry adder is
relatively slow, since each full adder must wait for the carry
bit from the previous full adder.
12
FULL ADDER: GENERATION AND
PROPAGATION OF CARRY
A B
Sum
Co = A B + (A B)Ci
or
Co = A B + (A + B)Ci
Co = G + P Ci
Define G and P auxiliary functions
RIPPLE-CARRY ADDERS
• Critical Delay
– The propagation of carry from low to high order
stages Cin
4 stage
@0 A @1 @N+1 adder
@0 B A0 S0 @2
@N Cin B0 C1 @2
Cout
@N+2
@0 A
@0 B @1 A1 S1 @3
B1 C2 @4
late two gate delays
arriving to compute Cout A2 S2 @5
signal B2 C3 @6
A
B A3 S3 @7
S
B3 Cout @8
Cin
13
CRITICAL PATH TROUGH
A RIPPLE CARRY ADDER
14
FASTER ADDITION:
CARRY LOOKAHEAD LOGIC
Operands
Carry
Logic
FA FA FA FA
Sum
CARRY-LOOKAHEAD LOGIC
• Carry generate: Gi = Ai Bi
– Must generate carry when A = B = 1
15
CARRY-LOOKAHEAD LOGIC
• Re-express the carry logic as follows:
– C1 = G0 + P0 C0
– C2 = G1 + P1 C1 = G1 + P1 G0 + P1 P0 C0
– C3 = G2 + P2 C2 = G2 + P2 G1 + P2 P1 G0 + P2 P1
P0 C0
– C4 = G3 + P3 C3 = G3 + P3 G2 + P3 P2 G1 + P3 P2
P1 G0
+ P3 P2 P1 P0 C0
CARRY-LOOKAHEAD IMPLEMENTATION
Adder with propagate and generate outputs
Ai Pi @ 1 gate delay
Bi
Ci Si @ 2 gate delays
C0 C0 C0
P0 C1 P0 P0
G0 P1 P1
P2 P2
G0 P3
C0 P1 G0
P0 P2 P1
P1 P2
G1 C3 P3
G0 P2 G1
P1 C2
P2
G2 P3
G1 C4
G2
P3
G3
16
CARRY LOOKAHEAD CIRCUITRY
CARRY-LOOKAHEAD IMPLEMENTATION
Carry-lookahead logic generates individual carries
Sums computed much more quickly in parallel
However, cost of carry logic increases with more stages
Cin Cin
A0 S0 @2
B0
A0 S0 @2
B0 C1 @2 C1 @3
A1 S1 @4
B1
A1 S1 @3
B1 C2 @4 C2 @3
A2 S2 @4
B2
A2 S2 @5
B2 C3 @6 C3 @3
A3 S3 @4
B3
A3 S3 @7
B3 Cout @8 C4 @3 C4 @3
17
4-BIT CARRY LOOKAHEAD ADDER CIRCUIT
18
CARRY LOOKAHEAD ADDERS: FEATURES
• By adding more hardware, we reduced the number of levels in the
circuit and sped things up.
• We can “cascade” carry lookahead adders, just like ripple carry
adders. (We’d have to do carry lookahead between the adders too.)
• How much faster is this?
– For a 4-bit adder, not much. There are 4 gates in the longest
path of a carry lookahead adder, versus 9 gates for a ripple carry
adder.
– But if we do the cascading properly, a 16-bit carry lookahead
adder could have only 8 gates in the longest path, as opposed to
33 for a ripple carry adder.
– Newer CPUs these days use 64-bit adders. That’s 12 vs. 129
gates!
• The delay of a carry lookahead adder grows logarithmically with the
size of the adder, while a ripple carry adder’s delay grows linearly.
19
CARRY-SELECT ADDER
Redundant hardware to make carry calculation go faster
Compute two high-order sums in parallel while waiting for carry-in
One assuming carry-in is 0 and another assuming carry-in is 1
Select correct result once carry-in is finally computed
C8 4-bit adder 1
[7:4] adder
high
C8 0
4-bit adder
[7:4] adder
low
C8 S7 S6 S5 S4 S3 S2 S1 S0
CARRY-SELECT ADDERS
20
MULTILEVEL CARRY-SELECT ADDERS
42
21
BCD ADDITION
A BCD adder is used to perform the addition of BCD numbers.
A BCD digit can have any of the ten possible four-bit binary
representations, that is, 0000, 0001, , 1001, the equivalent of
decimal numbers 0, 1, … , 9.
When we set out to add two BCD digits and we assume that
there is an input carry too, the highest binary number that we
can get is the equivalent of decimal number 19 (9+9+1).
This binary number is going to be (10011)bin. On the other
hand, if we do BCD addition, we would expect the answer to
be (0001 1001)BCD. And if we restrict the output bits to the
minimum required, the answer in BCD would be (1 1001)BCD.
44
22
FUNCTIONAL DIAGRAM OF A BCD
ADDER (1 DIGIT)
C4
B3 B3 C4 „0” B3
B2 B2 & 1 B2
B1 B1 B1
B0 B0 „0” B0
Binary Binary
adder
& adder
A3 A3 A3 S3 S3
S3
A2 A2 A2 S2 S2
S2
A1 A1 A1 S1 S1
S1
A0 A0 A0 S0 S0
C0 S0 C0
„0” „0”
The first adder adds the two codes corresponding to the k-th
decimal place, the second adds 6 if necessary. 45
23
SUBTRACTION IN BCD (8421) CODE
47
=1 =1 =1 =1
V
0 0 If V = 0 then Xk = Ak
8X3+4X2+2X1+X0 =
= 9 – (8A3+4A2+2A1+A0)
X3 X2 X1 X0
24
SSI MODULAR LOGIC: 4-BIT BCD ADDER
49
50
25
4-BIT BCD ADDER LOGIC DIAGRAM
Gate count 75 51
74F583 (incl. inverters)
MULTIPLIERS
A binary multiplier is an electronic circuit used in digital
electronics, such as a computer, to multiply two binary numbers.
26
THEORY OF MULTIPLICATION
Basic Concept
multiplicand 1101 (13)
multiplier * 1011 (11)
1101
1101
Partial products 0000
1101
10001111 (143)
COMBINATIONAL MULTIPLIER
A3 A2 A1 A0
B3 B2 B1 B0
A2 B0 A2B0 A1 B0 A0 B0
A3 B1 A2 B1 A1 B1 A0 B1
A3 B2 A2 B2 A1 B2 A0 B2
A3 B3 A2 B3 A1 B3 A0 B3
S7 S6 S5 S4 S3 S2 S1 S0
27
THE ARRAY MULTIPLIER (4x4 BIT)
FA HA HA HA
FA FA FA FA
FA FA HA FA
S7 S6 S5 S4 S3 S2 S1 S0
total = 88 gates!
28
SSI REALIZATION OF 4x4 BIT MULTIPLIER
57
COMBIATIONAL MULTIPLIER
Sum In X Cin
29
MAKING A 2n-BIT MULTIPLIER
USING n-BIT MULTIPLIERS
N1 = (24H1 + L1)
N2 = (24H2 + L2)
Multiplying out
30
MAKING A 2n-BIT MULTIPLIER
USING n-BIT MULTIPLIERS
2n-bit by 2n-bit multiplication:
31
MULTIPLIER: MODULAR STRUCTURE
16 BIT ADDER
32
8x8 BIT COMBINATIONAL MULTIPLIER
4x4 bit partial products are generated by four 256x8 bit ROMs
33
MULTIPLICATION: SPEEDING IT UP
34
BOOTH ENCODING MULTIPLICATION
35
MULTIPLIERS: COMPLEXITY
8-bit 3000
16-bit 9000
32-bit 21000
REVISION QUESTIONS
36
PROBLEMS AND EXERCISES
1. Implement the 2-bit adder function (i.e., 2-bit binary
number AB plus 2-bit binary number CD yields 3-bit result
XYZ) using three 8:1 multiplexers. Show your truth table and
how you derived the inputs to the multiplexers.
37