192
1 Chapter 2: Chapter 2: Combinational Logic Circuits Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

Embed Size (px)

Citation preview

Page 1: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

1

Chapter 2: Chapter 2: Combinational Logic CircuitsCombinational Logic Circuits

EKT 121 / 4DIGITAL

ELECTRONICS 1

Page 2: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

2

2.1 Combinational Logic Analysis

Basic Combinational Logic Circuits

Implementing Combinational Logic

The Universal Property of NAND and NOR gates

Page 3: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

3

The AND-OR Logic

Page 4: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

4

The AND-OR-Invert Logic

Page 5: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

5

The Exclusive-OR logic

How about Ex-NOR logic???

Page 6: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

6

X-Nor EquationX=ABAB= AB AB = AB AB = AB AB

= AB AB= AB AB =A AABABBB=ABAB

Page 7: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

7

Exclusive-OR Gate

A ⊕ B= A B A B

a) Gate Symbol, Boolean a) Gate Symbol, Boolean Equation Equation

& Truth Table & Truth Table

b) Timing Diagram b) Timing Diagram

Page 8: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

8

Ex-OR and Ex-NOR

Page 9: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

9

Implementing Combinational Logic

From Boolean Expression to Logic Circuit

From Truth Table to Logic Circuit

Page 10: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

10

The NAND and NOR gates as Universal Logic Elements

Both the NAND and NOR gates are universal gates because they can each represent the NOT, AND, OR and NOR functions.

Page 11: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

11

The Universal NAND gate

Page 12: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

12

The Universal NOR gate

Page 13: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

13

Equivalence Symbols

NAND

NORPlease sketch !!

Page 14: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

14

2.2 Functions of Combinational Logic Basic Adders

Parallel Binary Adder

Ripple Carry Adder

Comparators

Decoders

Encoders

Page 15: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

15

2.2 Functions of Combinational Logic Code Converters

Multiplexers (Data Selectors)

Demultiplexers

Parity Generators/ Checkers

Page 16: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

16

Decoders & Encoders

Page 17: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

17

Encoder

Encoder converts information such as decimal number or an alphabetical character into some binary coded form

Encoder is usually used for:•Data representation•Data security•Data compression

Page 18: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

18

EncoderExample: 8-to-3 Binary Encoder

Only one of the inputs can be 1.

Page 19: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

19

Design Exercise

Write the equations for Y2, Y1 and Y0.

Draw the logic circuit to implement this 8-to-3 encoder.

Page 20: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

20

The decimal-to-BCD Encoder

Page 21: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

21

DecoderA decoder is a circuit that creates an output based on the binary states of a given input

Selects 1 of several output lines, based on a coded input signal.

Do the opposite of encoder

Page 22: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

22

DecoderExample: 3 to 8 Binary Decoder

The inputs are treated as a binary number and the output selected is made active.

Page 23: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

23

A 4-line-to-16-line Decoder

Page 24: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

24

The BCD-to-decimal Decoder

Page 25: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

25

The BCD to 7-segment Decoder Accepts BCD

code on inputs and provide outputs to drive 7-segment display devices to produce a decimal readout.

Page 26: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

26

BCD to 7-Segment Decoder

A BCD to 7-segment decoder

has 4-bit BCD input and

the seven segment display

code as its output: In minimizing the circuits

for the segment outputs all

non-decimal input combinations

(1010, 1011, 1100,1101, 1110,

1111) are taken as don’t-cares

/Bl D C B A a b c d e f g 0 x x x x 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 0 0 1 0 0 1 0 1 1 0 1 1 0 1 1 0 0 1 1 1 1 1 1 0 0 1 1 0 1 0 0 0 1 1 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 0 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 0 1 1 1 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0

-- d

on’t

car

e in

pu

ts -

-

Page 27: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

27

Figure 4–47 Seven-segment display format showing arrangement of segments.

Thomas L. FloydDigital Fundamentals, 9e

Copyright ©2006 by Pearson Education, Inc.

Upper Saddle River, New Jersey 07458All rights reserved.

Page 28: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

28

Figure 4–48 Display of decimal digits with a 7-segment device.

Thomas L. FloydDigital Fundamentals, 9e

Copyright ©2006 by Pearson Education, Inc.

Upper Saddle River, New Jersey 07458All rights reserved.

Page 29: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

29

Figure 4–49 Arrangements of 7-segment LED displays.

Thomas L. FloydDigital Fundamentals, 9e

Copyright ©2006 by Pearson Education, Inc.

Upper Saddle River, New Jersey 07458All rights reserved.

Active-low Active-high

Page 30: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

30

Figure 4–50 Block diagram of 7-segment logic and display.

Thomas L. FloydDigital Fundamentals, 9e

Copyright ©2006 by Pearson Education, Inc.

Upper Saddle River, New Jersey 07458All rights reserved.

Page 31: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

31

Design Example

From the truth table, an SOP or POS can be written for each segment.

Derive an SOP for segment a.

Minimize the SOP using a K-map.

Draw the logic circuit to implement segment a of the 7-segment display.

Page 32: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

32

Figure 4–51 Karnaugh map minimization of the segment-a logic expression.

Thomas L. FloydDigital Fundamentals, 9e

Copyright ©2006 by Pearson Education, Inc.

Upper Saddle River, New Jersey 07458All rights reserved.

Page 33: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

33

Figure 4–52 The minimum logic implementation for segment a of the 7-segment display.

Thomas L. FloydDigital Fundamentals, 9e

Copyright ©2006 by Pearson Education, Inc.

Upper Saddle River, New Jersey 07458All rights reserved.

Page 34: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

34

BCD to 7-segment DecoderApplication Example:

Page 35: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

35

Lab 3

Use of 74S90 IC, a BCD counter – as inputs to the BCD to 7-segment decoder.

Part B Prepare the design before coming to lab! For unused input states, the output is either a ‘0’

or ‘X’. TT, K-map and circuit.

Page 36: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

36

Decoders & Encoders

- A Second Look -

Page 37: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

37

Convert numbers to be displayed

BCD to 7-segment display decoder

Hex to 7-segment display decoder

Page 38: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

38

7-Segment Display Configuration

Common Anode Requires logic 0 to

light up (ON) a segment.

Common Cathode Requires logic 1 to

light up (ON) a segment.

Page 39: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

39

3-5 DECODERS

DECODER

n m

m ≤ 2n

Converts binary information, from n coded inputs to a maximum of 2n outputs

Page 40: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

40

3-5 DECODERS

Functional Specs:

To generate the 2n (or less) minterms of input variables.

For each input, 7 outputs are equal to 0 and only 1 equals to 1. The output that is 1 represents the

minterm equivalent of the input number.

Page 41: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

41

Truth Table for 3-to-8-Line Decoder

Page 42: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

42

3-to-8-Line Decoder

Page 43: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

43

A 2-to-4-Line Decoder

Page 44: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

44

Decoder Expansion

When a certain decoder size is needed, but only smaller number of sizes is available.

Combine 2 or more decoders in a hierarchy, i.e. cascade the smaller decoders to form a larger decoder size.

Page 45: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

45

Example: A 3-to-8 Decoder Constructed with Two 2-to-4 Decoders

Page 46: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

46

… Its Operation The MSB input, A2, functions:

As enable, EN, of one decoder, and As its complement, N(EN) to the other decoder. When A2=0,

Top decoder enabled Generates minterms D0 to D3.

Lower decoder disabled Outputs equal to 0.

When A2=1, Top decoder disabled Outputs equal to 0. Lower decoder enabled Generates

minterms D4 to D7.

Page 47: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

47

… Enable Input

Very useful and convenient way to interconnect 2 or more functional blocks.

For the purpose of expanding digital functions into: Similar functions with more inputs

and outputs.

Page 48: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

48

Exercise

Construct a 6-to-64-line decoder, using:

Four 4-to-16-line decoders and one 2-to-4-line decoder.

Page 49: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

49

Combinational Circuit Implementation of Decoders

Binary Adder

Page 50: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

50

Implementing a Binary Adder Using a Decoder

S(X,Y,Z) = m (1, 2, 4, 7)

C(X,Y,Z) = m (3, 5, 6, 7)

3 inputs and 8 minterms

Use a 3-to-8 decoder.

Page 51: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

51

Implementing a Binary Adder Using a 3-to-8 Decoder

Page 52: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

52

3-6 ENCODERS

ENCODER

m n

m ≤ 2n

Page 53: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

53

3-6 ENCODERS

Inverse operation of decoder. The output lines generate the binary code

corresponding to the input value. Assume only 1 input has the value of 1 at

any given time. Example:

Octal-to-binary encoder.

Page 54: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

54

Truth Table for Octal-to-Binary Encoder

Page 55: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

55

Priority Encoder

Page 56: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

56

What about when 2 inputs are 1 at the same time?

Use “Priority Encoder” To ensure only one input is encoded.

e.g.

D3 = D6 = 1

Output = 110

(D6 has a higher priority than D3)

Page 57: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

57

Priority Encoder …

If 2 or more inputs are equal to 1 at the same time, the input having the highest priority is the one encoded.

Example: 4-input Priority Encoder Use condensed TT (5 rows to represent 16 rows). V (valid) =1 when 1 or more input is equal to 1.

Page 58: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

58

Condensed Truth Table of Priority Encoder

X @ output => don’t careX @ input => product term that is not minterm

Page 59: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

59

Maps for Priority Encoder

Page 60: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

60

Logic Diagram of a 4-Input Priority Encoder

Page 61: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

61

Functions of Combinational Logic

Adder Encoder Comparator DecoderMultiplexer DemultiplexerParity Generator Parity CheckerCode Converters

Page 62: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

62

ADDERS

Half Adder

Full Adder

Page 63: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

63

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) = (1,2)S = X’Y + XY’S = X Y

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

HalfAdder

X

Y

SC-OUT

Block diagram/ Symbol/ Black-box view

X

YSum S

C-out

Circuit

Page 64: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

64

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. Full Adder Truth Table

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

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

X00001111

Y00110011

S01101001

C-out 0 0 0 1 0 1 1 1

C-in 0 1 0 1 0 1 0 1

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

Inputs Outputs

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

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

Page 65: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

65

Full Adder

Y Y’Y

X X’X

C-in C-in’C-in

Full Adder

X Y

S

C-inC-out

Full Adder Circuit Using AND-OR:

Block diagram

XY

YC-in

C-outXC-in

X

X

Y

C-in

Y

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’Circuit

Page 66: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

66

Full Adder

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

Y

C-in

Full Adder Circuit Using XOR:

Page 67: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

67

HA`and `FA symbols

Page 68: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

68

Arrangement of 2 half-adders to form a full-adder

CASCADE

Page 69: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

69

Exercise: Determine the output values

Page 70: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

70

2-Bit Parallel Adder

Page 71: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

71

Determine the sum of this 3-bit parallel Adder

Page 72: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

72

4-bit Parallel Adder

Page 73: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

73

Bigger Adders

8-bit using two 4-bit Adders

16-bit using four4-bit Adders

Page 74: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

74

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.

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

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

Page 75: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

75

A 4-bit parallel ripple carry adder

Thomas L. FloydDigital Fundamentals, 9e

Copyright ©2006 by Pearson Education, Inc.

Upper Saddle River, New Jersey 07458All rights reserved.

Page 76: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

76

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

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

Page 77: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

77

4-bit Ripple Carry AdderAdds 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

Total Propagation delay = 2 n8

or 8 gate delays

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 Adder

X3X2X1X0

S3 S2 S1 S0

C-inC-outC4

Y3Y2Y1Y0

C0 =0

Inputs to be added

Sum Output

Cascade 4 full adders to get a 4-bit full adder

Page 78: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

78

Other types of Parallel Adders Carry Look-Ahead

Carry-Select Adder

Carry-Save Adder

Etc.

Page 79: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

79

1’s Complement and 2’s Complement Hardware

The 2’s complement of a binary number is formed by adding 1 to the 1’s complement.

2’s complement = (1’s complement) + 1

Page 80: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

80

How to use an adder as a Subtractor?

Page 81: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

81

Building a Subtractor using an Adder and 2’s Complement (for positive numbers)

A – B = A + (-B) = A + B + 1

To perform subtraction using an adder, we invert B, and use Cin =1.

2’s complement

Try drawing this diagram…

Page 82: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

82

Other types of Parallel Adders Carry Look-Ahead

Carry-Select Adder

Carry-Save Adder

Etc.

Page 83: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

83

ADDERS

– A Second Look -

Page 84: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

84

Adders and its Applications

Subtractor

Multipliers

Dividers

Page 85: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

85

ARITHMETIC CIRCUITS

Is a combinational circuit that performs arithmetic operations, e.g.

Addition Subtraction Multiplication Division

with numbers in binary form.

Page 86: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

86

Half Adder

Generates the sum of 2 binary digits.

HALFADDER

X

Y

Sum = X Y

Cy = X.Y

Page 87: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

87

Truth Table of Half Adder

Page 88: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

88

Logic Diagram of Half Adder

Page 89: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

89

Full Adder

Forms the arithmetic sum of 3 input bits.

FULL ADDER

X

Y

Sum = X Y Z

Cout = X.Y + Z (X Y)Cin

Page 90: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

90

Truth Table of Full Adder

Page 91: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

91

K-Maps for Full Adder

Page 92: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

92

Full Adder

A Full Adder can also be implemented using 2 HALF ADDERS and one OR gate.

Cascade two half adders

(Array method) Design “Smart”

Page 93: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

93

Full Adder (Array Method)

Design “Smart”

Page 94: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

94

1’s Complement and 2’s Complement Hardware

The 2’s complement of a binary number is formed by adding 1 to the 1’s complement.

2’s complement = (1’s complement) + 1

Page 95: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

95

How to use an adder as a Subtractor?

Page 96: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

96

Building a Subtractor using an Adder and 2’s Complement (for positive numbers)

A – B = A + (-B) = A + B + 1

To perform subtraction using an adder, we invert B, and use Cin =1.

2’s complement

Try drawing this diagram…

Page 97: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

97

Design Exercise

2-bits x 2-bits Multiplier

Page 98: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

98

Terms

2

X 3

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

6

Mutiplicand

Multiplier

Product

Page 99: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

99

Multiplication in binary form?1. Rewrite the multiplication in binary

form.

1. Sketch the black box view.

1. The multiplier multiplies two __?__ bits numbers.

Page 100: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

100

2-bits x 2-bits Multiplier Design

Two techniques:

Using the standard K-Map

Using Arrays (cascaded approach)

Page 101: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

101

Method A: Using the K-Map Technique Sketch the bLack box. Sketch the Truth Table for a 2-bit “multiplier” and 2-

bit “multiplicand”. Input (Multiplier) = A1 and A0 Input (Multiplicand) = B1 and B0 Output (4-bits) = S3, S2, S1 and S0 or S[3..0]

Using K-Maps, obtain the boolean expression for each output.

Sketch the schematic diagram.

Page 102: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

102

Method B: Using the Array (Cascaded) Technique

Create the 2x2 multiplier using Full ADDERS.

Design “Smart”

Page 103: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

103

… tHE cONcEpt

A1 A0B1 B0x

A1B0 A0B0A1B1 A0B1+

S0S1S2S3

CC

Page 104: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

104

A 2-Bit by 2-Bit Binary Multiplier

Page 105: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

105

AND computes A0 B0

Half adder computes sum. Will need FA for larger multiplier.

Page 106: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

106

The 4-bits x 4-bits Multiplier

Using Array 2x2

Page 107: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

107

Basic Idea of a Larger Multiplier (4-bits by 3-bits)

Page 108: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

108

Multiplier Product

The product of m-bit x n-bit numbers is an (m+n)-bit number.

=> The product of two 4-bit numbers is an 8-bit number.

Page 109: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

109

How about this one?

13

X 11

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

143

Mutiplicand

Multiplier

Product

Page 110: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

110

1

1

1

1

(143) Product1110001

1011

0000

1011

011

(11) multiplier101X

(13) multiplicand011

Partial products

Page 111: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

111

S0S1S2S3S4S5S6S7

A0B3A1B3A2B3A3B3

A0B2A1B2A2B2A3B2

A0B1A1B1A2B1A3B1

A0B0A1B0A2B0A3B0

B0B1B2B3

A0A1A2A3

Page 112: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

112

From the previous slide:

1. The multiplier multiplies two __?__ bits numbers.

1. Sketch the black box view.

Page 113: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

113

Design a 4-bits x 4-bits multiplier using the Array (cascaded) technique, by utilizing:

The 2-bits x 2-bits Multiplier and full adder designed earlier.

Hints : Look back at the concept of 2x2 multiplier. Take the same step.

Page 114: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

114

4x4 Combinational Multiplier

Note use of parallel carry-outs to form higher order sums

12 Adders, if full adders, this is 6 gates each = 72 gates

16 gates form the partial products

total = 88 gates!

A 0 B 0 A 1 B 0 A 0 B 1 A 0 B 2 A 1 B 1 A 2 B 0 A 0 B 3 A 1 B 2 A 2 B 1 A 3 B 0 A 1 B 3 A 2 B 2 A 3 B 1 A 2 B 3 A 3 B 2 A 3 B 3

HA

S 0 S 1

HA

F A

F A

S 3

F A

F A

S 4

HA

F A

S 2

F A

F A

S 5

F A

S 6

HA

S 7

Page 115: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

115

Array Multiplier

4 x 4 array of building blocks

1 building block

Page 116: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

116

4x4 Multiplier

(your design)

Tenth & UnitSegmentDecoder

7447BCD to

7Seg

7447BCD to

7Seg a - g

a - g

A0A1A2A3

B0B1B2B3

Pin Configuration to input(use flex switch 1-8)

Pin Configuration to output(use flex digit 1 & 2 )

Page 117: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

117

Functions of Combinational Logic

Adder Encoder Comparator DecoderMultiplexer DemultiplexerParity Generator Parity CheckerCode Converters

Page 118: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

118

Comparator

Equality Comparator

Inequality Comparator

Page 119: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

119

Equality Comparator

A B A=B

0 0 1

0 1 0

1 0 0

1 1 1

• To compare two binary strings (or binary words) to determine if they are exactly equal.

•Truth table for a comparator:

What is the Boolean expression for this truth table?

Can you draw the circuit for basic comparator?

Page 120: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

120

Equality Comparator

A B A=B

0 0 1

0 1 0

1 0 0

1 1 1

• Comparing two binary strings (or binary words) to determine if they are exactly equal.

•Truth table for a comparator:

A=B is same as output for Ex-NOR gate

1-bit comparator

Page 121: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

121

Basic Equality Comparator Operation

Page 122: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

122

1-bit Comparator with Inequality outputs To compare 2 binary numbers, each 1-bit

wide. The result of the comparison are single bit

outputs that indicate whether the numbers are equal to each other, or if one number is greater than or less than another. A=B ? A<B? A>B?

Page 123: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

123

Design Exercise

For the comparator explained in the previous slide ,

Derive its truth table. Minimize the output equations using K-maps. Draw the logic circuit.

Page 124: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

124

2-bit Comparator

Sketch the black box view/ symbol

Produce the truth table

Use K-maps

Sketch the circuit

Page 125: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

125

Design Exercise

Repeat the previous design exercise for a 4-bit comparator with inequality outputs.

Page 126: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

126

4-bit Comparator with Inequality Indication

Page 127: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

127

8- bit Comparator To design a comparator to evaluate two 4 bit numbers, we need 4

Ex-NORs and a 4-input AND gate 8 bit magnitude comparator (cascade two 4-bit comparators):

Page 128: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

128

Code Converters

Page 129: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

129

Code Converters A device that converts data in one type of

code and produces an output expressed in another type.

Example, BCD to binary, BCD to 7-segment display, Gray-to-binary code and binary-to-Gray code.

Still remember…………………………….? Binary code vs Gray Code.

To convert binary to Gray code or Gray code to binary, we use X-OR gates. How???

Page 130: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

130

Four-bit binary-to-Gray conversion logic

Thomas L. FloydDigital Fundamentals, 9e

Copyright ©2006 by Pearson Education, Inc.

Upper Saddle River, New Jersey 07458All rights reserved.

Page 131: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

131

Four-bit Gray-to-binary conversion logic

Thomas L. FloydDigital Fundamentals, 9e

Copyright ©2006 by Pearson Education, Inc.

Upper Saddle River, New Jersey 07458All rights reserved.

Page 132: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

132

Multiplexers& Demultiplexers

MUX & DEMUX

Page 133: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

133

Mutiplexer (MUX)

A circuit that selects binary information from one of many input lines, and directs the information to a single output line.

The selection of a particular input line is controlled by a set of input variables, called “selection inputs”.

Normally, there are 2n input lines and n selection inputs.

Output lines = ?

Page 134: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

134

2-to-1 MultiplexerData selectorSELECT input code determines which input is transmitted to output Z.

A 2 input multiplexer

Page 135: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

135

4-to-1 Multiplexer

A 4 input multiplexer

Write the output equation for Z

Verify the circuit above

Page 136: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

136

8-to-1 Multiplexer Larger multiplexers can be constructed from smaller ones.

An 8-to-1 multiplexer can be constructed by cascading smaller multiplexers as shown:

16-to-1 MUX: 74150

Page 137: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

137

“Smart” Design Exercise

Design a 16:1 MUX by cascading 4:1 MUXes

Page 138: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

138

MultiplexerApplication Example:

74157- consists of four separate 2-input multiplexers.

Page 139: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

139

Demutiplexer (DeMUX)

Opposite function of the multiplexer.

Information received from a single line is transmitted to one of 2n possible output lines.

The output line chosen is controlled by the n selection inputs.

Black box view?

Page 140: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

140

DemultiplexerData input is transmitted to only one of the outputs as determined by the select input code.

1-line-to-8-line multiplexer

Page 141: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

141

1-to-2 DeMUX

0D1

D00

Y1Y0Select

Black box view

Output equations

Logic circuit

Page 142: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

142

1-to-4 DeMUX

Page 143: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

143

Mux-Demux Application: Example

•This enables sharing a single communication line among a number of devices.•At any time, only one source and one destination can use the communication line.

Page 144: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

144

Multiplexer & Demultiplexer

- A Second Look -

Page 145: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

145

3-7 Multiplexers (Pemultipleks)

Selects binary information from one of many input lines and directs the information to a single output line.

The selection of an input line is controlled by a set of variables, i.e. the “selection” inputs.

Also called “Data Selector”.

Page 146: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

146

Mutiplexer (MUX)

Page 147: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

147

4-to-1-Line Multiplexer

Page 148: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

148

8-to-1-Line Multiplexer

Page 149: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

149

16-to-1-Line Multiplexer

Page 150: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

150

… Multiplexer

Also called “MUX”. Resembles a decoder circuit. 2n input lines. n selection inputs (SEL0, …, SELn). Can be constructed from:

Decoders. Transmission gates.

Page 151: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

151

… Multiplexer

May have an Enable, EN, input, to control its operation. EN = Inactive Outputs Disabled. EN = Active Normal Operation.

EN is useful when using 2 or more MUXes to obtain a bigger MUX (i.e. more inputs). Combine MUXes in parallel with the same SEL

and EN lines.

Page 152: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

152

Quadruple 2-to-1-Line Multiplexer…

Page 153: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

153

…Quadruple 2-to-1-Line Multiplexer Has ____ number of MUXes. YO can be selected from either A0 or B0.

Y1- from either A1 or B1, etc.

EN=1, S=0, all A inputs are passsed to the outputs. S=1, all B inputs are passed to the outputs.

EN=0, all outputs are 0.

Page 154: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

154

Implementing a Boolean Function with a Multiplexer … A multiplexer is basically a decoder that

includes the OR gate within the block. To implement a Boolean function of n

variables with a mux having n selection inputs and 2n data inputs, one for each minterm. The minterms are generated in a mux by the

circuit associated with the selection inputs. Individual minterms can be selected by the data

inputs.

Page 155: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

155

… Implementing a Boolean Function with a Multiplexer

A more efficient way To implement a Boolean function of n

variables with a mux having only n-1 selection inputs and 2n-1 data inputs.

Example 1:

F (X,Y,Z) = m (1, 2, 6, 7)

Page 156: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

156

Example 1

Page 157: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

157

… Implementing a Boolean Function with a Multiplexer

General procedure:

1. Produce Truth Table for Boolean function.

2. The first n-1 variables are applied to the selection inputs of the mux.

3. The remaining single variable of the function is used for the data input.

Page 158: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

158

… Implementing a Boolean Function with a Multiplexer

1. For each combination of the selection variables, we evaluate the output as a function of the last variable, i.e. a 0, 1, the variable or its complement.

2. These values are then applied to the data inputs in the proper order.

Page 159: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

159

Example 2: Implementing a 4-Input Function with a Multiplexer

F (A, B, C, D) = m (1, 3, 4, 11, 12, 13, 14, 15)

Implement the function with a mux having 3-selection inputs.

Page 160: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

160

… Example 2

Page 161: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

161

Demultiplexer Performs the inverse function of a

multiplexer. Receives information from a single line and

transmits it to one of possible 2n possible output lines.

The selection is is controlled by the bit combination of n selection lines.

A demultiplexer is identical to a 2-to-4-line decoder with enable input. A decoder with enable input =

A Decoder/Demultiplexer.

Page 162: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

162

1-to-4-Line Demultiplexer

Page 163: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

163

Design Preparation for Lab 4

Extra Exercise

A 16:1 MUX using cascaded 4:1 MUXes

1. 4:1 MUX

2. 1:5 DeMUX

Truth Table K-maps & minimized

equations Circuit diagram

Page 164: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

164

Functions of Combinational Logic

Adder Encoder Comparator DecoderMultiplexer DemultiplexerParity Generator Parity CheckerCode Converters

Page 165: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

165

Error Detection & Correction Codes

PARITY METHOD:

1. Even Parity

2. Odd Parity

Page 166: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

166

Parity Bit

Is an extra bit included with the data bits.

To detect errors in data communication & processing.

Page 167: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

167

Error-Detection Codes

Redundancy (e.g. extra information), in the form of extra bits, can be incorporated into binary code words to detect and correct errors.

A simple form of redundancy is parity, an extra bit appended onto the code word to make the number of 1’s odd or even. Parity can detect all single-bit errors and some multiple-bit errors.

A code word has even parity if the number of 1’s in the code word is even.

A code word has odd parity if the number of 1’s in the code word is odd.

Page 168: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

168

4-Bit Parity Code Example Fill in the even and odd parity bits:

The codeword "1111" has even parity and the codeword "1110" has odd parity. Both can be used to represent 3-bit data.

Even Parity Odd Parity Message - Parity Message - Parity

000 - 000 - 001 - 001 - 010 - 010 - 011 - 011 - 100 - 100 - 101 - 101 - 110 - 110 - 111 - 111 -

Page 169: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

169

Parity Generator & Parity Checker

Odd Parity

Even Parity

Page 170: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

170

Error-Detection

A parity bit is a scheme for detecting errors during transmission of binary info.

A parity bit is an extra bit included with the binary message to make the number of 1’s either odd or even.

The message, including the parity bit, is transmitted and then checked at the receiving end for errors.

An error is detected if the checked parity does not correspond to the one transmitted.

Page 171: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

171

Error-Detection

The circuit that generates the parity bit in the transmitter is a parity generator.

The circuit that checks the parity bit in the receiver is a parity checker.

Page 172: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

172

Error-DetectionParity generator truth table*For odd parity, the bit P is generated so as to make the number

of 1’s odd (including P)

X Y Z P0 0 0 10 0 1 00 1 0 00 1 1 11 0 0 01 0 1 11 1 0 11 1 1 0

P

X

Y

Z

Odd Parity Generator

Page 173: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

173

* The three-bit message (X, Y, Z) and parity bit (P) are transmitted to their destination, where they are applied to a parity checker circuit. An error occurs during transmission if the parity of the four bits is even, since the binary info transmitted was originally odd. The output C of the parity checker should be a 1 when an error occurs, i.e. when the number of 1’s in the four inputs is even.

X Y Z P C 0 0 0 0 10 0 0 1 00 0 1 0 00 0 1 1 10 1 0 0 00 1 0 1 10 1 1 0 10 1 1 1 01 0 0 0 01 0 0 1 11 0 1 0 11 0 1 1 01 1 0 0 11 1 0 1 01 1 1 0 0 1 1 1 1 1

Odd Parity Checker

Page 174: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

174

• Parity is used in digital circuits to check for errors in transmission.

• In Four bit transmission a parity bit is added to make the fifth bit.

• In a eight bit transmission a parity bit is added to made a ninth bit.

• And so on.

Page 175: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

175

ODD Parity

• In ODD parity when we add the bits together disregarding weight we get or want to get an odd number.

0000 is a four bit message add a parity bit to make it odd

10000 Odd parity is satisfied

00011001 is an eight bit message add a parity bit to make it odd

000011001 Odd parity is satisfied

Parity bit

Page 176: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

176

EVEN parity

• In EVEN parity when we add the bits together disregarding weight we get or want to get an even number.

0000 is a four bit message add a parity bit to make it even

00000 Even parity is satisfied

00011001 is an eight bit message add a parity bit to make it even

100011001 Even parity is satisfied

Parity bit

Page 177: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

177

How to generate a parity bit

Use exclusive ORs and Exclusive NORs

Page 178: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

178

How to make a parity checker

Page 179: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

179

Odd or even parity~ 0 out of a parity checker means the parity checks and all is ok

~ 1 out of a parity checker means there is an error

Page 180: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

180

Parity Generator/Checker

- A Second Look -

Page 181: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

181

Tip to generate/check “parity”

“The sum (disregarding carries) of an even number of 1’s is always 0, and the sum of an odd number of 1’s is always 1.”

To determine if a given code has even or odd parity, all the bits in the code must be summed. Summation can be done using Ex-OR gate

Page 182: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

182

Parity Checker Circuit

When the no. of inputs is even Output, X, is 0

When the no. of inputs is odd Output, X, is 1

Page 183: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

183

The 9-bit parity generator/checker.

Input is 8-bits of data and 1 parity bit

When there is an even no. of 1’s at the inputs, the Σ Even is high while the Σ Odd is low.

Page 184: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

184

Parity Checker Function

When used as an EVEN Parity Checker,

If a parity error occurs, the Σ Even is low while the Σ Odd is high.

When used as an ODD Parity Checker,

If a parity error occurs, the Σ Odd is low while the Σ Even is high.

Page 185: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

185

Parity Generator Function

When used as an EVEN Parity Generator,

The parity bit is taken at the Σ Odd output. It is 0 if there is an even no. of 1’s, and is 1 if there

is an odd no.

When used as an ODD Parity Generator,

The parity bit is taken at the Σ Even output. It is 0 if there is an odd no. of 1’s, and is 1 if there

is an even no.

Page 186: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

186

Design Exercise

Derive the gate-level schematic circuit for the 9-bit Parity Generator/Checker explained above.

Page 187: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

187

Extra Design Exercise - Decoder

1. The 4-line-to-16-line Decoder (Active low outputs)

1. The BCD to Decimal Decoder

1. The BCD to 7-segment Decoder

Page 188: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

188

Extra Design Exercise - Encoder1. 16-line-to-4-line Encoder using the 8-line-to-

3-line encoder in cascade

1. The Decimal to BCD Encoder

1. The Keypad Encoder, as in the next slide

Page 189: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

189

Keypad Encoder The keypad consists

of the keys 0 to 10. When one of the keys

is pressed, the decimal digit is encoded to the corresponding BCD code.

When a key is depressed, the line is connected to ground, i.e. low input.

The “0” key is not connected as the BCD output is 0 when none of the other keys is depressed.

Page 190: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

190

Design Exercise

Use truth table and K-map to design:

1. A 2-to-1 MUX

1. A 1-to-2 DeMUX

Page 191: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

191

Extra Design Exercise – MUX and DeMUXUsing the circuits from the previous slide,

design by using the cascade/array/”smart design” technique:

1. A 4:1 MUX using 2:1 MUXes

1. A 8:1 MUX using 4:1 MUXes

1. A 16:1 MUX using 8:1 MUXes

Page 192: 1 Chapter 2: Combinational Logic Circuits EKT 121 / 4 DIGITAL ELECTRONICS 1

192

1. A 1:4 DeMUX using 1:2 DeMUX

1. A 1:8 DeMUX using 1:4 DeMUX

1. A 1:16 DeMUX using 1:8 DeMUX