Beruflich Dokumente
Kultur Dokumente
C
i+1
Carry Ripple
A and B inputs change, corresponding changes to
C
IN
inputs ripple through the circuit.
Full Adder
B A C
IN
C
OUT
SUM
Full Adder
B A C
IN
C
OUT
SUM
Full Adder
B A C
IN
C
OUT
SUM
B
1
A
1
B
0
A
0
B
2
A
2
C
IN
= 0
Q
1
Q
0
Q
2
t = 0, A & B change
t = 30 ns, Adder 0
outputs respond
t = 60 ns, Adder 1
outputs respond
t = 90 ns, Adder 2
outputs respond
Carry-Look-Ahead
The accumulated delay in large parallel adders can be prohibitively large.
Example : 16 bits using 30 ns full-adders :
Solution : Generate the carry-input signals directly from the A and B inputs rather
than using the ripple arrangement.
ns 480 ns 30 16 =
Designing a Carry-Look-Ahead Circuit
B A C
IN2
C
OUT
SUM
B A C
IN1
C
OUT
SUM
B A C
IN0
C
OUT
SUM
Q
2
Q
1
Q
0
Carry-look-
ahead logic
B
2
A
2
B
1
A
1
B
0
A
0
( )
( ) | |( )
1 1 1 1 0 0 0 0
1 1 1 1 1
1 2
B A B A B A B A C
B A B A C
C C
IN
IN
OUT IN
+ + + + =
+ + =
=
C
IN
( )
0 0 0 0
0 1
B A B A C
C C
IN
OUT IN
+ + =
=
IN IN
C C =
0
E&CE 223 Digital Circuits and Systems (A. Kennings) Page 33
Carry Lookahead Adders
s(i)
c(i+1)
x(i)
y(i)
c(i)
g(i)
p(i)
So ripple adders can be slow, but we could calculate the carry ins faster, then we
can build a faster adder.
Consider the i-th bit of the adder, and identify two signals, namely the propagate p
i
and generate g
i
:
Write the carry out c
i+1
in terms of the p
i
and g
i
signals
instead.
S(i)=XOR(p(i)+c(i))
E&CE 223 Digital Circuits and Systems (A. Kennings) Page 34
Writing The Carries In Terms of Propagates and Generates
We can consider writing all the carry outs in terms of the p
i
and g
i
signals, but
substitute previously calculated carries as we go
We have written the carries in terms of values all computed when the inputs are
applied to the circuit:
All p
i
and g
i
are computed after 1 gate delay.
All c
i
are then computed after 2 more gate delays, since the are 2-level SOP in
terms of p
i
and g
i
.
s(i)
c(i+1)
x(i)
y(i)
c(i)
g(i)
p(i)
E&CE 223 Digital Circuits and Systems (A. Kennings) Page 35
Carry Lookahead Performance
If we use carry lookahead to generate all of the carries, then our adder will have a
delay of 3 units of gate delay to get c
n
.
What is the penalty to be paid?
The carry lookahead circuit is 2-level logic (SOP) and we should see that
higher numbered carries require more AND gates as well as AND/OR gates
with a large number of inputs.
It becomes impractical (cant get AND/OR gates with large numbers of
inputs).
It becomes expensive in terms of the number of logic gates required.
So, we get better performance, but we pay for it in terms of area and cost of the
circuit implementation.
E&CE 223 Digital Circuits and Systems (A. Kennings) Page 36
Combining Ripple Adders and Carry Lookahead
We can get something better than a ripple adder, but not as good as full carry
lookahead by cascading smaller carry lookahead adders
E.g., consider a 16-bit adder composed of 4, 4-bit carry lookahead adders.
4-CLA 4-CLA 4-CLA 4-CLA
Performance will be 3+2+2+2 = 9 units of gate delay to get c
1
6 (notice a ripple
adder would have required 2(16)+1 = 33 units of delay.
37
Carry Lookahead Logic
38
4 Bit Adder Subtractor
Desirable to use same hardware for both operations
2s complement addition for subtraction
Overflow
Addition/subtraction of 2 n bit numbers may produce n+1 bit
output
Problem if fixed # of bits (n) are allocated for input and output
Must detect its occurrence
d=101-010
d=101+2scom(010)
d=101+1scomp(010)+1
d=101+101+1
d=1011
d=3
M=0, add
M=1, Subtract
M=1, XOR=Complement
M=0, XOR=Pass through
ignore
39
BCD Adder
Binary Sum BCD Sum #
k Z8 Z3 Z2 Z1 C S8 S4 S2 S1
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 1 1
0 0 0 1 0 0 0 0 1 0 2
0 0 0 1 1 0 0 0 1 1 3
0 0 1 0 0 0 0 1 0 0 4
0 0 1 0 1 0 0 1 0 1 5
0 0 1 1 0 0 0 1 1 0 6
0 0 1 1 1 0 0 1 1 1 7
0 1 0 0 0 0 1 0 0 0 8
0 1 0 0 1 0 1 0 0 1 9
0 1 0 1 0 1 0 0 0 0 10
0 1 0 1 1 1 0 0 0 1 11
0 1 1 0 0 1 0 0 1 0 12
0 1 1 0 1 1 0 0 1 1 13
0 1 1 1 0 1 0 1 0 0 14
0 1 1 1 1 1 0 1 0 1 15
40
Binary Sum BCD Sum #
k Z8 Z3 Z2 Z1 C S8 S4 S2 S1
1 0 0 0 0 1 0 1 1 0 16
1 0 0 0 1 1 0 1 1 1 17
1 0 0 1 0 1 1 0 0 0 18
1 0 0 1 1 1 1 0 0 1 19
41
Magnitude Comparator
Classical approach
3 outputs and 2n inputs
Large logic complexity, if n >3
Alternative Approach
2-step process
F
1
(A = B)
F
2
(A > B)
F
3
(A < B)
magnitude
comparator
4
4
A
B
42
Magnitude Comparator
2-step process
1. Define
x
i
( A
i
B
i
) = A
i
B
i
+ A
i
B
i
, 0 < i < 3
2. F
1
= ( A = B) = x
3
x
2
x
1
x
0
F
2
= ( A > B) = ( A
3
> B
3
)
+ (A
3
= B
3
) - (A
2
> B
2
)
+ (A
3
= B
3
) - (A
2
= B
2
) - (A
1
> B
1
)
+ (A
3
= B
3
) - (A
2
= B
2
) - (A
1
= B
1
) - (A
0
> B
0
)
= A
3
B
3
+ x
3
A
2
B
2
+ x
3
x
2
A
1
B
1
+ x
3
x
2
x
1
A
0
B
0
F
3
= A
3
B
3
+ x
3
A
2
B
2
+ x
3
x
2
A
1
B
1
+ x
3
x
2
x
1
A
0
B
0
= ( F
1
+ F
2
)
43
Magnitude Comparator
44
Decoders
Code of n bits can represent 2
n
decode outputs
One output is true at a time
x
y
x y x
x
y x
y
y
y
x
xy
x y D
0
D
1
D
2
D
3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1
= D
0
= D
1
= D
2
= D
3
45
Decoders with Enable
If E = 0 all outputs are disabled
Outputs are active low
E x y Y
0
Y
1
Y
2
Y
3
1 X X 1 1 1 1
0 0 0 0 1 1 1
0 1 0 1 0 1 1
1 0 1 1 1 0 1
1 1 1 1 1 1 0
Y
0
Y
1
Y
2
Y
3
E
x
y
Y
0
Y
1
E
y
x
Y
2
Y
3
2
1
2 x 4
2
0
decoder
(enable)
46
Larger Decoders
Larger decoders are built with smaller ones
Special decoders (other than n to 2
n
)
BCD to 7 segment display
47
Function implementation using Decoders
Adder S = (1,2,4,7); C = (3,5,6,7)
E&CE 223 Digital Circuits and Systems (A. Kennings) Page 48
Decoder based realization
Implement the following function using 3 to 8 and 2 to 4 decoders
F= (0,3,5,7)
X
Y
z
m(0)
m(1)
m(4)
m(3)
m(6)
m(5)
m(2)
m(7)
E&CE 223 Digital Circuits and Systems (A. Kennings) Page 49
Decoder based realization
Implement the following function using 3 to 8 and 2 to 4 decoders
F= (0,3,5,7)
X
Y
m(0)
m(1)
m(3)
m(2)
000
011
101
111
Z
0
m(0)
m(1)
m(3)
m(2)
50
Encoders
Does reverse operation to decoder
Constraint only one input is active at a time
Example, Octal to Binary Encoder
Z = D1 +D3 +D5 +D7; y = D2 +D3 +D6 +D7; x = D4 +D5 +D6 +D7
Inputs Outputs
D0 D1 D2 D3 D4 D5 D6 D7 x y z
1 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 1 1
0 0 0 0 1 0 0 0 1 0 0
0 0 0 0 0 1 0 0 1 0 1
0 0 0 0 0 0 1 0 1 1 0
0 0 0 0 0 0 0 1 1 1 1
51
Priority Encoders
Encoder with priority function
Multiple inputs may be true simultaneously
Higher priority input gets the precedence
Inputs Outputs
D
0
D
1
D
2
D
3
x y V
0 0 0 0 X X 0
1 0 0 0 0 0 1
X 1 0 0 0 1 1
X X 1 0 1 0 1
X X X 1 1 1 1
Valid bit, V, indicates one or more inputs are true
at the same time
Higher priority input gets the precedence
52
Priority Encoders - Circuit
x = D
2
+D
3
y = D
3
+D
1
D
2
V = D
0
+D
1
+D
2
+D
3
53
Multiplexers
A Multiplexer has n inputs, one output, and S
(2
s
= n) select (control) inputs
Passes (selects) an input depending on S
54
Function Implementation with Multiplexers
Let F(x,y,z) = (1,2,6,7)
55
Function Implementation with Multiplexers
Let F(w,x,y,z) = (1,2,6,7,10,13)
wxyz
0)0000
1)0001
2)0010
3)0011
4)0100
5)0101
6)0110
7)0111
8)1000
9)1001
10)1010
11)1011
12)1100
13)1101
14)1110
15)1111
0
1
2
3
yz
wx+wx
wx+wx+wx
wx
56
Multiplexers with Tri-stated Gates
57
Book Sections Combination Circuits
Material is covered in Sections 4.1 4.5, 4.7 4.10