Digital Electronics EEE 357 Lecture 07

35
Course Conducted by – Shuvodip Das, Lecturer, Department of ETE, Prime University, Bangladesh. Combinational Logic Circuit (CLC) Lecture: 07

description

Combination Logic Circuit (CLC)

Transcript of Digital Electronics EEE 357 Lecture 07

Page 1: Digital Electronics EEE 357 Lecture 07

Course Conducted by – Shuvodip Das,

Lecturer, Department of ETE,Prime University, Bangladesh.

Combinational Logic Circuit (CLC)

Lecture: 07

Page 2: Digital Electronics EEE 357 Lecture 07

Combinational Logic Circuit (CLC)Computer components are made from both combinational and

sequential logic circuitsWe will apply the knowledge of Boolean Algebra to realize these

circuitsFirst we will look at Combinational Logic CircuitUnlike Sequential Logic Circuits whose outputs are

dependant on both their present inputs and their previous output state giving them some form of Memory, the outputs of Combinational Logic Circuits are only determined by the logical function of their current input state, logic "0" or logic "1", at any given instant in time as they have no feedback, and any changes to the signals being applied to their inputs will immediately have an effect at the output. In other words, in a Combinational Logic Circuit, the output is dependant at all times on the combination of its inputs and if one of its inputs condition changes state so does the output as combinational circuits have "no memory", "timing" or "feedback loops".

Page 3: Digital Electronics EEE 357 Lecture 07

Always gives the same output for a given set of inputs

Do not store any information (memoryless)A set of m Boolean inputs,A set of n Boolean outputs, andn switching functions, each mapping

the 2m input combinations to an output such that the current output depends only on the current input values.

combinational circuits have "no memory", "timing" or "feedback loops".

Combinational Logic Circuit (CLC)

Page 4: Digital Electronics EEE 357 Lecture 07

Combinational Logic Circuit (CLC)Combinational Logic

Combination Logic Circuits are made up from basic logic NAND, NOR or NOT gates that are "combined" or connected together to produce more complicated switching circuits. These logic gates are the building blocks of combinational logic circuits.

Page 5: Digital Electronics EEE 357 Lecture 07

Applications or Examples of CLC:Multiplexer and DemultiplexerAdder and SubtractorBCD Arithmetic CircuitArithmetic Logic Unit (ALU)Digital Comparator Parity Generator/CheckersCode ConvertersPriority Encoders Decoder/Drivers for Display devices

Combinational Logic Circuit (CLC)

Page 6: Digital Electronics EEE 357 Lecture 07

Classification of Combinational Logic

Page 7: Digital Electronics EEE 357 Lecture 07

The Analysis, Design and Optimization of Combinational Logic Circuit

Steps of Implementing Combinational Logic Circuit:

Working Principle of the Circuit: Problem Description

Truth Table

Boolean Expression

Karnaugh Map

Boolean Algebra or postulate

Simplified Boolean Expression

Logic Diagram

Page 8: Digital Electronics EEE 357 Lecture 07

The Analysis, Design and Optimization of Combinational Logic Circuit

Problem 01: There are two inputs and a single output. If both inputs are same, output should be zero. Construct this circuit.

Solution: A B

X

A B X

0 0 0

0 1 1

1 0 1

1 1 0

BA

BA

BA

BA

BABA

Logic Circuit

Truth Table

Page 9: Digital Electronics EEE 357 Lecture 07

The Analysis, Design and Optimization of Combinational Logic Circuit

1st Step: According to the problem description, we have drawn a truth table.

2nd Step: From the truth table, we have expressed the boolean expression as –

3rd Step: Given boolean expression is already in simplified form. So, no further simplification will be required.

4th Step: From the simplified boolean expression, we have drawn the logic circuit and verified its operation.

BABAX

Page 10: Digital Electronics EEE 357 Lecture 07

The Analysis, Design and Optimization of Combinational Logic Circuit

Problem 02: There are three inputs and one output. If two or more inputs are high then output should be high. Construct the circuit.

Solution: A B X C

A B C X

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 1

1 1 1 1

BCA

CBA

CAB

ABC

ABCCABCBABCAX

Page 11: Digital Electronics EEE 357 Lecture 07

The Analysis, Design and Optimization of Combinational Logic Circuit

AB

C

X=AB+BC+CA

Simplification of Boolean expression:

CABCAB

ABCAB

BBABCAB

BABCAB

CBABCAB

CBAACB

CBACCACB

CBACACB

CBACABBC

CABCBAAABC

ABCCABCBABCAX

)(

))((

)(

)(

))((

)(

)(

Page 12: Digital Electronics EEE 357 Lecture 07

Combinational Arithmetic CircuitsAddition:

Half Adder (HA).Full Adder (FA).Carry Ripple Adders.Carry Look-Ahead Adders.

Subtraction:Half Subtractor.Full Subtractor.Borrow Ripple Subtractors.Subtraction using adders.

Multiplication:Combinational Array Multipliers.

Page 13: Digital Electronics EEE 357 Lecture 07

Half Adder

Adding two single-bit binary values, X, Y produces a sum S bit and a carry out C-out bit.

This operation is called half addition and the circuit to realize it is called a half adder.

X0011

Y0101

S0110

C-out 0 0 0 1

Half Adder Truth Table

Inputs

Outputs

S(X,Y) = S (1,2)S = X’Y + XY’S = X Å Y

C-out(x, y, C-in) = S (3)C-out = XY

X

YSum S

C-out HalfAdder

X

Y

SC-OUT

Page 14: Digital Electronics EEE 357 Lecture 07

Full Adder

Adding two single-bit binary values, X, Y with a carry input bit C-in produces a sum bit S and a carry out C-out bit.

X00001111

Y00110011

S01101001

C-out 0 0 0 1 0 1 1 1

C-in 0 1 0 1 0 1 0 1

Full Adder Truth Table

S(X,Y, C-in) = S (1,2,4,7)C-out(x, y, C-in) = S (3,5,6,7)

Inputs Outputs

Sum S

C-in

X

0 1

00 01 11 10

Y

C-in

XY

0

1

2

3

6

7

4

5

1

1 1

1

C-in

X

0 1

00 01 11 10

Y

C-in

XY

0

1

2

3

6

7

4

5

1

11 1

Carry C-out

S = X’Y’(C-in) + XY’(C-in)’ + XY’(C-in)’ + XY(C-in)S = X Å Y Å (C-in)

C-out = XY + X(C-in) + Y(C-in)

Page 15: Digital Electronics EEE 357 Lecture 07

Full Adder Circuit Using AND-OR

XY

YC-in

C-outXC-in

X

X

Y

C-in

Y

C-in

Y Y’Y

X X’X

C-in C-in’C-in

X’Y’C-in

XY’C-in’

Sum SX’YC-in’

XYC-in

X’

X’

X

X

Y’

Y

Y

C-in

Y

C-in’

C-in’

C-in’

Full Adder

X Y

S

C-inC-out

Page 16: Digital Electronics EEE 357 Lecture 07

Full Adder Circuit Using XOR

Full Adder

X Y

S

C-inC-out XY

YC-in

C-outXC-in

X

X

Y

C-in

Y

C-in

Sum S

X

YC-in

Page 17: Digital Electronics EEE 357 Lecture 07

n-bit Carry Ripple Adders An n-bit adder used to add two n-bit binary numbers can built by

connecting in series n full adders.Each full adder represents a bit position j (from 0 to n-1).Each carry out C-out from a full adder at position j is connected

to the carry in C-in of the full adder at the higher position j+1. The output of a full adder at position j is given by: Sj = Xj Å Yj Å Cj

Cj+1 = Xj . Yj + Xj . Cj + Y . Cj

In the expression of the sum Cj must be generated by the full adder at the lower position j-1.

The propagation delay in each full adder to produce the carry is equal to two gate delays = 2 D

Since the generation of the sum requires the propagation of the carry from the lowest position to the highest position , the total propagation delay of the adder is approximately:

Total Propagation delay = 2 n D

Page 18: Digital Electronics EEE 357 Lecture 07

Full Adder

X1 Y1

S1

C-inC-out Full Adder

X0 Y0

S0

C-inC-out C0 =0 Full Adder

X2 Y2

S2

C-inC-out Full Adder

X3 Y3

S3

C-inC-outC1C2C3C4

Data inputs to be added

Sum output

4-bit Carry Ripple Adder

Adds two 4-bit numbers: X = X3 X2 X1 X0 Y = Y3 Y2 Y1 Y0 producing the sum S = S3 S2 S1 S0 , C-out = C4 from the most significant position j=3

4-bit Adder

X3X2X1X0

S3 S2 S1 S0

C-inC-outC4

Y3Y2Y1Y0

C0 =0

Inputs to be added

Sum Output

Total Propagation delay = 2 n = D 8 D

or 8 gate delays

Page 19: Digital Electronics EEE 357 Lecture 07

Larger Adders

Example: 16-bit adder using 4, 4-bit adders Adds two 16-bit inputs X (bits X0 to X15), Y (bits Y0 to

Y15) producing a 16-bit Sum S (bits S0 to S15) and a

carry out C16 from most significant position.

4-bit Adder

C-inC-out 4-bit Adder

C-inC-out C0 =0 4-bit Adder

C-inC-out 4-bit Adder

C-inC-outC4C8C12C16

Data inputs to be added X (X0 to X15) , Y (Y0-Y15)

Sum output S (S0 to S15)

Y3Y2Y1Y0X3X2X1X0Y3Y2Y1Y0X3X2X1X0Y3Y2Y1Y0X3X2X1X0Y3Y2Y1Y0X3X2X1X0

S3 S2 S1 S0S3 S2 S1 S0S3 S2 S1 S0S3 S2 S1 S0

Propagation delay for 16-bit adder = 4 x propagation delay of 4-bit adder = 4 x 2 n = 4 D x 8 = 32 D D or 32 gate delays

Page 20: Digital Electronics EEE 357 Lecture 07

Carry Look-Ahead Adders The disadvantage of the ripple carry adder is that the propagation delay of adder (2 nD )

increases as the size of the adder, n is increased due to the carry ripple through all the full adders.

Carry look-ahead adders use a different method to create the needed carry bits for each full adder with a lower constant delay equal to three gate delays.

The carry out C-out from the full adder at position i or Cj+1 is given by:

C-out = C i+1 = Xi . Yi + (Xi + Yi) . Ci

By defining:

Gi = Xi . Yi as the carry generate function for position i (one gate delay) (If Gi =1 C i+1 will be generated regardless of the value Ci)

Pi = Xi + Yi as the carry propagate function for position i (one gate delay) (If Pi = 1 Ci will be propagated to C i+1)

By using the carry generate function Gi and carry propagate function Pi , then C i+1 can be written as:

C-out = C i+1 = Gi + Pi . Ci

To eliminate carry ripple the term Ci is recursively expanded and by multiplying out, we obtain a 2-level AND-OR expression for each C i+1

Page 21: Digital Electronics EEE 357 Lecture 07

For a 4-bit carry look-ahead adder the expanded expressions for all carry bits are given by:C1 = G0 + P0.C0

C2 = G1 + P1.C1 = G1 + P1.G0 + P1.P0.C0

C3 = G2 + P2.G1 + P2.P1.G0 + P2.P1.P0.C0

C4 = G3 + P3.G2 + P3.P2.G1 + P3 . P2.P1.G0 + P3.P2.P1.P0.C0

where Gi = Xi . Yi Pi = Xi + Yi

The additional circuits needed to realize the expressions are usually referred to as the carry look-ahead logic.

Using carry-ahead logic all carry bits are available after three gate delays regardless of the size of the adder.

Carry Look-Ahead Adders

Page 22: Digital Electronics EEE 357 Lecture 07

Ripple-carry adder, illustrating the delay of the carry bit.

Page 23: Digital Electronics EEE 357 Lecture 07

4-bit CLA

The disadvantage of the carry-lookahead adder is that the carry logic is getting quite complicated for more than 4 bits. For that reason, carry-look-ahead adders are usually implemented as 4-bit modules and are used in a hierarchical structure to realize adders that have multiples of 4 bits. Figure 6 shows the block diagram for a 16-bit CLA adder. The circuit makes use of the same CLA Logic block as the one used in the 4-bit adder.

Page 24: Digital Electronics EEE 357 Lecture 07

16-bit CLA Adder

Page 25: Digital Electronics EEE 357 Lecture 07

Carry Look-Ahead Circuit

Ci = Gi-1 + Pi-1. Gi-2 + …. + Pi-1.P i-2. …P1 . G0 + P i-1.P i-2.

…P0 . C0

Page 26: Digital Electronics EEE 357 Lecture 07

Binary Arithmetic OperationsSubtraction

Two binary numbers are subtracted by subtracting each pair of bits together with borrowing, where needed.

Subtraction Example:

0 0 1 1 1 1 1 0 0 Borrow

X 229 1 1 1 0 0 1 0 1

Y - 46 - 0 0 1 0 1 1 1 0

183 1 0 1 1 0 1 1 1

Page 27: Digital Electronics EEE 357 Lecture 07

Half Subtractor

Subtracting a single-bit binary value Y from anther X (I.e. X -Y ) produces a difference bit D and a borrow out bit B-out.

This operation is called half subtraction and the circuit to realize it is called a half subtractor.

X0011

Y0101

D0110

B-out 0 1 0 0

Half Subtractor Truth Table

Inputs Outputs

D(X,Y) = S (1,2)D = X’Y + XY’D = X Å Y

B-out(x, y, C-in) = S (1)B-out = X’Y

HalfSubtractor

X

Y

DB-OUT

X

Y

Difference D

B-out

Page 28: Digital Electronics EEE 357 Lecture 07

Full Subtractor Subtracting two single-bit binary values,

Y, B-in from a single-bit value X produces a difference bit D and a borrow out B-out bit. This is called full subtraction.

X00001111

Y00110011

D01101001

B-out 0 1 1 1 0 0 0 1

B-in 0 1 0 1 0 1 0 1

Full Subtractor Truth Table

S(X,Y, C-in) = S (1,2,4,7)C-out(x, y, C-in) = S (1,2,3,7)

Inputs Outputs

Difference D

B-in

X

0 1

00 01 11 10

Y

B-in

XY

0

1

2

3

6

7

4

5

1

1 1

1

B-in

X

0 1

00 01 11 10

Y

B-in

XY

0

1

2

3

6

7

4

5

1

11 1

Borrow B-out

D = X’Y’(B-in) + XY’(B-in)’ + XY’(B-in)’ + XY(B-in)S = X Å Y Å (C-in)

B-out = X’Y + X’(B-in) + Y(B-in)

Page 29: Digital Electronics EEE 357 Lecture 07

Full Subtractor Circuit Using AND-OR

X’Y

YB-in

B-outX’B-in

X’

X’

Y

B-in

Y

B-in

Y Y’Y

X X’X

B-in B-in’B-in

X’Y’B-in

XY’B-in’

Difference DX’YB-in’

XYB-in

X’

X’

X

X

Y’

Y

Y

B-in

Y

B-in’

B-in’

B-in’

Full Subtractor

X Y

D

B-inB-out

Page 30: Digital Electronics EEE 357 Lecture 07

Full Subtractor Circuit Using XOR

Difference D

X

YB-in

X’Y

YB-in

B-outX’B-in

X’

X’

Y

B-in

Y

B-in

Full Subtractor

X Y

D

B-inB-out

Page 31: Digital Electronics EEE 357 Lecture 07

An n-bit subtracor used to subtract an n-bit number Y from another

n-bit number X (i.e X-Y) can be built in one of two ways:

By using n full subtractors and connecting them in series, creating a borrow ripple subtractor:Each borrow out B-out from a full subtractor at position j is

connected to the borrow in B-in of the full subtracor at the higher position j+1.

By using an n-bit adder and n inverters:Find two’s complement of Y by:

Inverting all the bits of Y using the n inverters.Adding 1 by setting the carry in of the least

significant position to 1The original subtraction (X - Y) now becomes

an addition of X to two’s complement of Y using the n-bit adder.

n-bit Subtractors

Page 32: Digital Electronics EEE 357 Lecture 07

4-bit Borrow Ripple Subtractor

Subtracts two 4-bit numbers: Y = Y3 Y2 Y1 Y0 from X = X3 X2 X1 X0 Y = Y3 Y2 Y1 Y0 producing the difference D = D3 D2 D1 D0 , B-out = B4 from the most significant position j=3

4-bitSubtractor

X3X2X1X0

D3 D2 D1 D0

B-inB-outB4

Y3Y2Y1Y0

B0 =0

Inputs

Difference Output D

Full Subtractor

X1 Y1

D1

B-inB-out

X0 Y0

D0

B-inB-out B0 =0

X2 Y2

D2

B-inB-out

X3 Y3

D3

B-inB-outB1B2B3B4

Data inputs to be subtracted

Difference output D

Full Subtractor

Full Subtractor

Full Subtractor

Page 33: Digital Electronics EEE 357 Lecture 07

4-bit Subtractor Using 4-bit Adder

4-bit Adder

X3 X2 X1 X0

D3 D2 D1 D0

C-inC-outC4

Y3 Y2 Y1 Y0

C0 = 1

Inputs to be subtracted

Difference Output

S3 S2 S1 S0

Page 34: Digital Electronics EEE 357 Lecture 07

Binary Multiplication

Multiplication is achieved by adding a list of shifted multiplicands according to the digits of the multiplier.

Ex. (unsigned)

11 1 0 1 1 multiplicand (4 bits)

X 13 X 1 1 0 1 multiplier (4 bits)

-------- -------------------

33 1 0 1 1

11 0 0 0 0

______ 1 0 1 1

143 1 0 1 1

---------------------

1 0 0 0 1 1 1 1 Product (8 bits)

An n-bit X n-bit multiplier can be realized in combinational circuitry by using an array of n-1 n-bit adders where is adder is shifted by one position.

For each adder one input is the multiplied by 0 or 1 (using AND gates) depending on the multiplier bit, the other input is n partial product bits.

X3 X2 X1 X0 x Y3 Y2 Y1 Y0 __________________________ X3.Y0 X2.Y0 X1.Y0 X0.Y0 X3.Y1 X2.Y1 X1.Y1 X0.Y1 X3.Y2 X2.Y2 X1.Y2 X0.Y2 X3.Y3 X2.Y3 X1.Y3 X0.Y3_______________________________________________________________________________________________________________________________________________

P7 P6 P5 P4 P3 P2 P1 P0

Page 35: Digital Electronics EEE 357 Lecture 07

4x4 Array Multiplier