 This time, we're going to begin by building one of the simplest pieces of hardware we possibly can. That's a multiplexer. Multiplexer, or a MUX, is essentially a selector device. It will allow us to choose whether we want one input or another. Whichever one we select will be produced as the output of our multiplexer, and that can go on to be used by some other piece of hardware. We're going to be building this multiplexer just using some AND and OR weights. And we'll start with a one-bit multiplexer. We will then go back and see how we can expand that to make a multiplexer for arbitrary size. We're probably most interested in having a 32-bit multiplexer. But we're going to start with just a one-bit multiplexer. So my one-bit multiplexer will have two inputs. I've got some A and some B. And for both of these cases, these values are going to go into two AND gates. So the AND gates are going to allow us to control whether we're going to select A or B. And we're going to do this using a selector line. So if our selector line is true, we can take whatever is on the A line. But we're going to set this up so that for the B, we take the opposite of our selector line. So when our selector line is one, this gate will produce whatever is on A, but this will be zero. So this AND gate would always produce zero, regardless of what B is. Conversely, if we set our selector bit to zero, then after this NOT gate we'll have a one, so one AND B is whatever B is. So now we'd be able to select whatever is on this B line. But since our selector bit is zero, zero, and regardless of what A is, this AND gate is always going to produce zero. Now this allows us to say, okay, do we want A or B? But we also need to combine that. We want to put the results of both of those onto one line, so we will do that using an OR gate. So now if we select A, then whatever A is gets passed to this OR gate, and the OR gate will just dutifully pass it along. If we select B, then this AND gate will select to pass value of B along, and then the OR gate will also dutifully pass that along. But in both cases, only one of these AND gates can ever be true. So our OR gate can only ever pass on the value of either A or B. However, in this case, we only have one bit on each of these lines. A and B are just both one bit, so if we want to build a bigger multiplexer, one that can handle full 32 or 64 bit numbers, we're going to need something a little more complex. Fortunately, this will actually provide the building blocks for how we build a 32-bit multiplexer. So consider for a moment that this is perhaps bit 31, and I'm going to have a whole bunch more bits below this. In this case, I'll have 32 of them, so down at the bottom I will have A0 and B0. These will again go into a pair of AND gates. Those AND gates will get fed into OR gates. And to control these, I'm going to do them do it the same way I did before. I will put a knot before the selector bit on each of these B lines, and then I'm just going to connect the selector bit to all of these new AND gates that I've got. So now I've got essentially a one-bit multiplexer for each pair of bits in my inputs. In each case, I'm either going to select all of the values of A or all of the values of B. I'm doing that using the same structure that I had for one bit. It's just been copied out another 31 times. For my input, I've got 32 wires for each of A and B, and one selector bit. That one selector bit is enough to choose between all the bits in A and all the bits in B. My output is the 32 bits that correspond to either A or B, depending on what I was interested in. Now this is our first building block. We don't want to have to go back and build a multiplexer every time we need one, every time we want to choose between one of two, three, or four values. We really just want to know that this is how we can build a multiplexer. So in the future, we'll build lots of multiplexers by drawing a structure that looks like this, and we'll often annotate our multiplexer with a number to indicate the value of a selector bit when we're picking one or the other of these values. So in this case, if my selector bit is zero, then I'm going to pass A on as the results of my multiplexer. If I had set my selector bit to one, then I'd be passing B on. That's the opposite of what I've got over here, but I could accomplish that simply by moving all of these knot gates up to the AND gate for the A inputs instead. In some cases, it will be more useful to have the one on the top and the zero on the bottom. Writing those in there allows us to understand how this multiplexer is going to be processing its inputs for a given selector bit.