T5 Combinational Circuit
T5 Combinational Circuit
Combination Circuit
1
What is Combinational Circuit?
• Combinational Circuit
– A digital circuit whose output depends only upon the present
combination of its inputs
– Output changes only when any of the inputs changes
• As oppose to Sequential Circuit which is
– A digital circuit whose output depends not only upon the present
input values, but also the history of input and output values
– Have feedbacks from outputs
– More complicated and difficult to analyze
• Typical modern digital circuit includes both combination
and sequential circuits
2
How to Design Combinational Circuits?
Step Description
3
Example: Count Number of 1s
• Problem: Output in binary the
number of 1s on three inputs
(e.g., 3 people are voting)
• E.g.: 01001 10110 00000
– Step 1: Capture the function
• Truth table or equation?
– Truth table is straightforward
a
– Step 2: Convert to equation b
a c
• y = a’bc + ab’c + abc’ + abc
Class
• z = a’b’c + a’bc’ + ab’c’ + abc
b
c a
b
Derivation a
b
c
yc
Class
a
z
b
– Step 3: Implement as a gate- a Derivation
c
based circuit b a
b
c
4
Example: Three 1s Detector
• Problem: Detect three consecutive 1s
(which represent certain event) among
8 inputs: abcdefgh
– 00011101 1 10101011 0
11110000 1 a abc
b
– Step 1: Capture the function c
bcd
a
• Truth table or equation? d
– Truth table too big: 2^8=256 rows cde
– Equation: create terms for each e y
possible case of three consecutive 1s def
f
• y = abc + bcd + cde + def + efg + fgh
efg
– Step 2: Convert to equation -- g
already done fgh
h
– Step 3: Implement as a gate-
based circuit
5
Combinational Building Blocks
6
Multiplexor (Mux)
• Mux: A popular combinational building block
– Like a railyard switch
Connect i0 to d 0 0 1 0
d = s0’ i0 i1’+ s0’ i0 i1+
when s0 is 0, 0 1 0 1
0 1 1 1
s0 i0’ i1+ s0 i0 i1
otherwise
1 0 0 0 = s0’ i0 + s0 i1
connect i1 to d
1 0 1 1
1 1 0 0
1 1 1 1
i0
2×1
d
i0 i1
d
i1
s0
s0
2x1 mux 8
Mux Internal Design
i0
4×1
i1 i0
d i1
i2 d
i2
i3
i3
s1 s0
s1 s0
4x1 mux
9
4-bit 2x1 Mux
2×1
a3 i0 Simplifying
d
b3 i1 notation:
s0
4-bit 4
2×1 4 C
a2 i0 2x1
d A I0 4
b2 i1
s0 4 D C is short
B I1 for
2 1
a1 i0 × s0
d
b1 i1
s0 c3
2×1 s0 c2
a0 i0
d c1
b0 i1
s0
s0 c0
11
Half Adder
• Derive Boolean functions (sum-of-
minterms) from the truth table for
A Sum both outputs
Half-Adder
B Carry Sum = A’B + AB’ = m1 + m2 = Σ (1, 2)
= (A+B)(A’+B’) = M0•M3 = Π (0, 3)
A
Sum Sum
A B
B
Carry
Carry
13
Full Adder
• Derive minterm/Maxterm
A Sum expressions from the truth table for
B Full-Adder both outputs
C Carry Sum = ?
A B C Sum Carry
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0 Logic Circuit?
1 0 1
1 1 0
1 1 1 1 1
14
Full Adder
A Sum
B Full-Adder
C Carry
A B C Sum Carry
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
Sum
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
16
Application of XOR in Full Adder
A
B sum
carry
sum
C
A sum
H.A. H.A.
B
carry
carry
C
17
Multi-bit Number Addition
Carry: 0 1 0 0 0 Carry: 0 0 0 0 0
A: 0100 =4 + 0 1 1 0 = +6
+ B: 0101 =5 + 0 0 0 1 = +1
Sum: 1001 =9 Sum: 0 1 1 1 = +7
a3 b3 a2 b2 a1 b1 a0 b0 ci
A B
a b ci a b ci a b ci a b ci a3 a2 a1 a0 b3 b2 b1 b0
FA FA FA FA 4-bit adder ci
co s co s co s co s cout s3 s2 s1 s0
c3 c2 c1
Cout S
cout s3 s2 s1 s0
(a) (b)
19
Two’s Complement Subtractor
A B
• Using two’s complement representation
A – B = A + (-B) N-bit
= A + (two’s complement of B)
= A + invert_bits(B) + 1
A B 1
• So build subtractor using adder by Cout Adder cin
inverting B’s bits, and setting carry in to 1
S
A3 B3 A2 B2 A1 B1 A0 B0
Cout FA C3 FA C2 FA C1 FA Cin
S3 S2 S1 S0
Or 20
Lookahead Adder
4-Bit 2’s Complement Adder
A3 B3 A2 B2 A1 B1 A0 B0
C_out FA C3 FA C2 FA C1 FA C0
0
S3 S2 S1 S0
Overflow
21
4-Bit 2’s Complement Subtractor
A3 B3 A2 B2 A1 B1 A0 B0
Cout FA C3 FA C2 FA C1 FA C0
1
S3 S2 S1 S0
Overflow
22
Arithmetic-Logic Unit: ALU
23
Encoder
• Each input is given a binary code
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
24
Decoder
• Decoder: Popular combinational
logic building block, in addition to
d0 1 d0 0 d0 0 d0 0
logic gates
0 i0 d1 0 1 i0 d1 1 0 i0 d1 0 1 i0 d1 0
– Converts input binary number to
0 i1 d2 0 0 i1 d2 0 1 i1 d2 1 1 i1 d2 0
one high output
d3 0 d3 0 d3 0 d3 1
• 2-input decoder: four possible
input binary numbers
– So has four outputs, one for each d0 0
i1’i0’ d0
possible input binary number 1 i0 d1 0
• Internal design i1’i0 d1 1 i1 d2 0
– AND gate for each output to e d3 1
i1i0’ d2
detect input combination 1
• Decoder with enable e i1i0 d3 d0 0
– Outputs all 0 if e=0 1 i0 d1 0
– Regular behavior if e=1 1 i1 d2 0
Inputs Outputs
x y z D0 D1 D2 D3 D4 D5 D6 D7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
26
Gate-Level Implementation of 3×8 Decoder
x
D0 = x’y’z’
y
D1 = x’y’z
z
D2 = x’yz’
D3 = x’yz Minterm
Generator
D4 = xy’z’
D5 = xy’z
D6 = xyz’
D7 = xyz
27
Implementation of Any Circuit with a Decoder
• P (A, B, C) = Σ m(1, 2, 3, 5) and Q (A, B, C) = Σ m(0, 4, 5, 6)
• Since there are three inputs and total of 8 minterms, we can
implement the circuits with a 3-to-8-line decoder
0
A 22 1
P
2
B 21 3×8 Decoder 3
4
C 5
20
6 Q
7
28
Decoder Example
• New Year’s Eve Countdown Display
– Microprocessor counts from 10 down to 0 in binary
– Want to illuminate one of 11 lights for each binary number
– May use a 4x16 decoder
• 5 outputs unused
3
21540 0
Happy
1
00 01 New Year
i0 d0
10 010
Microprocessor
i1 d1 1
010 i2 d2 100 2
00 i3 d3 100 3
d4 001 4
d5 010 5
…
e
d9
d10 9
4x16 d11 10
…
…
d15
decoder 29
Buffer and Three State (Tri-state) Buffer
• A buffer is a one directional transmission logic device
– somewhat like a NOT gate without complementing the binary value
– amplify the driving capability of a signal
– insert delay
– Protect input from output
• A three state (Tri-state) buffer can have three different output values,
controlled by an enable bit
– 0 (off) when B = 1, A = 0;
– 1 (on) when B = 1, A = 1;
– Z (high impedance, no voltage) when B = 0, A = x;
30
Tri-state Buffers
• Different types of tri-state buffers
31
Tri-state Buffer Application – Bidirectional I/O Port
rcv_data
inbound_data
32
Device
32 32
reg_to_bus data_to_from_bus
send_data
32
Applications of Decoders and Tri-state Buffers
• Based on the control signals, only one path will be connected
33
Alternative Implementation of Datapath
Control
• Based on the control signals, only one path will be connected
34