0% found this document useful (0 votes)
18 views80 pages

CH4 Combinational Logic

Uploaded by

priyaiiitdm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views80 pages

CH4 Combinational Logic

Uploaded by

priyaiiitdm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

CHAPTER-4

Combinational Logic

Digital Design (with an introduction to the Verilog HDL) 6th Edition,


M. Morris Mano, Michael D. Ciletti

ECE, IIITDM Kancheepuram


Outline
 Combinational Circuits
 Analysis Procedure
 Design Procedure
 Binary Adder-Subtractor
 Decimal Adder
 Binary Multiplier
 Magnitude Comparator
 Decoders
 Encoders
 Multiplexer

2
Combinational Logic
 Logic circuits for digital systems may be combinational or
sequential.
 A combinational circuit consists of logic gates whose outputs at
any time are determined from only the present combination of
inputs.
 The diagram of a combinational circuit has logic gates with no
feedback paths or memory elements.
 A combinational circuit performs an operation that can be
specified logically by a set of Boolean functions.

3
Sequential Logic
 In contrast, sequential circuits employ storage elements in addition to
logic gates.
 Because the state of the storage elements is a function of previous inputs,
the outputs of a sequential circuit depend not only on present values of
inputs, but also on past inputs.
 The circuit behavior must be specified by a time sequence of inputs and
internal states.

4
Combinational Circuits
 A combinational circuit consists of
 Input variables
 Logic gates
 Output variables

5
Combinational Circuits

 Each input and output variable is a binary signal


 Represent logic 1 and logic 0
 There are 2n possible binary input combinations for n input variable
 Only one possible output value for each possible input combination
 Can be specified with a truth table
 Can also be described by m Boolean functions, one for each output variable
 Each output function is expressed in terms of n input variables

6
Outline
 Combinational Circuits
 Analysis Procedure
 Design Procedure
 Binary Adder-Subtractor
 Decimal Adder
 Binary Multiplier
 Magnitude Comparator
 Decoders
 Encoders
 Multiplexer

7
Analysis Procedure
 Analysis: determine the function that the circuit implements
 Often start with a given logic diagram
 The analysis can be performed by
 Manually finding Boolean functions
 Manually finding truth table
 Using a computer simulation program
 First step: make sure that circuit is combinational
 Without feedback paths or memory elements
 Second step: obtain the output Boolean functions or the truth table

8
Analysis Procedure
Step 1:
 Label all gate outputs that are a function of input variables
 Determine Boolean functions for each gate output

9
Analysis Procedure
Step 2:
 Label the gates that are a function of input variables and previously labeled gates
 Find the Boolean function for these gates

10
Analysis Procedure
Step 3:
 Obtain the output Boolean function in term of input variables
 By repeated substitution of previously defined functions

Step 4:
 Build up the truth table
As we know ahead F1, F1 = S(1, 2, 4, 7), we can verify the function by truth
table

11
Analysis Procedure
 To obtain the truth table from the logic diagram:
1. Determine the number of input variables For n inputs:
 2n possible combinations
 List the binary numbers from 0 to (2n -1) in a table
2. Label the outputs of selected gates
3. Obtain the truth table for the outputs of those gates that are a function of the
input variables only
4. Obtain the truth table for those gates that are a function of previously defined
variables at step 3
 Repeatedly until all outputs are determined

12
Analysis Procedure
 Realize the truth table “level-by-level” for verification.

13
Outline
 Combinational Circuits
 Analysis Procedure
 Design Procedure
 Binary Adder-Subtractor
 Decimal Adder
 Binary Multiplier
 Magnitude Comparator
 Decoders
 Encoders
 Multiplexer

14
Design Procedure

 Design procedure:
 start from the specification of the problem and
 culminates in a logic circuit diagram or a set of Boolean functions
 Step 1: determine the required number of inputs and outputs from the
specification
 Step 2: derive the truth table that defines the required relationship between
inputs and outputs
 Step 3: obtain the simplified Boolean function for each output as a function of
the input variables
 Step 4: draw the logic diagram and verify the correctness of the design

15
Code Conversion Example
Example: Build up a logic circuit to convert a BCD code to an Excess-3
code

 The 6 input
combinations not
listed are don’t cares
 These values have
no meaning in BCD
 We can arbitrary
assign them to 1 or 0

Note: Excess 3 code is the code with “additional” 3

16
Maps for Code Converter
 Step 1: Find inputs and outputs and the truth table.
 Step 2: Making a K-map for the inputs and outputs.
 Step 3: Find the logic expressions from the K-map.
Z y

 The six don’t care minterms (10~15) are marked with X

17
Maps for Code Converter
x w

18
Logic Diagram for the Converter
 There are various possibilities for a logic diagram that implements a circuit
 A two-level logic diagram may be obtained directly from the Boolean
expressions derived by the maps
 The expressions may be manipulated algebraically to use common gates for
two or more outputs
 Reduce the number of gates used

Simplified function Another implementation


z = D' z = D'
y = CD +C'D' y = CD +C'D' = CD + (C+D)'
x = B'C + B'D+BC'D’ x = B'C + B'D+BC'D' = B'(C+D) +B(C+D)'
w = A+BC+BD w = A+BC+BD = A+B(C+D)

19
Logic Diagram for the Converter
z = D'
y = CD +C'D' = CD + (C+D)'
x = B'C + B'D+BC'D' = B'(C+D) +B(C+D)'
w = A+BC+BD = A+B(C+D)

C + D is commonly used
to implement the three outputs

20
Outline
 Combinational Circuits
 Analysis Procedure
 Design Procedure
 Binary Adder-Subtractor
 Decimal Adder
 Binary Multiplier
 Magnitude Comparator
 Decoders
 Encoders
 Multiplexer

21
Adder

 The most basic arithmetic operation is the addition of two binary digits
 When both augend and addend bits are equal to 1, the binary sum consists
of two digits (1 + 1 = 10)
0 + 0 = 0 ; 0 + 1 = 1 ; 1 + 0 = 1 ; 1 + 1 = 10

Carry
 The higher significant bit of this result is called a carry
 A combination circuit that performs the addition of two bits is half adder
 A adder performs the addition of 2 significant bits and a previous carry is called
a full adder

22
Half Adder
 A combinational circuit that performs the addition of two bits is
called a half adder.
 two input variables: x, y
 two output variables: C (carry), S (sum)
 truth table

23
Half Adder
 Circuit implementation of a half adder

24
Full Adder
 The arithmetic sum of three input bits
 Three input bits
 x, y: two significant bits
 z: the carry bit from the previous lower significant bit
 Two output bits: C, S

25
Full Adder

26
Full Adder

27
Full Adder

𝑆 = 𝑥 ′ 𝑦 ′ 𝑧 + 𝑥 ′ 𝑦𝑧 ′ + 𝑥𝑦 ′ 𝑧 ′ + 𝑥𝑦𝑧
= 𝑧 ′ (𝑥 ′ 𝑦 + 𝑥𝑦 ′ ) + 𝑧(𝑥 ′ 𝑦 ′ + 𝑥𝑦)
= 𝑧 ′ (𝑥 ′ 𝑦 + 𝑥𝑦 ′ ) + 𝑧[ 𝑥 ′ 𝑦 ′ + 𝑥 (𝑥 ′ 𝑦 ′ + 𝑦)]
= 𝑧 ′ (𝑥 ′ 𝑦 + 𝑥𝑦 ′ ) + 𝑧[ 𝑥 ′ + 𝑥 (𝑦 ′ + 𝑥)(𝑥 ′ + 𝑦)(𝑦 ′ + y)]
= 𝑧 ′ (𝑥 ′ 𝑦 + 𝑥𝑦 ′ ) + 𝑧[ 𝑦𝑥 ′ ′ (𝑥𝑦 ′ )′]
= 𝑧 ′ (𝑥 ′ 𝑦 + 𝑥𝑦 ′ ) + 𝑧 𝑦𝑥 ′ + 𝑥𝑦 ′ ′

𝑆 = 𝑧(𝑥 ′ 𝑦 + 𝑥𝑦′) = 𝑧(𝑥𝑦)

28
Full Adder

Make a full adder Different?


using 2 half adders
and one OR gate
𝐶 = 𝑧 𝑥𝑦 + 𝑥𝑦

half adder
half adder

29
Full Adder

30
Full Adder
 A binary adder is a digital circuit that produces the arithmetic sum of two
binary numbers.
 Can be constructed with full adders connected in cascade
 The output carry from each full adder is connected to input carry of the next full adder in
the chain
 n-bit binary ripple carry adder is connected by n FAs

31
Full Adder
 Consider two binary number A = 1011 and B = 0011

Example:
4 bit binary adder

32
Carry Propagation
 As in any combinational circuit, the signal must propagate through the gates before the
output is available.
 The total propagation time is equal to the propagation delay of a typical gate times the
number of levels in the circuit.
 The longest propagation delay time in an adder is the time it takes the carry to
propagate through the full adders.
 Each bit of the sum output depends on the value of the input carry
 The value of Si will be in final value only after the input carry Ci has been propagated

33
Full Adder with P and G
 The full adder can be redrawn with two internal signals P (propagation) and G
(generation)
 The signal from input carry Ci to output carry Ci+1 propagates through an AND and a
OR gate (2 gate levels)
 For n-bit adder, there are 2n gate levels for the carry to propagate from input to output

34
Carry Propagation

 The carry propagation time is a limiting factor on the speed with which two numbers are
added
 All other arithmetic operations are implemented by successive additions
 The time consumed during the addition is very critical
 To reduce the carry propagation delay
 Employ faster gates with reduced delays
 Increase the equipment complexity
 Several techniques for reducing the carry propagation time in a parallel adder
 The most widely used technique employs the principle of carry lookahead

35
Carry Propagation and Generation

 Gi, called “carry generate”, produces a carry 1 when Ai and Bi are 1.


 Pi is called a “carry propagate”, because it determines whether a carry into stage i will
propagate into stage i + 1.

36
Carry Lookahead Logic

C3 is propagated at the
same time as C1 and C2.

 Use “carry lookahead logic” to


reduce the propagation.

37
Four-bit Adder with Carry Lookahead

Output S1 to S3 can have equal


propagation delay times
C0

38
Binary Subtractor
 The subtraction A − B can be done by taking the 2’s complement of B and
adding it to A .
 The 2’s complement can be obtained by taking the 1’s complement and adding 1.
 A - B = A + (B + 1)
 The 1’s complement can be implemented with inverters.

Example: Find 2’s complement of 10110011

01001100 1’s complement (inverted)


+ 1

01001101 2’s complement  Place inverters between each data input B and the
corresponding input of the full adder.
 C0 = 1

39
4-bit Adder-subtractor
 A B = A (2’s complement of B)
 M=0 (Adder) [M=0, A+B]
 Input of FA is A and B (B  0 = B), and C0 is 0
 M=1 (Subtractor) [M=1, A+B′+1]
 Input of FA is A and B′ (B  1 = B′), and C0 is 1

M-mode input

40
Overflow
 An overflow occurs when two number of n digits each are added
and the sum occupies n+1 digits
 An overflow can only occur when two numbers added are both
positive or both negative

The two carry bits are different

Example:

(106) (106)
(010010110) (101101010)
Overflow

41
Overflow detection
 An overflow condition can be detected by observing the carry into the sign bit position
and the carry out of the sign bit position
 If these two carries are not equal, and overflow has occurred
 If the output V is equal to 1, an overflow is detected

42
Adder-subtractor circuit
 Unsigned
 C bit detects a carry after addition or a borrow after subtraction
 Signed
 V bit detects an overflow
0: no overflow; n -bit result is correct
1: overflow; result of the operation contains n + 1 bits

43
Decimal Adder
 A decimal adder requires a minimum of 9 inputs and 5 outputs
 1 digit requires 4-bit
 Input: 2 digits + 1-bit carry
 Output: 1 digit + 1-bit carry

BCD Adder
 How do we implement a BCD adder? Let’s see the relationship between a binary
sum to a BCD sum (the table in the next page).
 The maximum value for a BCD sum will be 9 + 9 + 1, while 1 is a carry from the
previous bit.
 Remember: If the sum is 10, 11, 12, ..19. We need to add binary 6 (i.e. 0110) to
the binary sum in order to obtain a correct BCD code.

44
BCD Adder
 When the binary sum is equal to
or less than 1001b
 BCD Sum = Binary Sum
 C=0
 When the binary sum is greater
same than 1001b
 BCD Sum = Binary Sum +
0110b
 C=1
 If binary sum Z8Z4Z2Z1 > 9, we
should add 0110 to the sum, set C
= 1, and get the right BCD code. A
D=6 way to gain C is:

 Think how we get expression of


C (use “observation” to guess
the result).

45
BCD Adder
 The logic circuit that detects the
necessary correction can be
derived from the entries in the
table.
 It is obvious that a correction is
needed when the binary sum has
same an output carry K = 1.
 The other six combinations from
1010 through 1111 that need a
correction have a 1 in position Z8.
To distinguish them from binary
1000 and 1001, which also have a
1 in position Z8, we specify further
D=6 that either Z4 or Z2 must have a 1.
 The condition for a correction and
an output carry can be expressed
by the Boolean function

46
BCD Adder

C = 0  0000
C = 1  0110

47
Binary Multiplier

 2 bits x 2 bits

Multiplicand

Multiplier

Product

48
4 Bit × 3 Bit Multiplier

B3 B2 B1 B0

X A2 A1 A0

A0B3 A0B2 A0B1 A0B0


A1B3 A1B2 A1B1 A1B0
A2B3 A2B2 A2B1 A2B0

C6 C5 C4 C3 C2 C1 C0

49
4 Bit × 3 Bit Multiplier

For J multiplier bits (3) and K multiplicand bits (4), we


need (J × K) AND gates and (J – 1) K -bit adders to
produce a product of (J + K) bits.

50
Magnitude Comparator
 A magnitude comparator is a combinational circuit that compares two
numbers A and B and determines their relative magnitudes.

 The comparison of two numbers


outputs: A=B, A>B, A<B
 To test the equality of the 4-bit numbers the following circuit can be used
a0
b0
a b z
XNOR
0 0 1 a1
0 1 0 b1
1 0 0
a2
1 1 1 b2
XNOR  if A = B, zi = 1
a3
b3
51
Magnitude Comparator

Algorithm -> logic  A > B means: A3= 1 & B3= 0


• A = A3A2A1A0 ; B = B3B2B1B0 or (A3 = B3) & A2= 1 & B2= 0
or (A3 = B3, A2 = B2) & A1= 1 & B1= 0
A=B if A3=B3, A2=B2, A1=B1and A0=B0
or (A3 = B3, A2 = B2, A1 = B1) & A0= 1 & B0= 0
• equality: xi= AiBi+Ai'Bi', for i = 0, 1, 2, 3
• (A=B) = x3x2x1x0  A < B means: A3= 0 & B3= 1
or (A3 = B3) & A2= 0 & B2= 1
(A>B) = A3B3'+x3A2B2'+x3x2A1B1'+x3x2x1 A0B0'
or (A3 = B3, A2 = B2) & A1= 0 & B1= 1
(A<B) = A3'B3+x3A2'B2+x3x2A1'B1+x3x2x1 A0'B0
or (A3 = B3, A2 = B2, A1 = B1) & A0= 0 & B0= 1
Implementation
• xi = (AiBi'+Ai'Bi)'

52 52
Magnitude A3'B3
=A3'B3+A3B3'

Comparator A3B3'

XNOR
 Algorithm -> logic
A2'B2
• A = A3A2A1A0 ; B = B3B2B1B0 =A2'B2+A2B2'

 A=B if A3=B3, A2=B2, A1=B1and A0=B0 A2B2'

• equality: xi= AiBi+Ai'Bi', for i = 0, 1, 2, 3


• (A=B) = x3x2x1x0
A1'B1
 (A>B) = A3B3'+x3A2B2'+x3x2A1B1'+x3x2x1 A0B0' =A1'B1+A1B1'

 (A<B) = A3'B3+x3A2'B2+x3x2A1'B1+x3x2x1 A0'B0 A1B1'

 Implementation
• xi = (AiBi'+Ai'Bi)'
A0'B0
=A0'B0+A0B0'

A0B0'

53
Decoders

 A decoder is a combinational circuit that converts binary information from n input lines
to a maximum of 2n unique output lines
 May have fewer than 2n outputs
 A n-to-m-line decoder (m ≤ 2n):
 Generate the m minterns of n input variables
 For each possible input combination, there is only one output that is equal to 1
 The output whose value is equal to 1 represents the minterm equivalent of the binary
number presently available in the input lines

54
3-to-8-Line Decoder
 The 3 inputs are decoded into 8 outputs
 Each represent one of the minterms of the inputs variables

55
3-to-8-line
decoder

The three inputs are


decoded into eight
outputs, each representing
one of the minterms of the
three input variables.

56
2-to-4-Line Decoder
 A circuit that receives information from a single line and directs it to
one of 2n possible output lines
 A decoder with enable input can function as a demultiplexer
 Often referred to as a decoder/demultiplexer
Data input
Selection
• Only one output can be
equal to 0 at any given
time, all other outputs are
equal to 1.
• The output whose value is
0 equal to 0 represents the
minterm selected by
inputs A and B .

active-low enable

57
Construct Larger Decoders
Construct 4 × 16 decoder with two 3 × 8 decoders
 Decoders with enable inputs can be
connected together to form a larger
decoder
 The enable input is used as the most
significant bit of the selection signal
 w=0: the top decoder is enabled
 w=1: the bottom one is enabled
 In general, enable inputs are a
convenient feature for standard
components to expand their numbers of
inputs and outputs

58
Combinational Logic Implementation
 Most of combinational logics can be implemented by the decoder, e.g., a
full adder as shown below.
 Note that the decoder outputs represent all minterms.

59
BCD to Seven-segment display
A BCD–to–seven–segment decoder is a combinational circuit that converts a decimal
digit in BCD to an appropriate code for the selection of segments in a display indicator used
for displaying the decimal digit in a familiar form. The seven outputs of the decoder
(a,b,c,d,e,f and g) select the corresponding segments in the display, as shown in the
following figure (a). The numeric display chosen to represent the decimal digit is shown in
figure (b). Using a truth table and K–maps, design the BCD–to–seven–segment decoder
using a minimum number of gates. The six invalid combinations should result in a blank in a
display.

60
Using a truth table and K–
maps, design the BCD–to–
seven–segment decoder
using a minimum number of
gates. The six invalid
combinations should result in
a blank in a display.

61
62
63
BCD to Seven-segment display

64
Encoders
 An encoder is a digital circuit that performs the inverse operation of a
decoder.
 An encoder has 2n input lines and n output lines.
 The output lines, as an aggregate, generate the binary code corresponding
to the input value.

65
Priority Encoder

 The Boolean functions for the encoder in the last page have the limitation
that only one input can be “1”.
 If there are two or more “1” in the inputs, the result will be wrong (e.q. D1, D3=
1  ambiguous results!)
 Adding an input priority function can solve the ambiguity. If the inputs have
more than two “1”, the priority function only consider the most significant bit.
 Priority Encoder: An encoder circuit that includes the priority function.

66
Priority Encoder
 An encoder circuit that includes the priority function
 If two or more inputs are equal to 1 at the same time, the input having the highest
priority will take precedence
 In the following truth table:
D3 > D2 > D1 > D0
 The X’s in output columns represent don’t-care conditions
 The X’s in input columns are useful for representing a truth table in condensed
form

V = 0:
no valid inputs

67
Priority Encoder
The maps for simplifying outputs x and y

68
Priority Encoder

69
Multiplexer
 A multiplexer, often labeled “MUX”, is a circuit that selects from one of
many input lines and directs it to a single output line.
 It usually contains “data inputs”, “selection inputs” and one “output”.

output
data inputs

selection inputs

70
Multiplexer
 A multiplexer, often labeled “MUX”, is a circuit that selects from one of
many input lines and directs it to a single output line.
 Have 2n input lines and n selection lines
 Act like an electronic switch (also called a data selector)
 For the following 2-to-1-line multiplexer:
 S=0  Y = I0 ; S=1 Y = I1

71
4-to-1-line Multiplexer
 2n inputs require n selection bits.
 A multiplexer can be modified from a
decoder.
 The combinations of S0 and S1 control
each AND gates
 Part of the multiplexer resembles a
decoder
 To construct a multiplexer:
 Start with an n-to-2n decoder
 Add 2n input lines, one to each AND
gate
 The outputs of the AND gates are
applied to a single OR gate
Decoder!!

72
Quadruple 2-to-1-line Multiplexer
 Multiplexers can be combined
with common selection inputs to
provide multiple-bit selection
logic
 Quadruple 2-to-1-line multiplexer:
 Four 2-to-1-line multiplexers
 Each capable of selecting one
bit of two 4-bit inputs
 E: enable input
E=1: disable the circuit (all
outputs are 0)

73
Boolean Function Implementation
 A multiplexer is essentially a decoder with an external OR gate
 Can be used to implement Boolean functions without extra logic
 To implement a Boolean function of n variables:
 Use a multiplexer with n  1 selection inputs
 The first n – 1 variables are connected to the selection inputs
 The remaining variable is used for the data inputs
Example: F(x, y, z) = S(1,2,6,7)

74
Boolean Function Implementation
Example: F(x, y, z) = S(1,2,6,7) • The two variables x and y are applied to
the selection lines in that order; x is
connected to the S1 input and y to the S0
input.
• The values for the data input lines are
determined from the truth table of the
function.
• When xy = 00, output F is equal to z
because F = 0 when z = 0 and F = 1
when z = 1. This requires that variable z
be applied to data input 0.
• The operation of the multiplexer is such
that when xy = 00, data input 0 has a
path to the output, and that makes F
equal to z.
• In a similar fashion, we can determine
the required input to data lines 1, 2, and
3 from the value of F when xy = 01, 10,
and 11, respectively. 75
Boolean Function Implementation
• The general procedure for implementing any Boolean function of n
variables with a multiplexer with n - 1 selection inputs and 2n-1 data
inputs.
• To begin with, Boolean function is listed in a truth table.
• Then first n - 1 variables in the table are applied to the selection
inputs of the multiplexer.
• For each combination of the selection variables, we evaluate the
output as a function of the last variable.
• This function can be 0, 1, the variable, or the complement of the
variable.
• These values are then applied to the data inputs in the proper order.

76
Boolean Function Implementation
Implementing a 4-Input Function
Example: F(A, B, C, D) = S(1, 3, 4, 11, 12, 13, 14, 15)

77
Three-State Gates
 A circuit that exhibits three states
 logic 1, logic 0, and high-impedance (z)
 The high-impedance state acts like an open circuit (disconnected)
 The most commonly used three-state gate is the buffer gate
 C=0  disabled (high-impedance) ; C=1  enabled (pass)
 Can be used at the output of a function without altering the internal
implementation

78
Three-State Gates
 A large number of three-state gate outputs can be connected with wires to form a common
line (bus) without logic conflicts
 Very convenient for implementing some circuits (ex: multiplexer)
 Only one buffer can be in the active state at any given time
 One way to ensure that no more than one control input is active at any given time is to use
a decoder

79
The End

Reference:
1. Digital Design (with an introduction to the Verilog HDL) 6th Edition, M. Morris Mano,
Michael D. Ciletti

Note: The slides are supporting materials for the course “Digital Circuits” at IIITDM Kancheepuram.
Distribution without permission is prohibited.

80

You might also like