Loading...

Hey there and welcome back to computer systems. I'm Mac your computing teacher of this unit.

In this lesson, we're going to learn all about logic gates the building blocks of processors.

Like usual you're going to need a notepad and a pen but also I can make sure that you've got a pencil because we're going to be doing some drawing in this lesson.

Like usual I've got my water bottle here and I want you to make sure that you got some refreshment if you need it throughout the lesson.

If you want to pause the video here and get all the things that you need I'll be here when you get back.

In this lesson you're going to discover the AND, OR and NOT logic gates.

You're going to learn how logic gates are used inside of a computer and how you can solve a problem with logic gates.

Let's get started.

It's all very logical.

George Boole was an English mathematician who lived in the 1800s.

And in 1847 he wrote a book called the Mathematical Analysis of Logic, in which introduced the idea of Boolean algebra which used the logical states of True or False to try and solve problems. This work was added to by Claude Shannon.

In 1940 Claude Shannon discovered the Boolean algebra could be applied to electrical circuits.

The True or False values could also be represented as a one and a zero.

Hopefully this is sounding familiar to you and rings a little bit of binary.

Shannon's discovery forms the basis of all electronic computers.

As you already know all computers have a central processing unit or the CPU and the CPU processes the data and instructions for the computer.

This processing uses billions of tiny electronic components to carry out operations and they're called logic gates.

logic gates use Boolean logic to take one or more inputs and produce a single output.

We use symbols to represent these gates in a circuit and you can see the symbols on the right hand side here.

There were three fundamental logic gates that you need to know about.

There are AND, OR and NOT.

Logic gates can be switched on and off depending on the input that has been provided and the type of gate being used.

If the inputs evaluate to True then an electrical current will flow through the gate and the gate will be switched on.

Like you can see in the diagram here we have two inputs which are both True and this gate here which is AND gate don't worry more on that in a minute means that if both of these are True the output will also be True.

So if this is an electrical circuit at the moment electrical current will be flowing through this component and could reach anything else that was on the other side.

If the inputs however, evaluate to False, then the electrical current will be stopped and the gate will be switched off.

So just we can see here we've now only got one True input so this gate now only got one True input and so this gate will not allow electrical current to flow through it.

It will output False and the electrical current will be stopped.

The gate is switched off.

So there's some important points, just two inputs they have to evaluate the right criteria for the gate and if so the gate will output True and electrical current can flow.

Let's start having a look at the three fundamental gates with the AND gate.

So, here's an example of the logic operator AND used in pseudo code you can see it on the right hand side here.

I have a question for you what will the output of this programme be when it is executed? if you'd like to pause the video here so you can read through it and come up with an answer that's fine resuming when you're done and I'll tell you what it is.

Welcome back.

How'd you get on? So let's have a look.

What will this programme output when it is executed? Well it will output hello and I hope you got that.

That's because the AND condition is a compound of two other conditions that were around it and both of those sub conditions need to be True for the AND condition to ring True.

So in here you can see we've got if person equals Sam AND known equals True.

So we've got two conditions that person equals Sam AND known equals True and they both need to be True for this entire if statement to ring True.

And in this case they are because we've set person to Sam and known is True.

So both parts need to be True for an AND condition to be true.

So the AND logic gate has two inputs and all logic gates remember this is important all logic gates only have a single output.

So an AND gate takes two inputs and has a single output.

So an AND gate will only put True switch on allow the electrical current to flow if both inputs are rule so True.

Like you can see on the right hand side here.

Both inputs are True the gate rings True an electrical current can flow.

So True and False can also be represented by one and a zero.

So one is True and zero is False.

So the moment this is the same gate as the one you saw before I'm going to flick back so you can see it, so we've got True on this one and then one on this one and they're the same representation it's just a different way of writing it.

If any of the outputs are False then the AND gate will also output False it's needs both of those things to be True and so even one of them is False The whole gate is going to to ring False and electrical current will not flow through.

Now these can also again be represented as a zero.

So if any of the inputs is zero The AND gate will output zero.

We got that.

Cool ,let's keep going.

So in order to keep track of which conditions will mean that AND gateway will output True we can use a tool called the Truth table which you can see on the right hand side here.

Now Truth table is just a way of marking down all the different combinations of inputs and then testing them to see which will result in an output of one or zero.

So we want to know all the combinations and what they will output when put through an AND gate.

So we can put labels on the inputs and outputs of the gate to make it easier to transpose.

Now the word transpose just means take from one place and put into another.

So in this case from our gate into our Truth table.

So you can see here that my two inputs have been labelled A and B and I've given the letter Q for my output.

This is very typical and you might see this written in the same way in other places.

So that's why I've used it here.

So all the possible combinations are put into the Truth table for the inputs.

So A and B can either be zero or one so here you can see we've got all the combinations.

Now an important thing to note here is that the combinations count up from zero to one to two to three.

This is very important and a key point you should remember if you ever have to write the inputs in yourself a good way of making sure you haven't forgotten any is by making it count up in binary.

So zero zero is zero and binary zero one is one And so on until you get to one one which is three in binary, okay.

Let's keep going.

So I've got a question if both of the inputs are zero or False what will the output be for an AND gate? You can pause the video and have a think about it that's fine.

Resume when you're done and we'll have a look.

So if both inputs are False what will an AND output? Will output zero right it needs both of those inputs to be True in order to output a one.

Cool.

So zero zero is a zero on the AND gate.

I said two zeros for inputs equals zero on the outputs.

I realise I said zero quite a few times there so it might have been confusing.

So let's try another one.

So if A is False or if A is zero and B is True or one what will the output be? Again if you want to pause the video here and have a think about it, that's fine.

Resume when you're done and we'll go through it.

Cool.

So now we've got one that is False or zero and one that is True.

What will an AND gate output True? No, will output False is zero.

It needs both of those to be one in order to output one so the fact that there's one zero means will outputs zero.

So now I've have another question I'm not going to give you a chance to pause this time I want you to think about on your feet.

So now we've got the other way round A is true and B is False what will the output be? You got it.

It's a zero.

It needs both of them to be True in order to output a one.

Okay, hopefully you're seeing a pattern here.

So now we're onto the final input combination, which is one, one.

Now what will it be if it's one, one? well, the AND gate will output one we've met its condition.

It wants both A and B to be True in order to output True and that's what we've got here.

So this is now a completed Truth table for the AND gate.

And why I'd like you to do is pause the video here and in your notes, I would like you to make a copy of the symbol and the Truth table and give it the label AND gate.

There's an important thing for you to remember so I'd like you to make sure you have it down in your notes you can use that pencil I told you to get the beginning of the lesson? Pause the video here, resuming when you're done and we'll move on to some other gates.

Hopefully you got that noted down let's move on and have a look at the next gate.

Next gate we're be looking at is the second of the three fundamental gates the OR gate.

So this the OR gate you can see the symbol on the right hand side here.

Notice it's slightly different from the AND gate it has a point end here and where the output is and also it's concave which means that it goes in at the back where the inputs is coming.

So slightly different.

You have to make sure that there are very distinct if you ever draw them.

An OR gate will output True if one or both of the inputs are True.

So the moment you can see we've got one True and one False input, but the OR gate entirety is outputting True.

So it doesn't need both it needs one or both to be True in order for the gate to ring True and allow electrical current to flow through it.

Let's have a look at another piece of pseudo code to see how an OR gate works.

You can see here on the right hand side I've got another programme for you to examine.

This time its gone OR condition instead of an AND condition.

What I'd like you to do is read through it and answer this question.

What will the output of this programme be when it's executed? Pause the video here, have a read through.

I want you to work out what is going to output and then resume when you're done and we'll go through it.

Welcome back.

Should we see what the answer is? Did you get it? What will it output when it's executed? Well it's going to output hello.

That's because the OR condition needs one or both of the expressions to be True.

Now as a reminder the expressions are the bits on the side.

So these are the sub conditions.

So person equaling Sam OR known to being True.

Either one or both need to be True in order for the OR statement to ring True and then output, hello, which happens in this case.

And that's because we have person set to Ajay, so the first expression or sub condition is not True that person doesn't equal Sam but known is True.

So one of the conditions is True therefore, the whole if statement is going to ring True, and we're going to output hello? So you saw us go through the Truth table for AND gates before now what I'd like you to do is do the same thing So look at each one of the sets of inputs and then work out what the output will be given those inputs.

So for zero, zero, if one input is zero the second input zero, what will the OR gate output? Do the same thing for all four rows and fill out you find this on your worksheet.

If you want to head over there, pause the video, resume when you're done and we'll go through it.

Welcome back again.

So let's have a look at what the OR Truth table will look like? So you can see here, we've got zero, zero so neither of the inputs is True and it's going to output zero.

Then on the second line we've got one input equal to zero and one equal to one and it will output a one because it want one or both conditions to be True.

The same is true if we've got the other way round A is one and B is zero It's going to ring True again because it's got one or both.

And the same thing happens on this last line here.

So one and one will also cause the OR gate to output one.

So one or both inputs need to be one in order for an OR gate to ring True.

If you want to pause the video again here, I'd like you to make sure that you have a copy of this symbol and the Truth table in your notes.

You probably already have the Truth table for you completed the exercise but just make sure that you've also got the symbol and a clear label for OR gate.

Resume when you're done and we'll carry on and have a look at the next gate.

Forward we go.

The last gate we're going to look at is the NOT gate.

So this is a NOT gate.

It's a triangle with a little circle on the end.

The little circle is important we'll come back to it at a later time.

So a NOT gate has one input and one output.

So it's a bit different to the last ones you've looked at because both an AND and an OR gate had two inputs.

However, a NOT gate only has a single input.

And the output is always the opposite of the input.

This is why NOT gates are also referred to as inverters.

Cause they invert whatever they take in.

So a False is coming, True will go out.

You can see that here.

So another two table for you to do here.

If you want to pause the video, head over either to your worksheet, or you can use this slide.

I want you to have a go filling out the Truth table for a NOT gate.

Now it's a bit simpler this time because it's only one input So there's only two rows.

Have a go pause the video here and resume when you're done and we'll talk about it.

Cool.

Should we have a look? So the NOT Truth table as I said, it just inverts whatever it takes in.

So when we have a zero as input or False, it's going to output True or one and when we have a one for an input, it's going to output zero.

So it takes a True and it will turn it to a false.

It inverts whatever comes in and there's only a single input.

Those are the important things you need to remember about NOT gate.

One input and it will reverse whatever it takes in.

I want to pause here to make sure you've got that symbol noted down and a clear label for NOT gate And then we'll carry on.

We're going to have a look at some word problems next.

Cool.

Let's keep going.

So we're going to put it all together now we've learned about the gates a bit above the logic that they use how does this apply to real life? So here we have a statement, My security system will trigger if it is nighttime and it detects movement.

Now this is a real world problem that would involve a computing system in some way and it also involves logic.

So in order to turn this statement into a logic diagram, we have to follow a process.

And the first step of that process is to identify the inputs of the expression.

So have a look here.

What do you think the inputs are of this expression? So my security system will trigger if it is nighttime and it detects movement.

The inputs are that it is nighttime and movement is detected.

So you might have a sensor that detects light and then feeds into your processor and you might also have another sensor that's detecting movement.

Both of those things are True those are the inputs then when something is going to happen.

Next we're going to identify the output.

What will happen based on those inputs? In this case, the security system will trigger and that can be in setting an alarm, calling the police it doesn't matter in this instance or we need to know is that we're going to trigger something.

Next you identify the logical operator.

What logic is inside this statement that we need to connect to the inputs to the output? And it's AND if it's nighttime and it detects movement.

So we've gone AND logic in there.

Next we need to draw a logic diagram based on this expression.

So we've identified the inputs and the output we need to connect them with the logic gate.

And we know it's going to be an AND logic gate with our two inputs on one side and our output on the other.

And then we have it.

So we have night and movement on one side, those are our inputs and we'd go through an AND gate.

And our output is an alarm or some kind of trigger for our security system.

And you see we've taken that real world problem a statement, a real computing system, and we've connected it using logic.

Now this might be a single logic date in a microprocessor, or it could be some code that you're creating, but either way, the logic has combined the two outputs and produced an output.

Combine the two inputs and produced an output.

Next we're going to create a Truth table for this statement.

Now we know that there was an ANT gate So our Truth table is going to be the same as a single AND gate, which looks like this.

Now you'll remember that the only thing that results in a True output from an AND gate is both inputs being true.

So in the output column Q here, we can see we've got all zeros and then a one at the end.

Just recap so the stages that you need to go through to turn a statement into a logic diagram and a Truth table are, identifying the inputs, which in this case was nighttime and detecting movement, you need to identify the output, which in this case was triggering an alarm or the security system in some way you then need to find a logical operator in this case it was AND.

We can then draw a logic diagram which looks like this and we can then create a Truth table for that logic diagram like that.

Okay, let's have a go at doing something yourself.

From the use your worksheet, I've got two other statements on there that I would like you to turn into a logic diagram and then a Truth table.

So you need to follow that process that we just went through.

I want you to do the same thing but on your own this time.

Pause the video here, head over to your worksheet find those, and then come back when you're done.

Let's have a look at the answers to those questions.

So I gave you some statements so let's have a look at the first one.

So the light will turn on if the switch is turned on or if I clap.

So you should have identified the inputs in this expression, which is the switch and the clap.

I can see those on the logic diagram on the left hand side.

Then you should have found the output which was the light turning on.

Then you need to identify the logical operator, which was OR in this case, you knew you were going to use an OR gate.

And then you drew the logic diagram using all those pieces of information.

And you can see on the bottom left here.

So we've got switching clap on one side connected through an OR gate and then producing the light output if the condition is met.

You then had to draw a Truth table for this and you would have known that it had to be the same as the OR gate.

So the only one outputs False is if there's neither inputs are True, that outputs False but the rest, whereas either one or both do out the True.

Hopefully you got that one.

Let's have a look at the next statement.

So the second statement I gave you was the buzzer will not turn on if the battery is charged.

So let's go through the process again.

Identify the inputs.

well actually there's only one input this time, the battery being charged.

Identify the outputs the buzzer going off is the output in this instance, find a logical operator, which is NOT.

Will not turn on.

And then we need to draw a logic diagram connecting those.

So you can see it down here in the bottom left again we've got charges are our input.

It goes into a NOT gate, because that was the logical operator we identified.

And then buzzer is our output.

And then asked you to make a Truth table for this.

And again it's going to be the same as just a NOT True table on its own.

So it's going to invert whatever the input is to produce the output.

So if our battery is not charged, it's False it's a zero.

our output will be one, True, and the buzzer will go off.

However, if the battery is charged, producing a one, the output will be a zero the buzzer will not go off.

Hopefully you got that.

If you need to pause it just make adjustments to your notes that's absolutely fine.

That's all from me today.

I hope you enjoyed this deep dive into logic gates.

The last thing is for me to ask you to share your work with Oak National.

If you'd like to, of course please ask your parent or carer to share your work on Instagram, Facebook, or Twitter tagging @OakNational and #LearnwithOak.

I'll see you next time.

Happy learning.

Bye.