In this video we're going to talk about logic interview just the bits that we can employ it.
OK.
So if we have P-Q and Mrs P and Q that symbol means and K we're going to draw a logic table 1 0 1 0.
If you say p and q 1 and 1 is true because one is the same is true.
Kate one is the same is true in zero is the same as false.
So 1 and 1 is 1.
But but if you ever don't have something it's not true so if you say you going to do two things you
only do one of them.
And you said I'm going to do this and this.
It's not true it's only true if you did both.
The second logical case is P or Q or is the logic which is to say that as long as one of them is true
it could be that both are true.
That's not an exclusive or this is just an or that says as long as one case is true.
I'm going to do this or that it could be I did both.
So that's your logical or this.
Over here we said is your logical and this is your logical OR.
And now we're going to do our logical knots and then X over which is exclusive or not is pretty straightforward.
You have P and NOT P.
And that's going to just be one becomes zero and zero becomes one.
Now the X or is the only one which is not one of the basic logics but it's still pretty important.
And we'll talk about it briefly.
OK.
So if I have my logical table of all my possibilities of logic that could be there x or says it is exclusive
or the only case when it is true is if one or the other is true if you say to a little child because
you have cookies or candy but you can have both.
That means that it's not going to be true when one and one are there.
You cannot have both if both statements are they are true it's not true.
You can have cookies and cake.
I said you can have one or the other but not both.
So one in one is zero.
True and true is zero but true and false and false and true is one.
You can have one or the other and that would be true but zero in zero is also zero.
So that's x square which is exclusive or versus the other type of or which is X or versus the other
type of or the regular or which says that even if both happen then that's also OK.
So now let's let's see about some drawing this a bid with some logical Gates.
OK.
The logical gait for and looks like this.
This is.
And that's here.
And so if I were to say something like you had a zero in a 1.
They went into this logical gate and they came out well 0 and 1 because that's R and 0 and 1 is 0 OK.
That's the output.
If I had a logical OR.
And please excuse my hand writing here.
Or that's the logical or symbol.
So if I had a zero and a 1 we'll stick with this example then I would that's my or sorry my output would
be 1 because one or the other happens if I had not symbol or not if I would put in a.
This is Arnotts.
OK.
If I were to put in a into my not similar to put in some input like zero then I would get out of one
because it just flips it it's an inverter because it flips it.
And then the last option that we discussed was the X or which is kind of like the OR.
But it just has that extra line there.
OK.
So that's the X.
Now let's test out our X or in logic and for inputs.
If I were to have a zero in a 1 x or returns to be a 1 if I were to have a 1 in a 1 x or returns to
me or zorse some people say returns to me a zero.
OK.
So those are our logical gates and we can mix and match these logical games together.
OK.
We can say something like here's a logical statement and and I'm going to have an all or I'm going to
put those together and they're going to be ordered again and then again I'm not.
That's OK.
So let's see what happens if I put different inputs and I'm going to have 0 1 0 1.
Now you could put any numbers in of course we're just doing an example.
So if you and because this is the anes that's the end.
If you and 0 1 you get a zero or zero and 1 you get that if you take two and one and you or it you gets
Because that's and or if you take and when you get a 1 and then I get a not it so I get a 0 as the output.
So the logic of this is that I have a P and Q I have a p or q.
Those are the two isolated ones.
And then I go and I or that's.
And after everything is said and done after this or that then you're going to not it's.
So you take that output and then you got it.
So that would be the logic p and q or P or Q And you're going to not it.
And that's what would happen if you have that C A and B being some input or p and q being some inputs
of 0 and 1 we got out a zero and that would be some logic.
Now you can actually use three very simple sim logic's or not.
In and in no particular order you can use just these and you can create any type of logic that you can
imagine in the fellow named Paulo Claude Shannon.
Claude Shannon was the one to write a thesis on this for his master's thesis and explained and that's
where I use booleans and computers because that's all we need we don't need anything else.
So let's see if we can create an X or a logic.
OK.
So the X where logic is going to be I actually have a picture of it so it will be easier.
The sort of logic is this treasons the X or logic is taking this diagram.
This is a.
And the this is not this is and and this is it.
Or let's put in some inputs let's test that one one one for a one for B see what happens.
Well if this is one in one we.
And that's because that's him and we and it and then we got it.
So that would be one then zero because we ended and not one in one becomes.
That's in the OR.
And then if we an 0 and 1 we get out a if we and we get out of zero which is perfect is 1 and 1 gave
us how to zero.
OK reasonable.
Let's try something else.
Let's put a 1 in a 0 and see what would happen.
Well if we and that we get a 0 and we not it we get a 1 if we or those two things we get a 1 1 and 1
is 1 so 0 1 as the input gives us that.
So this in fact is the logical gate behind an X or we drew the picture.
OK we drew the picture for the logical gate behind the X or.
And you can test the other cases but they should be obvious at this point as well.
And we can build any type of logic we'd like and there are other diagrams for an X or as well but I'm
going to do now is I'm going to say well hey let's go to the next step if we can build any logic.
Can I do addition.
Yes I can.
And let's go do it OK.
This over here.
Is our half adder K.
This is our half adder.
Let's explain what's happening.
We said in a previous video that we can take numbers we can add them in binary.
This logic will do that for us.
OK.
So let's test this out and see and then we'll learn a little bit about it.
I'm going to put a 1 in a 0 in let's see what happens if I take my b.
It's going to go into this X or that's X or and remember X was really built from other things.
And this is an answer.
If I take a one in zero I put them into X or then a get out a sum of 1.
If I take a 1 and 0 on I and I get out as of 0 Kate that is what I expect to get.
If I were to add 1 in 0 I would get one.
I would have no carry.
OK.
So I have the sum and I have a Kerry.
Kerry means you go to the next column.
If I were to have a 1 and a 1 I should get a 0 is the sum in a 1 is the Kerry OK.
So let's see if that's what we get.
Let me put in
a one in one and see if everything stacks up.
One in one.
Well if I x4 one in one I get zero.
If I ask if I and one in one I get a one.
So in fact that would be the sum that would be the carry because one plus one in binary is this.
This is the sum and.
This is the Kerry card carrying it over to the next column we did in the previous video.
OK.
So if that's the case then you can go through this logic like we've just done.
And you can in fact show that all of the different logical situations are going to perfectly mimic exactly
what I would expect if I were to have these two logical things what logic is this this logic of the
sum is X or when it's 1 1 or 0 0 0 otherwise it's 1 this logic down here is when it's only when it's
1 1 is that one that's scary.
This would be how you do addition.
We can do.
These are all the different cases of addition right here a 1 1 0 1 etc..
And that is how we do addition.
We have two different parts to it because we have a carry in a sum.
So if we had I have a larger number like this
K and I add them together.
I have some carry some carry some up.
Wait a second wait a second.
Let me let me make this clear so we can see that because I'm trying to isolate a certain point over
here.
And I'll do it like this one plus one is 0 1.
Now we had a seven to carry.
Now we also have some of the carry.
We didn't take this into account.
We're going to have to figure out how to add one plus one plus one together.
Well we know it's supposed to have a son of one in a carry of one some of one carry of one some have
one carry on.
So we're going to have to find a way to do not just two numbers added together with three numbers added
together.
Well here's the trick.
Take your two numbers add them together then add your third number to it and that's it.
OK.
That's what we're going to do to make a full adder.
This is a half adder as it says over there because it just adds this without inputting a carry because
this is just including an A and A B like I have over here and a and b.
So you can see in fact that my a and b are something but there's nothing else that's there but you can
see that perhaps I would have something else I am going to mess this up but this column right here has
has a carry built into that.
Adding to the beat you have to take that into account.
So let's go take that into account.
In fact this is going to be an X or let's highlight everything that's going on here.
This is our original X or and this is our original and that is the half adder that adds just two numbers.
But we're going to have to add the next numbers in as well.
In other words we're going to have to add what if there's a carry.
So first of all take your A and B X or it and get something and that's going to be or some BOP's are
some is also going to be dependent on the carry m c in if there's a carry for instance.
This is a carry.
So what did we do.
We first added the B.
Right.
We first added the B which are two numbers right here.
We got 1 0 then we say X or.
That's doo doo doo doo doo doo doo doo doo doo doo doo doo doo doo doo doo doo.
Ex who are that's with a with your.
Some of that with this carry in.
And then you can get some outputs.
So that's going to be your son.
So in this case if I do that my son is going to be one if like Kerry in was one my age was one and maybe
was one my son is going to be one over here and then I'm going to carry one.
So deal with the carry now.
OK so let's do with the carry now of what could happen.
All right.
I have the x or the X or I dealt with that's going to be the son the carry parts well a plus b is going
to be done isolated remember.
Does that have a carry.
Well if it does that's going to be right here.
So five one in one this will have a carry the carry to that's right is going to be this right there
which is one.
So this will be a one what about this if I add this together which is the sum does the sum does the
sum.
Meaning that's the sum part of the aim to be with the carry in.
Does that have a carry it does that have a carry.
Well if this is one and one gives you zero and one and it with zero says that right this is one in one
we're going to for them.
That's going to be zero.
We're going to put in the carry.
And so this is going to be the 0 that's going to go down there that Kerry is going to be one.
Well if we add them the output is zero if we or zero and one.
Yes in fact there is a Kerry.
This is my Some This is my KERRY time.
So this is the original Kerry.
And then we're basically just saying if either you had to carry due to the A in the B or are you out
in Kerry do to be X or of this meeting some with the with the Kariya and if you had to carry due to
that then either way you had to carry and then you get to say that there's a Kerry OK and there's only
three cases five cases one.
Well if Kerry is all in zero or one.
So that's your full adder.
It adds the numbers together and that was done it has.
And this is how you would add numbers now if you could add any number because now our full adder can
add any number we could add three and two right.
Gives us five.
Can we add negative numbers.
Sure.
Because we said that three and negative two three minus two is the same thing as three plus negative
two negative numbers we know how to address in binary.
Instead of saying this we do compliments.
I do this when we do do is compliment.
We flip it and then you add one to the binary So it's going to be this.
So what is this number right here.
I'm sorry what is this number right there.
That number is two.
So if that number is to this number when I flip it and add one that's going to be negative 2.
So all I need to do is take the three in the negative to do the carry.
Take those two numbers.
Do the addition block by block of the three which is this.
That's two and one which is three.
And that negative two which is this.
Add those together.
Block by block and then you will be able to do subtraction as well.
OK.
Well if we can do subtraction can we do multiplication.
Sure.
Because three times five is five three times which is 15.
So it's additive in notation we're good.
What about division.
Sorry to be all over the place but what about division.
Sure.
Because seven divided by five is five times one plus two.
So we could break it down and you can do all kinds of different algorithms to do that.
To break it down.
But essentially you could do.
My god you could do division multiplication addition and subtraction.
All of those were just justified.
Well if we use dictionaries and stuff like that for characters for chars cetra we could really basically
just do anything at this point.
That means that logic the logic gates logic gates took us to infinity.
And that's what our point is here to show the back the physical layer.
Let's say for instance in a network in the seven layers or Esai model or whatever it is and to show
the back when with the computer and what happens now due to this.
Now the nature of this in fact if we could manipulate lower level stuff like zeros and ones we would
obviously be able to do things faster.
And that's a large part of the goal here to understand how these things work.