Vous êtes sur la page 1sur 8

[music] So, here we are in Lecture 2.2, Computational Boolean Algebra.

What we did in the last lecture was we introduced the Shannon cofactors and the Shannon Expansion theorem. We showed how you can take a complicated Boolean object apart into smaller, simpler pieces and manipulate it. What we want to start talking about now is the fact that the cofactors are incredibly useful objects. And even when we're not rebuilding the original Boolean equation, they take on an interesting life of their own. And, in fact, important combinations of these cofactors have famous names and famous uses in the chip design business. And so, we're going to start talking about the first one of these, which is called the Boolean difference. So, here's our first question what else can you do with cofactors? So, for example, from a hardware sort of a view, suppose I've got 2 functions F and G, different functions of, say, variables x1 to xn. And I make a new function, for example, I invert function F and I call that H, or I[UNKNOWN] the functions together or them or something. And it's, it's worth just, you know, reminding ourselves that you know, it's kind of a hardware thing, right? So, here's function F, and here's all the X's going in and, and here's function G, and you know, it really is. It's the same set of X's, you know, going into those things and here's F of X coming out and here's G of X coming out and what I've really, really said here is, okay, I've gotta put them into an and gate and I'm going to make a new function H. Here's the new question I'd like to start talking about. Can I tell anything about H's cofactors if I know something about the cofactors of F and G? So you know, good question, and the bottom is what is the positive X cofactor of H, which is the positive cofactor of this new function F and G, you know, what can we, what can we say about that? And the wonderful news is that pretty much the cofactors tell you everything you need to know and they also give you some wonderful practical tricks for calculating stuff. So, for example suppose I take F and I complement it and then I would like to do

the positive cofactor operation, you know, what is that? And it turns out that the other thing that I could do is I could take X and I could cofactor it first and then I could invert it, or depending on how you like to write this, I take F and I cofactor it first, and then I compliment the whole thing, right? And in English, I'm writing it underneath the cofactor of the compliment is the compliment of the cofactor, right? So, it doesn't matter what order I do it in, I get to do it in whichever order makes the calculation easier. And similarly, for basically all binary Boolean operators, it works like that. The cofactor of the AND is the AND of the cofactors, the cofactor of the OR is the OR of the cofactors. The cofactor of the exclusive OR, EXOR, right, that's this gate, remember is the EXOR of the cofactors. This is really very useful because this can often help in getting cofactors of complex formulas and, in fact, we're going to see that in, in this particular slide deck. So now, let's consider some operations on the cofactors, themselves. Suppose I have F of X and I told you about the Shannon cofactor, which is one way of utilizing them, what if I just take the positive and negative cofactors and I just start putting them together in different ways? What happens if I exclusive OR them? What happens if I AND them? What happens if I OR them? It turns out that all of those things are useful. In fact, they are so useful, they all actually have names. Each of the 3 things above, has a famous name and it's a famous thing. So, let's go look at them and the first one is we're going to look at this one. We're going to look at the exclusive OR. And surprisingly enough, I'm going to take you back to Calculus and derivatives, alright? So, remember way back when, whenever you learned you know, introductory Calculus and basic derivatives and we said, okay, you have a function, y is f of x and we define the derivative as the slope of the curve, right, was this thing right here. And the way we defined that was, we said, alright, look, we're going to take x and then we're going to change x just a little

bit by delta. And then, we're going to look and see how much the value of the function changes between f of x and f of x plus delta. And we're going to take the ratio of those two things and we're going to let delta go to 0, and when we're done, we're going to get this really interesting mathematical object called the derivative. So, here's a, maybe an unusual question for you. Do Boolean functions have derivatives? And amazingly enough, yes. And they're useful. And they have a name. The trick is, how do you define them, alright? So, the basic idea for real valued functions was that DFDX, the derivative tells you how F changes when X changes. And that's the thing to, to hang on to, conceptually. How does the output change when the input changes? For a 0,1 value Boolean function, we cannot change X by some small delta. The only thing you can do is you can change it by, you know, 0 to 1 or 1 to 0, but you can still ask, ask how X changes. And it turns out there's actually a very nice definition for, for something like a Boolean derivative it looks like this. We take the positive cofactor and we exclusive OR it with the negative cofactor. And that's, the, the, the definition of this interesting kind of a derivative. The way you can think about that is that it compares the value of F when X is zero, against the value of X when it's 1. And this mathematical object is a 1, just if these 2 things are different. And the, the one thing that I'll remind you of again, alright, is that the exclusive OR operation, the thing we are, we're drawing like that if we say a exclusive OR b, right, that's equal to a b bar plus a bar b, right? And this thing is equal to 1, if and only if a is not equal to b, right? So, this object down here is a 1 just if these 2 things are different. Now, we seen those pieces before, right? You know, the derivative is just the exclusive OR of the Shannon cofactors, the positive and the negative cofactors. But I will note that it's not written DFDX. It's written del F del X. That's just a historical thing.

And it's got a slightly different name since it's not a derivative in the continuous value sense. It's called the Boolean difference, just to be sort of clear about that. And the thing that's interesting is that it kind of behaves like Calculus, so, you know, for example you can do derivatives differences with, with respect to more than one variable. You can do del f, del x, and then del y. And it doesn't matter if you do x first or y first. The order doesn't matter. That's, that's just like Calculus. And the derivative of the EXOR is the EXOR of the derivatives. That's interesting. That's kind of like addition, right, in regular Calculus, so that's interesting. And if the function f is actually a constant, which means it's always 1 or always 0, then its Boolean difference is 0 all the time and that, that's also like Calculus which is, you know, kind of interesting. And one of the reasons why people find this you know, this stuff interesting and why we use this notation. Now, it would be great if this stuff actually behaved like Calculus but it doesn't. And so, here's some scary stuff. If you take the derivatives of the AND of f and g or the OR of f and g, it doesn't work the same. You get these really very complicated, complicated, complicated Boolean expressions. And the reason is that AND, and OR, despite the fact that we like to kind of write them like multiplication and write them like addition, they do not always behave like real numbers and so, you know, ultimately, it comes back and something different happens. Here's a little interesting example that I'm going to walk you through to try to give you some sense of what the Boolean difference actually does. So, let's just calculate the Boolean difference del f del x for all four of these very trivial gates. And we're going to see an interesting pattern, right? So, here's a function which is just f is x bar. And so, remember, the, the Boolean do, you know, the Boolean difference here is fx exclusive ORed fx bar, alright?

So, what's fx here? Well, we take x and we make it a 1, and so we're going to get a 0 and if we take fx bar, right, we take a 1. We're going to get is a 1, right? And so the derivative with respect to x is going to be 0 exclusive OR 1, which is just one and it's not at all clear, there's a pattern yet, but there is. We have to do a little more work. So, here is f is xy, it's a simple AND gate, right? F of x, the positive cofactor, is 1 and y, so that's just a y. And f of x bar, the negative cofactor, we take x and make it a 0, and you just get a 0, right? So, the derivative, the difference of del f del f is y exclusive OR 0 and that's just y. And so, let me ask you a, a kind of a question there. Supposed that I do whatever it takes to make this Boolean derivative, this Boolean difference equal to a 1, alright, so then, that, what that would mean is that I'd have to put a 1 on that input. Oh, here's something interesting that happens. If you make this input a 1, any time you make a change on x, I guarantee you, it will make a change on the output. This is actually the pattern we're going to, we're going to discover if you make the Boolean difference a 1, it guarantees for those values of, of other inputs that if you wiggle x, f will change. So, let's try that again with an OR gate, convince ourselves that that's the pattern, x plus y, x plus y. F of x is going to be 1 plus y, which is going to be 1. F of x bar is 0 plus y and so, it's going to be y and so the difference del f del x is going to be 1 exclusive ORr y and if you do the Boolean Algebra on that one, you'll discover that that's just y bar and I sort of said this same thing. What does it take to make this thing a 1? What it takes to make this thing a 1 is that you make y a 0, alright? That's what it takes to make the Boolean derivative a 1. So, if you make this thing as 0, oh, look, if you change, if you put a 0 on the other OR gate, any time you change x, I guarantee, you'll change f. That's cool. So, evaluate the Boolean difference, figure out how to make it a 1.

If you put that pattern of inputs on the gate when you change x, f will change, alright? What about an exclusive OR? So, this is x exclusive OR y, del f del, I'm sorry, f of x is equal to 1 exclusive OR y. So, that's y bar. F of x bar is equal to 0 exclusive OR y, so that's y. Del F, del x is equal to y exclusive OR y bar do th Boolean Algebra, and you discover that's a 1. That's that makes sense. What does it take to make that Boolean derivative a 1? And the answer is, everything makes it a 1, either you can't not make it a 1. And so, that means it does not matter what value you put on a y. If you put a wiggle on a x, if you change x, the output will always, always, always change. And now, if we go back to the inverter, we can see the pattern. X will always change the output no matter what you do, x will always change the output, that's why the Boolean difference evaluates to a 1. And for all of these others, the meaning is that when del f del f is 1, then f changes if x changes. And that's a, a wonderful thing because with just some math, we were able to do some sensitivity studies on a, on an interesting piece of logic. So you know, we could sort of expand that to a, you know, a much bigger thing. Here's a big blob of logic, right? And I'm trying to ask the question when does an input change on x turn into an input, turn, turn into an output change? And the answer is that, what I should go do, is I should go evaluate del f del x, and I should figure out what values of these variables here make it a 1. And if I can put those values of the variables on all of those other inputs, if I can make del f del fx which, recall, is a function of everything up at the top but not x, if I can make this function a 1, okay, then I garuantee that if I put that pattern on the input, right, the output will change. That's very useful thing. Here's just another um,you know, little kind of an example. So, here's a one bit adder, very simple little object. It's got a sum and it's got a carry we're

basically going, right now we're going look at just the, just the carry out. So, the carry out is ab, the two bits being added plus a plus b Cin. So, a simple equation. What's the Boolean difference of the carry out with respect to the carry in? Or, or kind of in English, when does the change in the carry in make a change in the carry out? Okay, well, we can go do the math. The notation is a little, a little weird. Carry out sub carry in, right, is what you get when you take the carry in and make it a 1. So, if you look at the equation, I get ab plus a plus b, okay? And that's just a plus b, alright? And then I do carry out sub carry in bar and that's what happens when I make the carry in as 0 and obviously, I'm just going to get ab because the second term is just going to drop out, okay? And if i want to do the carry out with respect to the carry in, del carry in I'm going to get a plus b exclusive OR ab, alright? And so that's a plus b, bar ab plus a plus b ab bar. The Boolean Algebra is a little tedious. I'll just kind of let you do it. It turns out you get a exclusive OR b, which makes total sense, alright? What does it take to make the Boolean difference of the carry out with respect to the carry in 1? A has to be different than b, right? If a is not equal to b, right, then, if you change the carry in, you will change the carry out. That makes sense because, you know, if a is equal to b and they both are 0, I don't care what you do with the carry in, you are not going to make a carry out. You just can't do it. And, you know, if a and b are both 1, they make a carry out all by itself, and again I don't care what you do with the carry in, it doesn't matter. But if a and b are not the same, then I guarantee you a change in the carry in will change the carry out. So arithmetically, this all makes sense, but the thing that's really nice and very elegant about this is that I can do all of this entirely in the Boolean domain. So, a couple of quick things to remember about the Boolean difference. It's not like the physical interpretation of Calculus derivative, there's no slope

of the curve stuff, but it explains how an input change can cause, can cause an output change for a Boolean function. The Boolean difference, del f del x, is a Boolean function, but it does not depend on x. That's a big one. And if I don't tell you that 5 more times, you'll forget it. Because, you know, in Calculus land, when you differentiated something with respect to x, the x did not always go away, but in Boolean land it does. Look, it can't have an x in it. It's made out of cofactors and cofactors don't have x's in them, they got replaced by constants. And this is really surprisingly useful. We're going to see this in a bunch of later places.

Vous aimerez peut-être aussi