Skip to main content

Processor and Computer Hardware

The Processor

The processor refers to any electronic component capable of performing mathematical and logical operations. While the CPU (central processing unit) is the primary general purpose processor responsible for managing the system, other specialised processors utilise the same fundamental components, but are implemented and produced differently to optimise for specific workloads.

The processor is responsible for processing and executing program instructions as per the fetch-decode-execute (FDE) cycle.

  1. Fetch: The address of the next instruction is copied from the program counter to the memory address register. The fetched instruction is copied to the memory data register, and the program counter is incremented by 1. The contents of the memory data register are copied to the current instruction register.
  2. Decode: The instruction held in the current instruction register is decoded by the control unit, then split into opcode and operand. The opcode determines the type of instruction, and the operand holds either the address of the data to be used (copied to the memory address register) or the actual data to be used. Data is passed to the memory data register.
  3. Execute: The instruction is carried out.

Control Unit

The control unit is responsible for directing the flow of data between different components of the processor. It is responsible for all three parts of the fetch-decode-execute cycle.

Buses

A bus is a set of parallel wires connecting two or more components of a computer. There are three main buses, collectively known as the system bus:

  • Address bus: The bus along which an address of RAM is sent.
  • Data bus: The bus along which data is sent.
  • Control bus: The bus along which a control signal (e.g. read and write) is sent.

Each bus is a shared transmission medium, so only one device can transmit along a bus at any one time.

Arithmetic Logic Unit

The arithmetic logic unit (ALU) is responsible for performing arithmetic, such as adding and subtracting, as well as multiplication and division by executing bit shifts, and logical operations on data with operators like AND, OR, NOT, and XOR. Operations are performed on, and results are stored in, the accumulator.

Registers

Registers are super-fast, low-capacity primary memory devices located inside the processor. Each register has a dedicated purpose.

  • Program counter (PC): Holds the address of the next instruction to be executed. Can be modified by a branch instruction, and is otherwise incremented on every FDE cycle.
  • Current instruction register (CIR): Holds the current instruction executed.
  • Memory address register (MAR): Holds the address of the memory location from/to which data has to  be read from/written.
  • Memory data register (MDR): Temporarily holds data read from a memory address or that needs to be written to one. (A.k.a. the memory buffer register.

Cache Memory

Cache is a small amount of very fast memory located inside the processor. It stores frequently accessed instructions and data, so the processor does not have to fetch it from the RAM so often, which is located much further from the processor than cache. Reduces data transmission times thus result in greater processor performance. However, instructions and data in the cache could become outdated, harming data integrity.

Furthermore, cache tends to be low in capacity - if it's too large, more time is spent searching the cache for the desired data, reducing processor performance. For this reason, processors tend to have levels of cache. E.g. in a CPU, there is level 1 cache (low capacity, ~2-64KB) and level 2 cache (higher, ~0.256-2MB).

Clock speed

The clock speed dictates the number of FDE cycles that occur per second, affecting the speed of instruction execution. This number is so vast, it is measured in MHz (million hertz) or GHz (billion hertz). The larger this number, the more cycles, but the more power drawn to do so, resulting in more heat being generated.

Pipelining

Pipelining involves the fetching and decoding of instructions while another is executing. This uses components of the CPU that would otherwise be idle during the execution of a single instruction. Thus, three FDE cycles can be running at the same time. Take instructions A to F for example in an instruction pipeline:

Fetch Decode Execute
A

B A
C B A
D C B
E D C
F E D

Cores

A core is an independent processing unit within a processor that contains all of the above components and techniques. Multiple cores are connected in parallel in a circuit and can communicate with each other. Since they are otherwise independent of each other, they can execute instructions simultaneously. However, the more cores there are, the more power is drawn, causing heat to be generated.