47
Computers in the real world Objectives • Understand what is meant by binary • Why do computers use binary? • Understand what is meant by a truth table. • Be able to read simple logic gate circuit diagrams • Be able to create and append to circuit diagrams.

Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Embed Size (px)

Citation preview

Page 1: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldObjectives

• Understand what is meant by binary• Why do computers use binary?• Understand what is meant by a truth table.• Be able to read simple logic gate circuit

diagrams• Be able to create and append to circuit

diagrams.

Page 2: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldBinary 1 or 0

Computer only understand binary. A binary digit can only be either 1 or 0.

By arranging 1’s and 0’s together in special ways we can create anything!

•Numbers•Letters•Pictures•Music•Software!

When you read text on a screen the computer sees a series of 1’s and 0’s!

Page 3: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldWhy?

0 Voltage

High Voltage

Low Voltage

Computers communicate binary by setting a voltage on a wire. A high voltage represents a 1 and a low voltage represents a 0. 0 voltage DOES NOT means a 0 binary digit! It means the line is broke!

Page 4: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldWhy?

The voltage is measured at fixed time intervals. That way a binary value can be “read”. The value here is 10011!

Page 5: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldWhy?

What is wrong with this? Voltages sometimes fluctuate. When the values are close together (like in the diagram below) a fluctuation could mean the difference between a 7 being seen as a 9! As this is very common it would mean the computer would crash MUCH more often!

0 Voltage

1

3

7

5

1

9

Page 6: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldWhy?

In order to represent two values we need two separate voltages. In a perfect world we could have more than two voltages. The diagram below shows what a signal along a 10 (or normal number) line may look like.

0 Voltage

1

3

7

5

1

Page 7: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldWhy?

0 Voltage

High Voltage

Low Voltage

Lets see what happens if a voltage changes in this example.

Middle Voltage

Page 8: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldWhy?

0 Voltage

High Voltage

Low Voltage

Even though it has moved it is still clearly in the low voltage area. The computer would have no problem recognising this as a 0. Computers and binary go together like bread and butter. Or cake and chocolate... Mmm chocolate cake

Middle Voltage

Page 9: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldImplications of binary

Ever wondered why computer memory has odd sizes? Like 512 Mb or 1024 Mb?

We already know computers use binary...

This means we use binary or “base 2” for sizes.

ALL sizes on computers are 2x

So the pattern will be 2,4,8,16,32,64,128,256,512,1024,4048 and so on.

Page 10: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

Add a new section to your revision notes called binary logic. Explain

•What is binary?•Why do computers use binary?

You are not expected to be able to convert number or text into binary!!

Page 11: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldComputers and logic

You may not believe this but...

Computers are logical!

Honest!

Page 12: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldWhat is binary logic

Computers use binary logic to do many great things. It is one of the key skills needed in order to be able to program a computer. It also helps to understand why computers can be a “bit thick” sometimes. More on that later

Binary logic is where we say if something is either true or false. There is no maybes or kind of. Just true or false.

For example “Is that a car?” would result in true or false. Or “Mr Hamflett has a beard today”. Statements like “Is Mr Hamflett awesome?” would NOT be binary logic as the answer will not be answered the same by different people.

Page 13: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldPredictable

Binary logic must be predictable. That means that if you asked anyone you would always get the same true or false answer. We must be able to predict the outcome.

It has a posh name. Binary logic is deterministic. You do not need to know that word but it may be good way to confuse your mates!

Computers are deterministic. That means that their behaviour must be predictable given the same input and circumstances. As I have already said you may thing computers have a mind of their own and are NOT predictable. I can assure you they are and there are reasons why they act the way they do. More on that later!

Page 14: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

Some students like to travel on trains. Not all students like cheese.

Discuss in groups which of the following statements are true based on the statements above.

a) Students who like cheese do not like to travel on a trainb) Student who travel by train like eating cheesec) Some students who travel by train will like cheesed) Students who do not like cheese may still like the train.

Page 15: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldAnswers

Some students like to travel on trains. Not all students like cheese.

Discuss in groups which of the following statements are true based on the statements above.

a) Students who like cheese do not like to travel on a trainb) Student who travel by train like eating cheesec) Some students who travel by train will like cheesed) Students who do not like cheese may still like the train.

Page 16: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

Open the “understanding logic” work sheet and answer all of the questions.

Page 17: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldBinary operators

We can connect truth statements together by using special words. We call these binary (or Boolean) operators.

The words we can use are –ANDOR NOT

By doing this we can derive something else which is true. For example -

1. It is raining2. I have an umbrella

It is raining AND I have an umbrella means I will not get wet

Page 18: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldTruth tables

We can consider all of the possibilities of the last statement in a little table. This is known as a truth table.

It is raining I have an umbrella I wont get wet

True True True

True False False

False True False

False False False

The above table shows the truth for AND. Both things MUST be true for the result to be true. But hang on there is a mistake! If it is not raining i will not get wet either! Duh! We need to use our boolean operators to try and fix this. Let us look at what OR and NOT do!

Page 19: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldAND

AND – If A and B are both true then A AND B is true.

A B A AND B

True True True

True False False

False True False

False False False

Key point – Both MUST be true for AND to be true!

Page 20: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldOR

OR– If either A or B are true then A OR B is true

A B A OR B

True True True

True False True

False True True

False False False

Key point – At least one of A or B must be true!

Page 21: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldNOT

NOT– reverses truth. True becomes false and false becomes true!

A NOT A

True False

False True

Key point – This flips truth!

Page 22: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

For all of these questions assume that A = True and B = false. Write down if the result will be true or false.

1) A AND B2) NOT B3) NOT A4) A OR B5) NOT (A AND B)

Page 23: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldComing back to our problem

We already know there are issues with the statement below. We want the truth below but AND / OR / NOT on their own will create it! We will need to combine them in order to create the correct table.

It is raining I have an umbrella I wont get wet

True True True

True False False

False True True

False False True

We need to get creative to create the correct truth table!

Page 24: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldComing back to our problem

If we flip the raining we get the column in yellow. So rather that say true if it is raining, we say false.

It is raining NOT (It is raining)

I have an umbrella

I wont get wet

True False True True

True False False False

False True True True

False True False True

Now look at what we have. We can now use OR to get the required answers on the left. So our final truth statement is

NOT (it is raining) OR I have an umbrella

Page 25: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

For all of these questions assume that A = True and B = false. Write down if the result will be true or false.

1) (NOT A) AND (NOT B)2) NOT (A OR B)3) (A OR B) AND (B OR A)4) NOT (A OR B) OR (A AND B)

Once we have gone over the answers you should do the “truth table” worksheet

Page 26: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldTruth is a matter of on or off!

Now that we have an idea of what we mean by AND / OR / NOT we can start looking at how truth is represented on a computer. If you do electronics then you will already know this!

True = 1 (on)False = 0 (off)

So rather than writing True or false we can write 1 or 0.

Let us see how this changes the truth tables.

Exam tip – You will be using 1 / 0 in the exam so get used to doing it this way!

Page 27: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldAND

AND – If A and B are both 1 then A AND B is 1.

A B A AND B

1 1 1

1 0 0

0 1 0

0 0 0

Key point – Both MUST be 1 for AND to be 1!

Page 28: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldOR

OR– If either A or B are 1 then A OR B is 1

A B A OR B

1 1 1

1 0 1

0 1 1

0 0 0

Key point – At least one of A or B must be 1!

Page 29: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldNOT

NOT– reverses truth. 1 becomes 0 and 0 becomes 1!

A NOT A

1 0

0 1

Key point – This flips truth!

Page 30: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

Copy the truth tables into your revision notes. Make sure you copy the ones with 1’s and 0’s!

Yes i did say copy! It does not happen very often I know! Bask in the lazy glow!

Page 31: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldLogic gates

Now that we have an idea of truth and understand this on / off / 1 / 0 malarkey we can move onto logic gates.

You will need to be able to read them, append to them and create them. You will also be expected to create truth tables from them.

Below are what AND / OR and NOT look like

Page 32: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldRemembering them!

You need to remember these symbols. Let us use some memory techniques to help.

The OR looks a bit like a badge. There is lots of badges to choose from but your only allowed to wear one. So could it be that one OR that one OR that one ....

NOT has a circle at the end which is a bit like a full stop. You are NOT having that, full stop!!!

AND looks a bit like a pac man ghost. Pacman needs to eat power kills AND avoid ghosts.

Page 33: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

In your revision notes copy the symbols. Now think of a fun / interesting way to remember what they look like. Note it down next to the icon.

This may seem silly but lets face it what does AND look like??? It will be hard to remember in a years time!

Page 34: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldReading results off a logic gate

The diagram below has been labelled with letters. It has two Inputs and one out put. The inputs are labelled X and Y while the output is Labelled P.

X

Y

P

What would be the output if the inputs were –X = 1Y = 0P = ???

Page 35: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldReading results off a logic gate

X

Y

P

X Y P

1 1 1

1 0 0

0 1 0

0 0 0

Here is the truth table for this diagram. Do you recognise it? You should because this is....

AND!!

Page 36: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

Complete the questions below

X

YP

What would be the output if the inputs were –X = 1Y = 0P = ???

Create the truth table for this.

Page 37: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldCombining gates

The diagram below is P = NOT (X OR B)

X

Y

P

How? Well the output of the OR is fed into the NOT. So we do X OR Y and then NOT it. When you want to NOT the whole of a truth statement you need to put the NOT at the end. Even though we write it down at the front.

Bit confusing but it will become clearer over time.

Page 38: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldTruth table of P = NOT( X AND Y)

X Y P

1 1 0

1 0 0

0 1 0

0 0 1

X

Y

P

Page 39: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldNeed help? TRUTH TABLE IT!

X Y X OR Y P

1 1 1 0

1 0 1 0

0 1 1 0

0 0 0 1

X

Y

P

If you add a column for each stage then it will help you work out the answer! With all these 1’s and 0’s floating around it is easy to get confuzzled.

Page 40: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

Create the truth table (including any help) for the logic gate diagram below.

L

D

K

You may wish you create a extra column for the first symbol!

Page 41: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldMore that 2 inputs

It is possible to have more than 2 inputs. The diagram below shows three inputs (A, B and C). The equation is Z = (A OR B) AND (NOT C)

A

BZ

You can create truth tables for these beasts as well!

C

Page 42: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldMore that 2 inputs

It is possible to have more than 2 inputs. The diagram below shows three inputs (A, B and C). The equation is Z = (A OR B) AND (NOT C)

A B C Z

1 1 0 1

1 0 0 1

0 1 0 1

0 0 0 0

1 1 1 0

1 0 1 0

0 1 1 0

0 0 1 0

So how did I make this? I will take you through the steps

Page 43: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldStep 1 – Write out all the permutations

The first step is write down all of the possibilities. As there are now 3 inputs there are extra rows.

A B C

1 1 0

1 0 0

0 1 0

0 0 0

1 1 1

1 0 1

0 1 1

0 0 1

Every possibility must be written down. As a rule of thumb

1 input = 2 rows2 inputs = 4 rows3 inputs = 8 rows4 inputs = 16 rows..

They double each time!

As a tip. When you add a extra output copy all of the rows and then add 0’s in the new input for the first half and 1’s for the second half.

Page 44: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldStep 2 – Perform the first logic gate

Now we create a new column for the first logic gate. That will help us work out the output of that gate. This will then be the input to the next!

A B C A OR B

1 1 0 1

1 0 0 1

0 1 0 1

0 0 0 0

1 1 1 1

1 0 1 1

0 1 1 1

0 0 1 0

Page 45: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldStep 3 – Do the same for the next logic gate

We just add a new column for each logic gate. Things are starting to take shape!

A B C A OR B NOT C

1 1 0 1 1

1 0 0 1 1

0 1 0 1 1

0 0 0 0 1

1 1 1 1 0

1 0 1 1 0

0 1 1 1 0

0 0 1 0 0

Page 46: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldStep 4 – The result!

Z = (NOT C) AND (A OR B)

A B C A OR B

NOT C Z

1 1 0 1 1 1

1 0 0 1 1 1

0 1 0 1 1 1

0 0 0 0 1 0

1 1 1 1 0 0

1 0 1 1 0 0

0 1 1 1 0 0

0 0 1 0 0 0

Page 47: Computers in the real world Objectives Understand what is meant by binary Why do computers use binary? Understand what is meant by a truth table. Be able

Computers in the real worldActivity

Write down the equation related to this diagram and then create a truth table.

L

D

K

The key to success here is HOW you do it, not the answer!

A