03LogicGates - COMP 102 Computers and Computing Lecture 3...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP 102: Computers and Computing Lecture 3: Truth Tables and Logic Gates Instructor: Kaleem Siddiqi ([email protected]) Class web page: www.cim.mcgill.ca/~siddiqi/102.html
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
COMP-102: Computers and Computing (thanks to Joelle Pineau!) 2 Practice example Three friends are trying to decide what to do Saturday night (see a movie or go out clubbing). They settle the issue by a vote (everyone gets a single vote, the activity with the most votes wins.) Assume you want a computer to automatically compile the votes and declare the winning activity. What logical variables would you use? Can you write a logical expression , which evaluates whether or not you will go Clubbing (True = Clubbing, False = Movie)?
Background image of page 2
COMP-102: Computers and Computing (thanks to Joelle Pineau!) 3 Practice example Input logical variables: V1 = Vote of person 1 (True=Clubbing, False=Movie) V2 = Vote of person 2 (True=Clubbing, False=Movie) V3 = Vote of person 3 (True=Clubbing, False=Movie) Output logical variables ACTIVITY = Choice of activity (True=Clubbing, False=Movie) Logical expression: ACTIVITY = ( V1 AND V2 ) OR ( V1 AND V3 ) OR ( V2 AND V3 ) How would you check if the logical expression is correct?
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
COMP-102: Computers and Computing (thanks to Joelle Pineau!) 4 Checking logical expressions Computer must be ready for any input, and must compute correct results in all cases. Must go through all possible input combinations: V1=True, V2=True, V3=True ACTIVITY = ? V1=True, V2=True, V3=False ACTIVITY = ? V1=True, V2=False, V3=True ACTIVITY = ? V1=True, V2=False, V3=False ACTIVITY = ? V1=False, V2=True, V3=True ACTIVITY = ? V1=False, V2=True, V3=False ACTIVITY = ? V1=False, V2=False, V3=True ACTIVITY = ? V1=False, V2=False, V3=False ACTIVITY = ?
Background image of page 4
COMP-102: Computers and Computing (thanks to Joelle Pineau!) 5 Truth table Write-up a table with all possible input combinations, and check the output the output for each row. Inputs: Outputs: V1 V2 V3 ACTIVITY 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 This is called a Truth Table .
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
COMP-102: Computers and Computing (thanks to Joelle Pineau!) 6 Comparing logical expressions Recall our previous expression: ACTIVITY = ( V1 AND V2 ) OR ( V1 AND V3 ) OR ( V2 AND V3 ) You can also extract the logical expression directly from the Truth Table: ACTIVITY = ( (NOT V1) AND V2 AND V3 ) OR ( V1 AND (NOT V2 ) AND V3 ) OR ( V1 AND V2 AND (NOT V3) ) OR ( V1 AND V2 AND V3 )
Background image of page 6
COMP-102: Computers and Computing (thanks to Joelle Pineau!) 7 Extracting logical expression from the truth table Recall: ACTIVITY = ( (NOT V1) AND V2 AND V3 ) OR ( V1 AND (NOT V2 ) AND V3 ) OR ( V1 AND V2 AND (NOT V3) ) OR ( V1 AND V2 AND V3 ) How do we get this logical expression: Consider each line in the table.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 29

03LogicGates - COMP 102 Computers and Computing Lecture 3...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online