 Now that we've shown how we can do some arithmetic, we can select things. We're going to look at an abstraction that we can actually get a whole lot of use out of later. That's an ALU. ALU stands for Arithmetic Logic Unit. So as you would expect, it does things like addition and subtraction, arithmetic, but it also does logical operations like and, or, nor, and and. So we're going to build this in a few pieces. We'll start by just building a one-bit ALU. Just the same way as we have, say, the arithmetic operations. So I'll start with something simple, the AND operation. If I want to know what A and B are, well, I need an AND gate. We'll put A over here, B over here, and we'll just go ahead and connect these. So there's A and B, and I get my result out. That one's not terribly interesting. The OR operation isn't going to be too much better. I just need OR gate, and I pass its result along. But now I have two possible outputs, so I'm going to need a multiplexer to choose which one do I want. And since I'm going to have other things coming in here, I'll leave some room. Now I've got an opcode, so I can choose whether I want AND operation or OR operation. If I want to do addition, well, I will need one of those adders. I can name that one number two. It will take A and B as inputs. And then I will also have carry-in line being an adder. It also produces a carry-out bit, as well as the regular result. And now I have AND OR as well as addition. We saw how we could implement subtraction last time, so we'd like to add that. I could add that close to my adder, but I may have a use for inverting B elsewhere. So I'm going to add the multiplexer to invert B out here. So now if I enable my B invert and my carry-in lines, then I can do one bit subtraction the way we saw before. I'd also like to be able to implement some other operations like NOR and NAND. Ideally, I can do this without adding any more hardware again. So I can consider what other representations NOR and NAND might have. NOT A OR B. If I apply De Morgan's laws, I can distribute the NOT sign through the rest of the proposition, and I get NOT A AND NOT B. So I've got an AND gate. I have NOT B. I would need to have a NOT A, which would mean adding another multiplexer in front of A just the same way as I have for B. That's not too bad. Let's see what happens with our NAND operation. So if I want NOT A AND B, again, apply De Morgan's law and I would get NOT A OR NOT B. So again, I have a NOT B that I can do. I have an OR gate, so I just need the NOT A. So I will go ahead and add another multiplexer here that I will use, choose whether I want A or NOT A. I'll need a selector bit for this, which I will name A INVERT. So that tells me exactly what that does. If I enable my A INVERT line, then we invert A. So great. This will now allow me to do all six of these operations. For any one bit pair of inputs. So next we're going to look at how we can take this and connect it together to build a 32-bit ALU. It's going to be a similar process to what we've done before, so it shouldn't be too bad.