The arithmetic logic unit is a big combinational circuit that takes

a substantial part of the real state of any computer chip.

So, that's what we're going to look at next.

So we're going to move up one more layer of abstraction.

And the basic idea is that our circuits,

our computers are organized as

modules that correspond to the functional units of the computer.

So we know we need a memory,

we need a register, we need the PC,

the IR, and the ALU,

which does all the calculations.

And those are not too many of those and there are

big circuits that are built up on smaller circuits as we've been doing.

We need to connect modules together with what's called buses.

In general, a bus is one wire for every bit in a word,

and that's how we propagate information between modules.

And then we also have single wires called

control lines that control the behavior of the circuit.

And we adhere to conventions to make it easier to understand what the circuits are doing.

Usually, we put the bus inputs at the top,

and we connect to them at the left.

And we put bus outputs at the bottom,

and we run any connections out from the right.

But often these buses have to run all the way through the circuit

because different pieces have to connect to one.

And then we have control lines that we usually do in

blue that also run all the way through the circuits.

So we'll see several examples of modules in the next lecture,

but our first example is the ALU.

And again the whole purpose of

these conventions is to make the circuits easy to understand.

Our rules are not designed to make the most efficient possible circuits.

What we're trying to do is get you to understand

how a computer works in just two lectures.

And so we're going to remove as much confusing detail as we possibly can.

So that's what the ALU looks like.

This as an 8-bit ALU,

so it takes two 8-bit input buses at the top,

and it's got an 8-bit output bus at the bottom,

and it's got three control lines for each one of the functions.

This one has three control lines.

We're going to emit the left-right shifter circuits.

You can see those in the details.

And this is what the whole circuit looks like.

There's one circuit for each function.

It computes all the values in parallel.

So that's our adder circuit or 8-bit adder.

There's an 8-bit bitwise XOR that's just

using the XOR from the pop quiz one for each bit.

And there's an 8-bit AND which is just an AND gate for each bit.

So, those are combinational circuits.

They're always computing their function of the inputs.

And then we have the control lines,

but the question is, how do we do the selection for the desired output?

When the ADD control line is lit,

we want to see the result of the ADD circuit,

and when the XOR is one we want to see that one and so forth.

And the answer is, we use a small subcircuit or a little switch called a one-hot mux,

which we'll talk about in the next slide.

And the purpose of that is to select

the proper result and carry it down to the output bus.

So this is the full design of the calculator that sits at the heart of the computer,

and we can check off a very significant module within the computer,

and we'll have a couple more to do next time.

So, the idea of a one-hot multiplexer is that there's m selection inputs,

m data inputs, and exactly one output.

And there's a precondition that at most one of the selection lines is one.

Eventually, these lines come from a decoder,

so we can be sure of that,

but we're not going to consider all possible inputs.

Either they're all 0 or exactly one of them is 1.

And the function of the circuit is to just give

the output the value of the selected input.

So, for example, in this case,

select input 3 is on.

Data input 3 is 0 so the output is going to be 0.

All the other data inputs are just ignored.

If data input 3 is one,

then the output will be 1.

This is a very simple circuit to implement,

and you can probably guess how it's implemented.

We just AND together the pairs of selection and data inputs.

If all the selections are zero,

then all the outputs of those AND gates is zero,

and then the output of that circuit is zero because it goes into an OR gate.

But if one of them is 1,

then either the AND gate will either produce 0 or if

the data input is 0 or one of the data input is 1,

and most one of those things will be 1.

If one of them is 1 then OR gate will produce 1 as output.

It's a very simple circuit, but it's useful.

And in our ALU,

this circuit is embedded for each bit.

In the ALU, the data inputs are the result of the operation,

either they ADD the XOR or the AND in

the selection input of the selection lines that are supposed to select the operation.

So it's just built with AND gates and a multi-way OR gate,

and this is just the example showing how the AND gates work for those cases.

So we use these in the ALU as just shown in the previous slide,

and they also play an important part of that

in the main memory that we talk about in the next lecture.

Now, again, it's important to note that this isn't

actually seems like a switch but it's not actually a switch.

There isn't a direct connection from

the input data to the output data,it's just that it has the same value.

We call it like a virtual selection switch.

And it's important to understand that because it's

misleading to think that there's actually electrical connection.

So that's our summary.

In this lecture, we've talked about some combinational circuit modules

that actually play each play a critical role in the design of our CPU circuit.

And we built this all up from starting with

just the idea of a controlled switch in wires connecting switches.

Next time, we'll talk about how to build registers and

memory using sequential circuits with feedback and

talk about connecting modules and then about how to control

the connections to make a full CPU like the one in your computer.