{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

Info icon This 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)?
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?
Image of page 3

Info icon This 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 = ?
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 .
Image of page 5

Info icon This 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 )
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.
Image of page 7

Info icon This 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 ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern