180 likes | 422 Views
Binary Logic. Derrington KCL CPD/SKE 2014. Binary. We’ve seen how data of all different sorts and kinds can be represented as binary bits… 0s and 1s 1 is used to denote the TRUTH or presence of a state And 0 the FALSITY or absence of a state Now we are going to look at binary logic
E N D
Binary Logic Derrington KCL CPD/SKE 2014
Binary • We’ve seen how data of all different sorts and kinds can be represented as binary bits… 0s and 1s • 1 is used to denote the TRUTH or presence of a state • And 0 the FALSITY or absence of a state • Now we are going to look at binary logic • At how inputs in the form of 0s and 1s can be logically processed • And output… again in the form of 0s and 1s • Using simple circuits called LOGIC GATES
Switches…. Circuits • 1 , 0 • ON, OFF • TRUE, FALSE • BOOLEAN Logic… invented by George BOOLE enables computers to process binary data
The NOT gate • Very simple • If a 0 is input, then the output is a 1 • And if the input is a 1 then the output is a zero A A NOT A NOT A
AND gate • Two inputs • BOTH 1 … output 1 • Otherwise output 0 A.B means A AND B A A.B B A.B B A NB. ‘AND’ means BOTH They must BOTH be true A AND B
OR gate • If either or both the inputs are 1 then the output is 1 • If neither of them are 1, the output is zero + means OR A A + B B A B A OR B (or both) A + B NB CURVE
Combinations of these threeeg NAND and NOR (this is all at GCSE) • When drawing the circuits and writing the truth tables for more complex combinations of these three gates.. • Start with all the possible combinations of A and B (0 and 1) And when you get on to three inputs… Note the traditional order Note the traditional order that ensures all the options are covered Binary numbers
NAND gate • An AND gate followed by a NOT gate R = A and B P = NOT R A A B B NOT (A AND B) A and B B A That little circle turns AND into NAND
NOR gate An OR gate followed by a NOT gate R = A or B P = NOT R A A+B A and B B A B This little circle indicates that it’s NOT NOT A or B
R= A AND B P = R or C C A B C A B And with three inputs… A C • (A AND B) OR C • (A OR B) AND C AB + C B C A B R = A OR B P = C AND R A (A+B)C B C • Is (A and B) and C = A and (B and C) • Is (A OR B) OR C = A OR (B OR C) • Draw up the truth tables and see. If two operations have the same truth table, then they must be the same: if they haven’t, they aren’t!
Understanding how these logic gates are used in programming • It is all a way of turning decisions about input into binary….. • eg a program with a REPEAT UNTIL loop • REPEAT • Bla bla bla • UNTIL • condition A is TRUE OR • The end of the file is reached • This can be seen on a TRUTH TABLE.. • In fact it is the OR gate table Isn’t it?
And at A level… Not both • The exclusive OR gate EOR (one or the other but NOT both) • NEOR, (an EOR gate followed by a NOT gate) • Also more complicated combinations of functions and their truth tables • And De Morgan’s Laws A A B A B B A A B A B B
De Morgan’s laws • These govern how we can convert Boolean expressions from one type of operation to another • (A.B) = A+B • (A+B) = A . B • We prove these are equivalent by showing that they have the same truth tables. De Morgan’s Laws… turn ANDs into ORs and vice versa
A AND B (A.B) = A + B AND OR • NOT (A AND B) is the same as NOT A OR NOT B To put it another way… • A AND B is false if A is false OR B is false The Venn diagrams help us see it… the Truth tables PROVE it… NOT (A AND B) NOT A NOT B (NOT A) OR (NOT B)
A AND B (A.B) = A + B AND OR • We see the truth tables (final red column) are the same!!! NOT (A AND B) NOT A NOT B SAME (NOT A) OR (NOT B)
A OR B (A+B) = A . B AND NOT (A OR B) OR • NOT (A OR B) is the same as • (NOT A) AND (NOT B) • To put it another way… • A OR B is false if • Both A is false AND B is false • Again, the Venn diagrams help us see it, but the TRUTH TABLES PROVE IT NOT A NOT B (NOT A) AND (NOT B)
A OR B (A+B) = A . B OR AND NOT (A OR B) • We see the TRUTH TABLES (final red column) are the same!!! NOT A NOT B SAME (NOT A) AND (NOT B)
At A level (AS) • Use de Morgan’s laws to simplify Boolean expressions • Create truth tables from logic gates • And vice versa • Create logic circuits from descriptions of systems. • There is a selection of worksheets and exam questions here on KEATS for you to try….