Subscribe

Lessons / Computer Science / IB Computer Science | Year 1 (Junior) / IB Computer Science · A1.1 Computer Hardware and Operation (SL & HL)

Computer ScienceIB1 · Junior

IB Computer Science CPU: ALU, CU & Registers (MAR vs MDR)

IB Computer Science CPU: ALU, CU & Registers (MAR vs MDR)

What you'll learn

IB Computer Science A1.1, computer hardware and operation: the components of the CPU (part 1 of 10, for SL and HL). What the ALU, the control unit and the registers PC, MAR, MDR, IR and accumulator do, and how the address bus, data bus and control bus connect the CPU to memory, following one instruction from memory into the CPU. Includes an eight mark exam-style question solved step by step.

In this lesson

  1. 0:00MAR or MDR: where does an address go?
  2. 0:29PC, MAR, MDR, IR and the two buses
  3. 2:22Spot the mistake: MAR and MDR swapped
  4. 2:59Control unit: decodes and sends signals
  5. 3:45ALU and accumulator
  6. 4:44Quick check
  7. 4:54Next: cores and the GPU
Read the lesson (full transcript)

CPU registers. This answer scores zero.

The student put an address into the data register. Can you see the mistake?

An address belongs in the memory address register. The M-A-R. That's one mark.

You've got one mark. This question has seven more, and each part hides a trap like that.

So if the address goes in the M-A-R, what is the M-D-R for? And where did two hundred and four come from?

A register is a tiny, very fast store inside the CPU. Each one holds a single value. Follow one instruction, and you'll see every register do its job. It starts in the program counter, the P-C. The P-C holds the address of the next instruction. Right now, that's two hundred and four. That's the first mark of part c.

The CPU copies that address into the M-A-R. So how does it reach memory? It travels along the address bus. A bus is just a set of wires that carries signals.

And here's the detail people skip. The address bus is one-way. Addresses go from the CPU to memory, and never come back. That's both marks for part e.

Memory looks up address two hundred and four, and sends back what's stored there. The instruction: add seven. It comes back on the data bus. The data bus is two-way, because the CPU also writes to memory.

The instruction lands in the M-D-R, the memory data register. So now you can answer it. The M-A-R holds where to look. The M-D-R holds what was found.

But the M-D-R is only a waiting room. The instruction is copied into the instruction register, the I-R. The I-R holds the instruction that's being decoded and executed right now. Second mark of part c.

And the P-C? It has already moved on. You'll now find two hundred and five in it, ready for the next instruction.

So look at that two hundred and five in the P-C. What is it? An instruction, an address, or a result?

An address. The P-C never holds an instruction. It only points to the next one. Would you spot that mix-up in someone else's answer?

You're the examiner now. A two mark question, and three answers. One mark is for the M-A-R. One mark is for the M-D-R.

Student A swapped them. Zero. Student B has the M-A-R right. One mark. But the M-D-R doesn't hold a second address. Student C has both. Two marks.

Here's how you keep them apart. A for address: where. D for data: what. But who tells all these registers when to copy?

That's the job of the control unit. First, it takes your instruction from the I-R and decodes it. It works out what add seven means. One mark.

Then it sends control signals to the other parts. Memory, read now. Register, copy now. Those signals travel on the third bus, the control bus. That's the second mark.

Here's the trap you need to see. The control unit never does the calculation itself. It's a manager, not a calculator.

So who actually adds the seven? The control unit, the M-D-R, or the A-L-U?

The A-L-U. The arithmetic logic unit. So what can it do, apart from adding?

The A-L-U does two kinds of work. Arithmetic, like add and subtract. And logic, like and, or, not. Is five greater than three? Comparing two values is the A-L-U's job too.

It works with one more register: the accumulator. The accumulator holds the result. Say it holds five. Add seven. Now it holds twelve.

So for part a, you write: the A-L-U performs arithmetic and logic operations. That's the last mark. Eight out of eight.

Now a new case. The next instruction says: load the value at address three hundred. Where does the three hundred go? Pause if you want to try it first; here it is.

Three hundred is an address, so you put it in the M-A-R. The value stored there, say forty-two, comes back in the M-D-R. The same two registers, but for data this time.

Next instruction's address? The P-C. The instruction running now? The I-R. Who does the maths? The A-L-U.

One core runs one instruction at a time. So what changes when a CPU has eight cores? That's part two.