Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital...

27
Digital Logic Design ENGG1015 1 st Semester, 2010 Dr. Kenneth Wong Dr. Hayden So Department of Electrical and Electronic Engineering

Transcript of Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital...

Page 1: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

Digital Logic Design

ENGG1015

1st Semester, 2010

Dr. Kenneth Wong Dr. Hayden So

Department of Electrical and Electronic Engineering

Page 2: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

Lowered Abstraction

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 2

Applications

Systems

Digital Logic

Circuits

Electrical Signals

High Level

Low Level

•  Computer & Embedded Systems •  Computer Network •  Mobile Network

•  Image & Video Processing

•  Combinational Logic •  Boolean Algebra

•  Basic Circuit Theory

•  Voltage, Current •  Power & Energy

Last week

This week

Page 3: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

Motivation   How do you build a computer system?   Possible answer: “use electronic

circuits”   Partially correct… but way too

complicated for human (or even computers) to handle •  Too many things to consider: voltage,

current, resistance, loading effect…   The study of digital logic helps to

design large digital systems with a easier and mathematically sound abstraction

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 3

CPU Control + Datapath

ALU

+

Page 4: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

Digital Logic Design   In a digital system, all signals take on discrete values.

•  Also referred as states   Most modern digital systems operate on 2 discrete states

•  binary logic system   We represent the two states as

•  True and false •  1 and 0 •  High and Low

  Remember: They are not binary numbers -- although you can represent binary numbers using logical states

  They are not voltage value – although they are usually represented using voltage

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 4

Page 5: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

Logic Function   A logic function takes 1 or more logic input to

produce 1 single logic output

  Sometimes one may “define” logic functions that produce more than 1 output

  But note that a multi-output function can always be implemented as a grouping of multiple single-output functions •  i.e. just a short hand

  Mathematically, it a function produce only 1 output

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 5

y = f (x1,x2,…,xn )

(y1,y2,…,ym ) = f (x1,x2,…,xn )

Page 6: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

Representing Logic Operations  Each function can be represented

equivalently in 3 ways: •  Truth table •  Boolean logic expression •  Schematics

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 6

Truth Table

Boolean Expression Schematics

Page 7: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

7

Truth Tables   Describe how a logic circuit’s output depends on the logic levels

present at the inputs.

  All the possible combinations of inputs are listed

  If the truth table is known, we completely know how the circuit behave!!

Page 8: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

3 Basic Logic Functions  Also called a logic gate

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 8

NOT OR AND

Page 9: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

OR Gate

 The output of an OR gate is HIGH iff one or more inputs are HIGH

9

Truth table 0 = LOW 1 = HIGH

Boolean expression

Timing Diagram

time

X = A + B

Page 10: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

10

•  OR gate can have more than 2 inputs:

  Summary of OR operation: •  Produce a result of 1 whenever any input is 1. Otherwise 0. •  The expression x=A+B is read as “x equals A OR B”

Page 11: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

11

Alarm is activated whenever the temperature exceeds a maximum value VTR or whenever the pressure goes above a certain limit VPR

•  Example of the use of an OR gate in an alarm system

Page 12: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

More examples

12

•  Review questions: •  What is the only set of input conditions that will produce a LOW output for any OR gate? -- Ans: all inputs LOW •  Write the Boolean expression for a six-input OR gate. -- Ans: X=A+B+C+D+E+F •  If the A input in previous example is permanently kept at the 1 level, what

will the resultant output waveform be? -- Ans: constant HIGH

Page 13: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

AND Gate

  The output of an AND gate is HIGH only when all inputs are HIGH.

13

Boolean expression Truth table 0 = LOW 1 = HIGH

Timing Diagram

X = AB

Page 14: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

14

  Summary of the AND operation •  The AND operation is performed the same as ordinary

multiplication of 1s and 0s. •  An AND gate output will be 1 only for the case when all inputs

are 1; for all other cases the output will be 0. •  The expression x=A•B is read as “x equals A AND B.”

  Review Questions   What is the only input combination that will produce a HIGH at the

output of a five-input AND gate? •  all 5 inputs = 1

  What logic level should be applied to the second input of a two-input AND gate if the logic signal at the first input is to be inhibited (prevented) from reaching the output? •  A LOW input will keep the output LOW

  True or false: An AND gate output will always differ from an OR gate output for the same input conditions. •  False

Page 15: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

The NOT Operation & Inverter

 The output of a NOT gate is always the complement (opposite) of the input.

 A NOT gate is sometimes referred as an inverter, especially in circuit designs

15

Boolean expression

Truth table 0 = LOW 1 = HIGH

X = A

Page 16: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

Other Simple Gates  ALL logic functions, no matter how

complex, can be completely expressed using the 3 basic operations AND, OR, NOT.

 However, many systems utilizes more than just the 3 basic logic gates because it makes the design cleaner and easier to understand (for human).

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 16

Page 17: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

NAND Gate

 Output 0 iff ALL inputs are 1s  Complement of an AND gate  Note the “bubble” at the output of the

symbol, and the bar over the expression AB. Both of them signifies the complement nature to the AND gate

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 17

X = AB

bubble

Page 18: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

NOR Gate

 Output 1 iff ALL inputs are 0s

 Complement of an OR gate

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 18

X = A + B

Page 19: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

XOR Gate

 Exclusive-OR gate

 Output 1 iff exactly one input is 1

 Similar to an OR gate, except that when both inputs are 1, the output is 0

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 19

X = A⊕ BA B X 0 0 0 0 1 1 1 0 1 1 1 0

Page 20: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

3 Representations of Logic Functions  Recall that any complex logic function

can be expressed in 3 ways: Truth Table, Boolean Expression, Schematics

 Only Truth Table representation is unique

 We can convert representation from one form to the other

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 20

Page 21: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

21

Schematics to Boolean Expression   Example: logic circuit with its Boolean expression

  Question: how to interpret A·B+C? •  Is it A·B ORed with C ? Is it A ANDed with B+C ?

  Order of precedence for Boolean algebra: AND before OR. Parentheses make the expression clearer, but they are not needed for the case on the preceding slide.

  Therefore the case below is different:

Page 22: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

22

  Whenever an INVERTER is present in a logic-circuit diagram, its output expression is simply equal to the input expression with a bar over it.

  More examples:

Page 23: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

Precedence  Given an Boolean expression •  First, perform all inversions of single terms •  Perform all operations with parentheses •  Perform an AND operation before an OR

operation unless parentheses indicate otherwise

•  If an expression has a bar over it, perform the operations inside the expression first and then invert the result

23

Page 24: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

24

Determining output level from a diagram

Page 25: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

25

  Example: Draw the circuit diagram to implement the expression

  Example: Draw the circuit diagram that implements the expression

using gates having no more than three inputs.

X = (A + B)(B + C)

Page 26: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

Boolean Expressions to Schematics   When the operation of a circuit is defined by a

Boolean expression, we can draw a logic-circuit diagram directly from that expression.

  Example: draw the circuit for

  Done in two steps

26

Page 27: Digital Logic Design - University of Hong Kongengg1015/fa10/handouts/06-digitallogic.pdf · Digital Logic Design In a digital system, all signals take on discrete values. • Also

In conclusion…  AND, OR, NOT are 3 basic logic gates

that can implement all logic functions

 All logic functions can be represented as (1) truth table (2) schematics (3) Boolean expressions

 The same logic functions can be converted between the 3 representations easily.

 Only truth table representation is unique

1st semester, 2010 Digital Logic - ENGG1015 - K. Wong/H. So 27