digital design: principles and practices

96
Digital Design: Principles and Practices Chapter 6 Combinational Logic Design Practices

Upload: hanae-robles

Post on 04-Jan-2016

40 views

Category:

Documents


0 download

DESCRIPTION

Digital Design: Principles and Practices. Chapter 6 Combinational Logic Design Practices. Introduction. If you are contemplating a career in digital design, it is recommended that you study the examples at least for Verilog or VHDL. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Digital Design: Principles and Practices

Digital Design:Principles and Practices

Chapter 6Combinational Logic Design Practices

Page 2: Digital Design: Principles and Practices

Introduction

• If you are contemplating a career in digital design, it is recommended that you study the examples at least for Verilog or VHDL.

• A practical combinational circuit may have dozens of inputs and outputs and could require millions of terms to describe as an SOP expression, and billions of rows to describe in a truth table.

• A complex circuit or system is conceived as a collection of smaller subsystems, each of which has a much simpler description.

2

Page 3: Digital Design: Principles and Practices

Introduction (cont’d)

• Basic combinational building blocks discussed in this chapter: Decoders Encoders Three-State Devices Multiplexers (MUX) XORs Comparators Adders & Subtractors Multipliers

3

Page 4: Digital Design: Principles and Practices

6.4 Decoders(including 6.4.1 – 6.4.4)

Page 5: Digital Design: Principles and Practices

Decoder

• A decoder is a multiple-input, multiple-output logic circuit that converts coded inputs into coded outputs, where the input and output codes are different.

• The input code generally has fewer bits than the output code, and there is a one-to-one mapping from input code words into output code words.

• In a one-to-one mapping, each input code word produces a different output code word.

• The most common decoder circuit is an n-to-2n decoder or binary decoder.

5

Page 6: Digital Design: Principles and Practices

A 2-to-4 (Binary) Decoder

6

Table 6-4

Figure 6-32

Page 7: Digital Design: Principles and Practices

A 2-to-4 (Binary) Decoder – Verilog Structural-style Verilog Module

7

Table V6-20 Structural-style Verilog module for the decoder in Figure 6-32.

Page 8: Digital Design: Principles and Practices

Decoder Circuit Structure

8

Page 9: Digital Design: Principles and Practices

A 3-to-8 Binary Decoder for Gray Code

9

Page 10: Digital Design: Principles and Practices

A Mechanical Encoding DiskUsing a 3-bit Gray Code

10

Page 11: Digital Design: Principles and Practices

A 3-to-8 Binary Decoder for Gray Code

11

Page 12: Digital Design: Principles and Practices

Decoder• Truth table for a 4-bit (4-to-16) Decoder with Active-LOW outputs

LogicLogicDiagramDiagram

Page 13: Digital Design: Principles and Practices

Decoder

• 4-bit decoder

Binary inputs

Active-low outputs

TruthTruthTableTable

13

Page 14: Digital Design: Principles and Practices

BCD-to-Decimal Decoder

14

Page 15: Digital Design: Principles and Practices

LogicLogicDiagramDiagram

BCD-to-7-Segment Decoder

15

Page 16: Digital Design: Principles and Practices

TruthTruthTableTable

BCD-to-7-Segment Decoder

16

Page 17: Digital Design: Principles and Practices

7-Segment Display

LED (Light –Emitting Diode)17

Page 18: Digital Design: Principles and Practices

74x138 – Logic Symbol• 3-to-8 decoder• All of the output pins are active low.

18

Page 19: Digital Design: Principles and Practices

74x138 – Truth Table

19

Page 20: Digital Design: Principles and Practices

74x138 - Logic Diagram

20

Page 21: Digital Design: Principles and Practices

74x138 – Different Logic Symbols

21

Page 22: Digital Design: Principles and Practices

Casc

adin

g Bi

nary

Dec

oder

5-to

-32

Dec

oder

Usi

ng 7

4x13

8s

22

Page 23: Digital Design: Principles and Practices

74x138-like 3-to-8 Binary DecoderBehavior-Style Verilog Module

23

Page 24: Digital Design: Principles and Practices

74x138 – Logic Symbol• 3-to-8 decoder• All of the output pins are active low.

24

Page 25: Digital Design: Principles and Practices

6.5 Encoders(including 6.5.1 & 6.5.2)

Page 26: Digital Design: Principles and Practices

Encoder

• An encoder is a combinational logic circuit that essentially performs a “reverse” decoder function.

• An encoder’s input code normally has more bits than its output code, whereas a decoder’s output code normally has more bits than its input code.

• Probably the simplest encoder to build is a 2n-to-n encoder or binary encoder.

26

Page 27: Digital Design: Principles and Practices

8-to-3 (Binary) Encoder

27

Y0 = I1 + I3 + I5 + I7Y1 = I2 + I3 + I6 + I7Y2 = I4 + I5 + I6 + I7

Page 28: Digital Design: Principles and Practices

8-to-3 (Binary) Encoder- Truth Table

I0 I1 I2 I3 I4 I5 I6 I7 Y2 Y1 Y0

1 0 0 1

1 0 1 0

1 0 1 1

1 1 0 0

1 1 0 1

1 1 1 0

1 1 1 1

28

Page 29: Digital Design: Principles and Practices

A Request Encoder

29

Page 30: Digital Design: Principles and Practices

Priority Encoder

30

• Input I7 has the highest priority.• The IDLE output is asserted if no

inputs are asserted.

Page 31: Digital Design: Principles and Practices

Decimal-to-BCD Encoder

31

Page 32: Digital Design: Principles and Practices

Decimal-to-BCD Encoder

• A3 = 8 + 9• A2 = 4 + 5 + 6 + 7• A1 = 2 + 3 + 6 + 7• A0 = 1 + 3 + 5 + 7 + 9 32

Page 33: Digital Design: Principles and Practices

Decimal-to-BCD Encoder

Basic logic diagram of a decimal-to-BCD encoder

• A3 = 8 + 9• A2 = 4 + 5 + 6 + 7• A1 = 2 + 3 + 6 + 7• A0 = 1 + 3 + 5 + 7 + 9

33

Page 34: Digital Design: Principles and Practices

8-to-3 Encoder

Page 35: Digital Design: Principles and Practices

74x148 – Logic Symbol

• 8-input priority encoder• All inputs and outputs are active low.

• EI_L : enable input• GS_L : group select (got something)• EO_L : enable output (used for

cascading). EO_L is asserted if EI_L is asserted but no request input is asserted.

35

Page 36: Digital Design: Principles and Practices

74x148 – Truth Table

36

Page 37: Digital Design: Principles and Practices

74x148-like 8-input Priority Encoder Behavior-Style Verilog Module

37

Page 38: Digital Design: Principles and Practices

6.6 Three-State Devices(including 6.6.1)

Page 39: Digital Design: Principles and Practices

Three-State Devices

• Three states: 0, 1, or Hi-Z Hi-Z: High Impedance

39

Page 40: Digital Design: Principles and Practices

Tristate Inverter

Implementation of an Tristate Inverter

40

Page 41: Digital Design: Principles and Practices

Eight Sources Sharing a Three-State Party Line

41

Page 42: Digital Design: Principles and Practices

74x541: Octal Three-State Buffer

42

Page 43: Digital Design: Principles and Practices

74x541-like Three-State Device Behavior-Style Verilog Module

43

Page 44: Digital Design: Principles and Practices

6.7 Multiplexers(including 6.7.1)

Page 45: Digital Design: Principles and Practices

Multiplexer (MUX)

• A multiplexer is a digital switch – it connects data from one of n sources to its output.

• Figure 6-57(a) n sources of data each source is b bits wide b output bits usually, 2s = n enable signal (EN)

• A Multiplexer is often calleda MUX for short.

45Figure 6-57 (a)

Page 46: Digital Design: Principles and Practices

Multiplexer (MUX)

46

Page 47: Digital Design: Principles and Practices

75x151: 8-input 1-bit MUX

47

Page 48: Digital Design: Principles and Practices

75x151: 8-input 1-bit MUX

48

Page 49: Digital Design: Principles and Practices

74x157: 2-input 4-bit MUX

49

Page 50: Digital Design: Principles and Practices

74x157 2-input 4-bit MUX

50

Page 51: Digital Design: Principles and Practices

4-input 8-bit MUXDataflow-Style Verilog Module

51

Page 52: Digital Design: Principles and Practices

4-input 8-bit MUXBehavioral-Style Verilog Module

52

Page 53: Digital Design: Principles and Practices

6.8 Exclusive-OR Gates andParity Circuits

(including 6.8.1, 6.8.2, and 6.8.3)

Page 54: Digital Design: Principles and Practices

XOR

• An Exclusive-OR (XOR) gate is a 2-input gate whose output is 1 if exactly one of its inputs is 1.

• Stated another way, an XOR gate produces a 1 output if its inputs are different.

54

Page 55: Digital Design: Principles and Practices

XNOR

• An Exclusive NOR (XNOR) or Equivalence gate is just the opposite to the XOR – it produces a 1 output if its inputs are the same.

55

Page 56: Digital Design: Principles and Practices

XOR

56

Page 57: Digital Design: Principles and Practices

XOR and XNOR

• Any two signals (inputs or output) of an XOR or XNOR gate may be complemented without changing the resulting logic function.

57

Page 58: Digital Design: Principles and Practices

Error Detection & Correction Codes

• The Parity Method For error detection

• The Hamming Code For error detection and correction

58

Page 59: Digital Design: Principles and Practices

The Parity Method• An even parity bit makes the total number of 1s even.• An odd parity bit makes the total number of 1s odd.

P: the parity bit

59

Page 60: Digital Design: Principles and Practices

The Parity Method- Detecting an Error

• A parity bit provides for the detection of a single bit error (or any odd number of errors, which is very unlikely) but cannot check for two errors in one group.

• For instance, let’s assume that we wish to transmit the BCD code 0101. The total code transmitted, including the parity bit, is

0 0 1 0 1↑ BCD Parity bit

0 0 0 0 1↑

Bit error

60

Page 61: Digital Design: Principles and Practices

Parity Circuits

• Odd-parity circuit Its output is 1 if an odd number of its inputs are 1.

• Even-parity circuit Its output is 1 if an even number of its inputs are 1.

61

Page 62: Digital Design: Principles and Practices

Parity Circuits

62

Page 63: Digital Design: Principles and Practices

74x280: 9-bit Parity Generator• 74x280 can be used to

indicate whether an even or odd number of inputs are 1.

63

Page 64: Digital Design: Principles and Practices

3-input XOR DeviceDataflow-Style Verilog Module

64

Page 65: Digital Design: Principles and Practices

9-Input Parity CheckerBehavioral-Style Verilog Module

65

Page 66: Digital Design: Principles and Practices

6.9 Comparators(including 6.9.1)

Page 67: Digital Design: Principles and Practices

Comparator• A circuit that compares two binary words and indicates

whether they are equal is called a comparator.

67

Page 68: Digital Design: Principles and Practices

Comparator

• Comparators can also be built using Exclusive-NOR (XNOR) gates, sometimes called Equivalence gates.

68

Page 69: Digital Design: Principles and Practices

OR Functions

69

4 levels of gate delay at the transistor levelLarger circuit

2 levels of gate delay at the transistor levelSmaller circuit

Page 70: Digital Design: Principles and Practices

6.10 Adders, Subtractors, and ALUs (including 6.10.1, 6.10.2, and 6.10.6)

Page 71: Digital Design: Principles and Practices

Basic Adders

• Half Adder• Full Adder

71

Page 72: Digital Design: Principles and Practices

Half Adder

0 + 0 = 00 + 0 = 0

0 + 1 = 10 + 1 = 1

1 + 0 = 11 + 0 = 1

1 + 1 = 101 + 1 = 10

Zero plus zero equals zeroZero plus zero equals zero

Zero plus one equals oneZero plus one equals one

One plus zero equals oneOne plus zero equals one

One plus one equals zero with a carry of oneOne plus one equals zero with a carry of one

Simple Binary Addition

• The half-adder accepts two binary digits on its inputs and produces two binary digits on its output, a sum bit and a carry bit.

Page 73: Digital Design: Principles and Practices

Half Adder

Page 74: Digital Design: Principles and Practices

Half Adder

Page 75: Digital Design: Principles and Practices

Half Adder

Page 76: Digital Design: Principles and Practices

Binary Addition and Subtraction

76

Page 77: Digital Design: Principles and Practices

Full Adder

77

Page 78: Digital Design: Principles and Practices

Full Adder

Page 79: Digital Design: Principles and Practices

Full Adder

Page 80: Digital Design: Principles and Practices

Full Adder

Page 81: Digital Design: Principles and Practices

4-Bit Ripple (Carry) Adder

81

Page 82: Digital Design: Principles and Practices

4-Bit Ripple (Carry) Adder

Page 83: Digital Design: Principles and Practices

8-Bit (Signed and Unsigned) AdderVerilog Module

83

Page 84: Digital Design: Principles and Practices

ALU – 74x382

84

Page 85: Digital Design: Principles and Practices

What We Have Learned

• Decoders• Encoders• Three-State Devices• Multiplexers (MUX)• XOR and Parity Circuits• Comparators• Adders• ALUs

85

Page 86: Digital Design: Principles and Practices

Universal Gates

• NAND Gate• NOR Gate

Page 87: Digital Design: Principles and Practices

Universal Gates - NAND

• One NAND Gate as an Inverter

Page 88: Digital Design: Principles and Practices

Universal Gates - NAND

• Two NAND Gates as an AND Gate

Page 89: Digital Design: Principles and Practices

Universal Gates - NAND

• Three NAND Gates as an OR Gate

Page 90: Digital Design: Principles and Practices

Universal Gates - NAND

• Four NAND Gates as a NOR Gate

Page 91: Digital Design: Principles and Practices

Universal Gates - NAND

Page 92: Digital Design: Principles and Practices

Universal Gates - NOR

• One NOR Gate as an Inverter

Page 93: Digital Design: Principles and Practices

Universal Gates - NOR

• Two NOR Gates as an OR Gate

Page 94: Digital Design: Principles and Practices

Universal Gates - NOR

• Three NOR Gates as an AND Gate

Page 95: Digital Design: Principles and Practices

Universal Gates - NOR

• Four NOR Gates as a NAND Gate

Page 96: Digital Design: Principles and Practices

Universal Gates - NOR