Post on 24-Jan-2020
transcript
Advanced Boolean Logic and Gates
Lupoli’s Theorem on Understanding DecisionsComputer Makes the ultimate decisionProgrammer (you and me) Sets the criteria
Decision StructuresSingle-alternative selection structure Dual-alternative selection structure
Action is provided for only one outcome
if-then
Provides an action for each of two possible outcomes
Beginning at “Start”, where would we go in the flowchart when “housekeeping” appears?
Explanation of Relation OperationsSymbol Means Example! not if(answer != ‘Q’)++ / -- incrementing/decrementing covered later% modulus - remainder covered later+ - / * normal arithmetic symbols< less than 4 < 8 = = True<= less than or equal to 6 <= 6 = = True> greater than 6 > 4 = = True>= greater than or equal to 6 > = 6 = = True= = used to COMPARE – if they are equal if ( answer = = ‘Q’)! = or <> used to COMPARE – if they are NOT equal if(answer != ‘Q’)&& and covered later| | or covered later
Logical Operators/Gates used to make decisions in programming and circuit boards 0 == false 1 == true
Why are we learning this? so many things are created using these gates!! application
o http://www.youtube.com/watch?v=idhTFhtDyKY&feature=fvwrel schematic
o http://www.flickr.com/photos/29971737@N03/6293170275/in/ photostream/
OR gate One OR the other must be true in order for the entire expression to be true
Symbols representing the OR GateMathematical Electronic Programming
+ Or (in VB)|| (Java, just above the enter)
Using the two images below, what direction does the electricity flow in the electronic symbol?? (A or B)
A B
OR Gate (||)x y answer0 0 00 1 11 0 11 1 1
OR Example(x) your keys in the ignition?(y) are your headlights on?(answer)
will the alarm sound?
AND gate One AND the other must be true in order for the entire expression to be true
Symbols representing the AND GateMathematical Electronic Programming
• VB = AndJava/C++ = &&
AND Gate (&&)x y answer0 0 00 1 01 0 01 1 1
AND Example(x) eat your veggies?(y) behaved well at the table?(answer)
will you get dessert?
NOT gate reverses (negates) the answer
o Mr. L, you’re cool. NOT!!!! Symbols
o ‾ (Mathematical)o ! (Programming)
Symbols representing the NOT GateMathematical Electronic Programming
!
NOT Gate (!)x answer0 11 0
NOR gate Same as an OR, but the results are NOTTED (or reversed)
NOR Gate compared to OROR NOR
NAND gate Same as an AND, but the results are NOTTED (or reversed)
NAND Gate compared to ANDAND NAND
What does the NOR and NAND gate look electronically (on a schematic)?? Draw it!!
x y answer0 0 00 1 11 0 11 1 1
x y answer0 0 10 1 01 0 01 1 0
x y answer0 0 00 1 01 0 01 1 1
x y answer0 0 10 1 11 0 11 1 0
Determine output in circuits there is a direction of flow
o usually from top or left, goes into gate, then a single outputI will do the following Values Answer
A = 0B = 0
Q = ???
Complete the Following
1A = 1B = 0C = 1
Z = ???
2
A = 1B = 1C = 0
f = ???
3
A = 1B = 0C = 0
4A = 1B = 1C = 0
5A = 0B = 0C = 1
Test your answer with On-line simulations!! use an LED to determine FINAL answer
o if ON, then 1, otherwise… pick the first simulation, the other is a backup
o http://www.neuroproductions.be/logic-lab/ o http://logic.ly/demo/
use Toggle Switch instead of a Push Button
Answers to problems above#1 and 2
Tell me what XOR and XNOR are!!! Program it to find out!!
Gates not covered yet!!XOR
0 0 ??0 1 ??1 0 ??1 1 ??
XNOR0 0 ??0 1 ??1 0 ??1 1 ??
Boolean Algebra uses the math symbol same overall idea, just in MATH form!!
Boolean Algebra LayoutMathematic ProgrammingAB AND A && BA + B OR A || B
Ex. (B + C) AA B C (B + C) A answer0 0 0 0 1
0 0 1 1 1
0 1 0 1 1
0 1 1 1 1
1 0 0 0 0
1 0 1 1 0
1 1 0 1 0
1 1 1 1 0
Try a few examples:
1. (AB) + CA B C (AB) + C0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1
2. A + (BC)A
A B C0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1
Try it in our Logic simulator!! Answersb:
Boolean Logic representations
WRITE YOUR ANSWERS ON PAPERComplete as a group
Circuit Mathematical Programming
1
(AB) + C
Answers:
(A && B) || C
2
3
4
(A || C) || B
Suggested way of completing the mathematical conversion, start output to input!!
Answer Section
(AB) + C
With inputs 0, 0, 0 (A,B,C respectfully)
With inputs 0, 0, 1 (A,B,C respectfully)