digital logic design - university of hong kongengg1015/fa11/handouts/06-digitallogic.pdf · digital...

41
Digital Logic Design ENGG1015 1 st Semester, 2011 Dr. Kenneth Wong Department of Electrical and Electronic Engineering

Upload: duongdiep

Post on 19-Jul-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Digital Logic Design

ENGG1015

1st Semester, 2011

Dr. Kenneth Wong

Department of Electrical and Electronic Engineering

Page 2: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Lowered AbstractionLowered AbstractionApplicationsHigh • Image & Video Processing

Systems

gLevel

• Computer & Embedded Systems• Computer Networky

Digital

Computer Network• Mobile Network

• Combinational LogicgLogic

Combinational Logic• Boolean Algebra

Last Circuits • Basic Circuit Theoryweek

ThisElectricalSignals

LowLevel

• Voltage, Current• Power & Energy

This week

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 2

Page 3: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

MotivationMotivationHow do you build a computer system?P ibl “ l t i

CPUC t l +Possible answer: “use electronic

circuits”P ti ll t b t t

Control + Datapath

Partially correct… but way too complicated for human (or even computers) to handle

ALUp )

• 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 soundeasier and mathematically sound abstraction

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 3

Page 4: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Digital Logic DesignDigital Logic DesignIn 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 statescan represent binary numbers using logical statesThey are not voltage value – although they are usually represented using voltage

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 4

Page 5: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Logic FunctionLogic FunctionA logic function takes 1 or more logic input to produce 1 single logic outputproduce 1 single logic output

S ti “d fi ” l i f ti1 2( , , , )ny f x x x= L

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

( ) ( )fBut note that a multi-output function can always be implemented as a grouping of multiple

1 2 1 2( , , , ) ( , , , )m ny y y f x x x=L L

be implemented as a grouping of multiple single-output functions• i.e. just a short handj

Mathematically, it a function produce only 1 output

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 5

Page 6: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Representing Logic OperationsRepresenting Logic OperationsEach function can be represented equivalently in 3 ways:equivalently in 3 ways:• Truth table• Boolean logic expression• Boolean logic expression• Schematics Truth Table

B lBoolean ExpressionSchematics

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 6

Page 7: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Truth TablesTruth TablesDescribe how a logic circuit’s output depends on the logic levels present at the inputs.p p

All the possible combinations of inputs are listed

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

7

Page 8: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

3 Basic Logic Functions3 Basic Logic FunctionsAlso called a logic gate

NOTORAND

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 8

Page 9: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

OR GateOR Gate

Boolean expression

X = A + B

Truth table0 = LOW1 = HIGH

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

time

Timing Diagram9

Page 10: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

• OR gate can have more than 2 inputs:

44--Input OR GateInput OR Gate

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”

10

Page 11: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

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

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

11

Page 12: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

More examples

12

Page 13: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Quick Quiz (1)What is the only set of input conditions that will produce a LOW output for anythat will produce a LOW output for any OR gate?• Any one of the input is LOW• Any one of the input is HIGHy p• All inputs are LOW• All inputs are HIGH• All inputs are HIGH

13

Page 14: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Quick Quiz (2)W it th B l i f iWrite the Boolean expression for a six-input OR gate• X=A+B+C+D+E+F

If th A i t i i l iIf the A input in previous example is permanently kept at HIGH, what will the resultant output waveform be?• Always LOWAlways LOW• Always HIGH

S ti LOW ti HIGH• Sometimes LOW, sometimes HIGH• None of the above

14

Page 15: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

AND GateAND Gate

X ABBoolean expressionTruth table

0 = LOW

X = AB

1 = HIGH

The output of an AND Timing Diagram

e ou pu o agate is HIGH only when all inputs are HIGHall inputs are HIGH.

1533--Input AND GateInput AND Gate

Page 16: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Summary of the AND operation• The AND operation is performed the same as ordinary• 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 0are 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

16

Page 17: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Quick Quiz (3)What is the only input combination that will produce a HIGH at the output of awill produce a HIGH at the output of a five-input AND gate?• Any one of the input is LOW• Any one of the input is HIGHy p• All inputs are LOW• All inputs are HIGH• All inputs are HIGH

17

Page 18: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Quick Quiz (4)Wh t l i l l h ld b li d tWhat 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) fromto be inhibited (prevented) from reaching the output?

A LOW input will keep the output LOW• A LOW input will keep the output LOW• A LOW input will keep the output HIGH• A HIGH input will keep the output LOW• A HIGH input will keep the output HIGHp p p

True or false: An AND gate output will ff f O f

18

always differ from an OR gate output for the same input conditions.

Page 19: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

The NOT Operation & InverterThe NOT Operation & Inverter

X A Boolean expression

Truth table

X = A

The output of a NOT gate is always the

0 = LOW1 = HIGH

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 designsan inverter, especially in circuit designs

19

Page 20: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Other Simple GatesOther Simple GatesALL logic functions, no matter how complex, can be completely expressed using the 3 basic operations AND, OR, g p , ,NOT.

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

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 20

Page 21: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

NAND GateNAND Gate

X = ABX = AB

bubble

Output 0 iff ALL inputs are 1sOutput 0 iff ALL inputs are 1sComplement of an AND gateNote the “bubble” at the output of the symbol, and the bar over the expression y , pAB. Both of them signifies the complement nature to the AND gate

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 21

Page 22: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

NOR GateNOR Gate

X = A + BX = A + B

Output 1 iff ALL inputs are 0sOutput 1 iff ALL inputs are 0s

Complement of an OR gatep g

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 22

Page 23: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

XOR GateXOR Gate

X A ⊕ B

A B X0 0 0

X = A ⊕ B0 1 11 0 1

Exclusive OR gate

1 1 0

Exclusive-OR gate

Output 1 iff exactly one input is 1p y p

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

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 23

Page 24: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

3 Representations of Logic Functions3 ep ese o s o og c u c o sRecall that any complex logic function can be expressed in 3 ways: Truth Table, Boolean Expression, Schematics, p ,

Only Truth Table representation is unique

We can convert representation from oneWe can convert representation from one form to the other

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 24

Page 25: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Schematics to Boolean ExpressionSchematics to Boolean ExpressionExample: 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 ?

O d f d f B l l b AND b f OR P thOrder 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:

25

Page 26: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

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

More examples

26

Page 27: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Quick Quiz (5)What is the output expression of the following logic circuit diagram?following logic-circuit diagram?

• ( )x ABC A D= +

( )x ABCD=

( )x ABC A D= +•

•( )x ABC A D= +

x ABCD=

27

Page 28: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Quick Quiz (6)What is the output expression of the following logic circuit diagram?following logic-circuit diagram?

• ( )x D A B C E= + + ⋅

• x D A B C E⎡ ⎤= + + ⋅ ⋅⎣ ⎦

x D A BC E⎡ ⎤= + + ⋅⎣ ⎦

( )

• ( )x D A B C E⎡ ⎤= + + ⋅⎣ ⎦

x D A B C E⎡ ⎤= + + ⋅ ⋅⎣ ⎦

28

Page 29: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

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

operation unless parentheses indicateoperation unless parentheses indicate otherwiseIf i h b it f• If an expression has a bar over it, perform the operations inside the expression first

d th i t th ltand then invert the result

29

Page 30: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Determining output level from a diagramg p g

30

Page 31: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Example: Draw the circuit diagram to implement the expressionExample: Draw the circuit diagram to implement the expressionX = (A + B)(B + C)

Example: Draw the circuit diagram that implements the expression

using gates having no more than three inputs)( DABCAx += using gates having no more than three inputs. )( DABCAx +=

31

Page 32: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Boolean Expressions to SchematicsBoolean Expressions to SchematicsWhen the operation of a circuit is defined by a Boolean expression, we can draw a logic-circuitBoolean expression, we can draw a logic circuit diagram directly from that expression.Example: draw the circuit for

Done in two stepsy = AC + BC + ABC

p

32

Page 33: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Switch Logic (1)Switch Logic (1)We can construct a logic-circuit diagram using switches and relaysswitches and relays.Normally-open (NO)/normally-close switches:

To implement logical AND and logical OR functions on two human inputs A and B as follows:follows:

The logical value of input is reversed by using a NC switch instead of NO switch 33

Page 34: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Switch Logic (2)Switch Logic (2)Instead of relying human input, a relay should be usedbe used.In other word, a relay allows its switching activity be controlled by another electricalactivity be controlled by another electrical signal.For example:p

OA OR B

34

Page 35: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Quick Quiz (7)What is the output expression of the following switch logic circuit?following switch-logic circuit?

• ( )x A B C= + ⋅

( )( )x A B C= + ⋅

( )x A B C= + ⋅•

( )x A B C= +

( )x A B C= + ⋅

35

Page 36: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

In conclusion…In conclusion…AND, OR, NOT are 3 basic logic gates that can implement all logic functions

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

The same logic functions can beThe same logic functions can be converted between the 3

t ti ilrepresentations easily.

Only truth table representation is uniqueOnly truth table representation is unique

1st semester, 2011 Digital Logic - ENGG1015 - K. Wong 36

Page 37: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

1st semester, 2011 37

Page 38: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

HomeworkHomeworkHomework 1 is out• Due: 5pm on 14 Oct, 2011• Turn in physical copy of your answer• Homework boxes near Room 712, Chow Yei

Ching Building

Homework 2 will be out next week• Due: 5pm on 4 Nov, 2011

Individual homeworkG d t t d f fi lGood way to study for finalZero tolerance on plagiarismp g

1st semester, 2011 38ENGG1015 – E. Lam/K. Wong

Page 39: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Project GroupsProject GroupsNeed to form a group of 4 by the end of this week (Sat 9am)Email the following group information to Leon: culei@eee hku hkEmail the following group information to Leon: [email protected] the following subject in your email:• “ENGG1015 group information”

I l d i th b d f il th f ll i i f tiInclude in the body of your email the following information:• Group Name• Group Members

4 i f + UID• 4 pairs of name + UID• Group leader

The group leader’s role:R ibl f th ti f ll th b• Responsible for the actions of all the members

• Make sure the members can work safely in the lab• Act as main correspondence for the group

R t + t t i l• Request + return materials• NO extra credit

1st semester, 2011 39ENGG1015 – E. Lam/K. Wong

Page 40: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Rough ScheduleRough ScheduleWeek 7/8 (10-21 Oct)• Lab bench “move-in”• Get initial equipments (basic sensors, tools)• Brainstorm on ideas• Put in your 1st equipment request (if and only if you havePut in your 1 equipment request (if and only if you have

some ideas on what you need. See bullet above)Week 8 (17-21 Oct)

G t t k t d f 1st t• Get stock requested from 1st request• Brainstorming session• 2-4pm

Week 9 (24-28 Oct)• Mid-term check-point presentation• 2-4pm2 4pm

Week 10-13• Work on project

1st semester, 2011 40ENGG1015 – E. Lam/K. Wong

Page 41: Digital Logic Design - University of Hong Kongengg1015/fa11/handouts/06-digitallogic.pdf · Digital Logic Design ENGG1015 1st Semester, 2011 Dr. Kenneth Wong Department of Electrical

Working on the ProjectWorking on the Project

The lab will be opened from 9am toThe lab will be opened from 9am to 11pm every weekday

You may work on the project any time you want during that periodyou want during that period

Safety goes first

NO water/fire/chemical !!!

1st semester, 2011 41ENGG1015 – E. Lam/K. Wong