How are individual bits controlled inside of a CPU?

325 views

I know there are transistors to represent 1 and 0 (on and off), and I know that assembly is the lowest human-readable level you can get to telling the CPU exactly what to do. Any and all processes between that are an enigma to me, and I would love to know how it works.

In: 35

10 Answers

Anonymous 0 Comments

A CPU is a machine. The purpose of the machine is to read instructions from memory and then do what they say. Some people have the idea that machine code instructions directly control the CPU or force it to do things. This is wrong – the CPU is voluntarily doing what the machine code instructions tell it because that’s what it’s designed to do.

It’s easiest to study an old 8-bit CPU like you might’ve found in a Commodore 64. Modern ones have too much going on and they do too many things at the same time. The CPU has a few main sections. It has the control unit, which connects to all the other parts of the CPU and sends them signals making them do the right things at the right times. It has the ALU, which is the part that does the calculations, under the control of the control unit. And it has the register file, which stores numbers temporarily.

I suppose the control unit is the part that interests you. It’s wired to do a loop like: connect program counter register to address bus, send memory read signal, connect data bus to instruction register, and then the rest of the loop depends on what the instruction in the instruction register is, and then it goes back to the beginning. When I say “it connects the program counter register to the address bus” I actually mean “it sends out a signal to the place where the program counter register connects to the address bus, telling that connection to activate” because the control unit is just controlling the rest. The loop is part of the control unit though.

An example instruction to add two registers might have the following steps. Everything in the same number happens at the same time, and then the next number happens in the next clock cycle. Each thing that happens is actually just sending a signal to the part that makes it happen.

1. Read program counter register onto address bus. Read memory. Write instruction register from data bus.
2. Read register 5 onto data bus. Write ALU left register from data bus.
3. Read register 6 onto data bus. Write ALU right register from data bus.
4. Tell the ALU to add, putting the result on the data bus. Write register 6 from the data bus.

The CPU designers hard-wired it so things happen in this order.

You are viewing 1 out of 10 answers, click here to view all answers.