{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

03LogicGates

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

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

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

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

View Full Document
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)?
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?

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

View Full Document
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 = ?
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 .

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

View Full Document
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 )
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.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern