The CPU
- We have seen a basic CPU with wombat..
- The general components of a CPU are
- Memory/Registers
- These are built out of flipflops.
- They are usually all the same size.
- In most modern machines there are 64 bits.
- But you may still have a 32 bit CPU.
- There are two types of registers.
- Special purpose registers, covered later.
- General purpose registers.
- General purpose registers hold temporary computation.
Think of these as variables, or temporary memory
- There are anywhere from 1 to 32 of these, but there could be more.
- The programmer can save values in these registers.
- Sometimes the collection of registers is called a register file (RF).
- And are indexed from 0 to the size of the register file.
- The program counter (PC) is a special purpose register.
- This is sometimes called the instruction pointer.
- This stores the address in memory of the next instruction to be executed.
- This is normally incrementd each instruction to point to the next instruction.
- But may be changed radically for a jump.
- The instruction register (IR) is a special purpose register.
- It holds the current instruction.
- The Arithmetic Logic Unit (ALU) conducts all math.
- This is where all computation takes place.
- It can add, subtract, multiply, divide.
- It can do comparison.
- The Memory Management Unit (MMU) interacts with memory
- It can read or write words to/from memory.
- It is connected to an external bus.
- The control unit (CU)
- This looks at the instructions in the IR and decides what to do.
- This controls all other parts of the CPU.
- The clock is probably part of the CU.
- The internal bus
- Connects all of the components.
- The fetch-decode-execute cycle
- fetch
- Fetch the instruction pointed at by the PC
- Store this instruction in the IR
- Increment the PC for the next instruction.
- Decode
- The CU looks at the instruction in the IR and "decides" what to do.
- Execute
- The CU provides signals to the individual components to carry out the instruction.
- This could include
- Fetching data from memory, RF, or even IR
- Performing a Mathematical operation
- Storing data in memory, RF, or even PC