Home :: Processor
Processors
Ever wanted to know how a processor works? Now is you chance to find out! I will explain how a processor works, what the various components of a processor do, and some other stuff.

Processor Components

Well, there you have it: your basic CPU.

You propably want to know what this resembles.

REGISTERS
The registers (Left in the picture) are used to store data in. Not very much though, the Z80 has 8 bit registers (so 1 register can hold 1 byte of data). There are 2 types of registers: General purpose registers and dedicated registers. General purpose registers are usually used in performing mathematical operations. Stack based processors usually don't have any general purpose registers. Non-stack based processors have. The Z80 has 7 general purpose registers.
Now the dedicated registers. They serve a single, unique puprose. Here are some general types:

Program counter - holds the memory address of the next instruction
Stack pointer- points to the top of the stack
TopOfStack - holds the value stored at the top of the stack
MemoryAddressRegister - holds the address to read from / write to
MemoryDataRegister - holds the data to write to the memory or read from the memory
MemoryByteRegister or Instruction-register - holds the instruction to execute
Status Register - holds the status flags

BIU
The Bus Interface Unit (top) controls the communication with external hardware components (like memroy, keyboard, display, etc.)

ICU
The Internal Control Unit (on the right) decodes the instruction in microcode and takes care of it's execution. It also controls the data transfer between registers and the memory. To make a long story short: it controls the entire CPU.

TU
The Timing Unit (Lower right corner) generates one or more clock signals to time all the processes within the CPU.

ALU
The Arithmetic and Logical Unit (bottom) can perform mathematical operations. It is used to change the content of the registers. For more details, read on.


The ALU
The previous picture wasn't quite complete, the shifter was missing. Anyway, here's another picture, this one's from the MIC1 processor.

It's written in Dutch but you should be able to understand most of it. The rectangles are registers:
MAR - Memory Address Register
MDR - Memory Data Register
PC - Program Counter
MBR - Memory Byte Register
SP - Stack Pointer
LV - Local Variable
CPP - Constant Pool Pointer
TOS - Top Of Stack
OPC - Old Program Counter
H - Help register
The upper four registers are used for memory control, the text on the left says: "To and From main memory".
The grey arrows indicate the B-Bus. It is one of the two entrances to the ALU. The A-Bus is the second. Inside the ALU, data from the A and B bus is manipulated and the result is passed on to the shifter. Once the shifterhas done it's job, the result is put on the C-Bus. From there, it is stored in one ore more registers. All this is done within 1 clockpulse. So my Athlon 1.2 Ghz can perform 1,200,000,000 of these operations in one second. As you can see, the ALU has some other lines. The N and Z line are flags wich are set or reset after an operation. The six other lines are instruction lines wich tell the ALU what to do. These lines are controlled by the ICU. The Shifter has two lines wich are also instruction lines. If anyone's interrested, here's the blueprint to the 1 bit version of this ALU, just connect 32 of those together and you have the actual thing.
More Info
Most of the stuff I tell here comes from my school books. Here are the names of those books:

Computersystemen en Netwerken - Leo van Moergestel
Gestructureerde Computerarchitectuur - Andrew S. Tanenbaum

Of course, these are Dutch books. But the second is also avilable in english:

Structured Computer Organization
published by:
Prentice-Hall, Inc. Simon & Schuster, a Viacom Company, Upper Saddle River, NJ, USA