binary logic

18
Binary Logic Derrington KCL CPD/SKE 2014

Upload: alton

Post on 14-Jan-2016

112 views

Category:

Documents


2 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Binary Logic

Binary Logic

Derrington KCL CPD/SKE 2014

Page 2: Binary Logic

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

Page 3: Binary Logic

Switches…. Circuits

1 , 0ON, OFFTRUE, FALSE

BOOLEAN Logic… invented by George BOOLE enables computers to process binary data

Page 4: Binary Logic

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 P

0 1

1 0

NOT A

NOT A

A A

Page 5: Binary Logic

AND gate

Two inputs BOTH 1 … output 1 Otherwise output 0

A B P

0 0 0

0 1 0

1 0 0

1 1 1

A B

A AND B

A.B

A

B A.B

NB. ‘AND’ means BOTHThey must BOTH be true

A.B means

A AND B

Page 6: Binary Logic

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

A B P

0 0 0

0 1 1

1 0 1

1 1 1

A + B

A B

NBCURVE

A OR B(or both)

A

BA + B

+ means OR

Page 7: Binary Logic

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)

A B whatever

0 0

0 1

1 0

1 1

A B C whatever

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

Note the traditional

order Note the traditional

orderthat ensures

all the options are

covered

And when you get on to three inputs…

Binary number

s

Page 8: Binary Logic

NAND gate

An AND gate followed by a NOT gate

A B R P

0 0 0 1

0 1 0 1

1 0 0 1

1 1 1 0

A B

A and B

R = A and BP =

NOT R

A

BA B

That little circle turns AND into NAND

Page 9: Binary Logic

NOR gateA B R P

0 0 0 1

0 1 1 0

1 0 1 0

1 1 1 0

R = A or B P =

NOT R

NOT A or B

A BA

and B

A

BA+B

An OR gate

followed by a NOT gate

This little circle indicates that it’s NOT

Page 10: Binary Logic

And with three inputs… (A AND B) OR C

(A OR B) AND C

A B C R P

0 0 0 0 0

0 0 1 0 1

0 1 0 0 0

0 1 1 0 1

1 0 0 0 0

1 0 1 0 1

1 1 0 1 1

1 1 1 1 1

R= A AND B P = R or C

A B

C

A B

C

AB

C A B C R P

0 0 0 0 0

0 0 1 0 0

0 1 0 1 0

0 1 1 1 1

1 0 0 1 0

1 0 1 1 1

1 1 0 1 0

1 1 1 1 1

R = A OR B P = 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

BC

AB + C

(A+B)C

Page 11: Binary Logic

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 NO NO

NO YES YES

YES NO YES

YES YES YES

A B P0 0 0

0 1 1

1 0 1

1 1 1

Page 12: Binary Logic

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

AB

A B

A B

A B A B

0 0 0

0 1 1

1 0 1

1 1 0

A B A B

0 0 1

0 1 0

1 0 0

1 1 1

A B

A B

Not both

Page 13: Binary Logic

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

Page 14: Binary Logic

(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

Page 15: Binary Logic

(A.B) = A + BA 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!!!

A B A.B A.B

0 0 0 1

0 1 0 1

1 0 0 1

1 1 1 0

A B A B A+B

0 0 1 1 1

0 1 1 0 1

1 0 0 1 1

1 1 0 0 0

SAME

Page 16: Binary Logic

(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

Page 17: Binary Logic

(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)

A B A B A.B

0 0 1 1 1

0 1 1 0 0

1 0 0 1 0

1 1 0 0 0

A B A+B A+B

0 0 0 1

0 1 1 0

1 0 1 0

1 1 1 0

SAME

OR AND

Page 18: Binary Logic

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….