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 AP NOT A A A
AND gate Two inputs BOTH 1 … output 1 Otherwise output 0 ABP A B A AND B A.B A B NB. ‘AND’ means BOTH They must BOTH be true A.B means 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 ABP A + B A B NB CURVE A OR B (or both) A B A + B + means OR
Combinations of these three eg 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) AB what ever ABC Note the traditional order that ensures all the options are covered And when you get on to three inputs… Binary number s
NAND gate An AND gate followed by a NOT gate ABRP A B A and B R = A and B P = NOT R A B A B That little circle turns AND into NAND
NOR gate ABRP R = A or B P = NOT R NOT A or B A B A and B A B A+B An OR gate followed by a NOT gate This little circle indicates that it’s NOT
And with three inputs… (A AND B) OR C (A OR B) AND C ABCRP R= A AND BP = R or C A B C A B C A B C ABCRP R = A OR BP = C AND R 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! A B C A B C AB + C (A+B)C
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? Is A TRUE? End reached? STOP NO YES NOYES AB P
And at A level… 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 B A B A B AB AB AB AB Not both
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.B) = A + B 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… A AND B NOT (A AND B) NOT A NOT B (NOT A) OR (NOT B) AND OR
(A.B) = A + B A AND B NOT (A AND B) NOT A NOT B (NOT A) OR (NOT B) AND OR We see the truth tables (final red column) are the same!!! ABA.B ABABA+B SAME
(A+B) = A. B 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 A OR B NOT (A OR B) NOT A NOT B (NOT A) AND (NOT B) OR AND
(A+B) = A. B We see the TRUTH TABLES (final red column) are the same!!! A OR B NOT (A OR B) NOT A NOT B (NOT A) AND (NOT B) ABABA.B ABA+B SAME OR AND
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….