# The Processor

## Central Processing Unit

Similar to a human brain, (although it cannot think or make decisions for itself) a computer processor controls, calculates and executes instructions.&#x20;

A processor has a number of different components, each with their own role to perform:&#x20;

* Arithmetic-Logic Unit (ALU)
* Control Unit&#x20;
* Clock&#x20;
* General purpose registers&#x20;
* Dedicated registers

## Arithmetic-Logic Unit

This part of the processor is responsible for the problem solving. It can perform arithmetic, logical and shift operations on data.

{% tabs %}
{% tab title="Arithmetic Operations" %}
Add, Subtract, Multiply, Divide
{% endtab %}

{% tab title="Logic Operations" %}
AND, OR, NOT, XOR
{% endtab %}

{% tab title="Shift Operations" %}
Move bits to the left or right within a register
{% endtab %}
{% endtabs %}

### Control Unit

This part coordinates the activity of all other components. It also synchronises all steps of the fetch, decode and execute cycle with a regular pulse from the system clock.

### The System Clock

A series of regular ON/OFF signals are used to synchronise the operations of the processor's components.&#x20;

Actions are usually carried out on the rising edge of the clock. Each action takes a fixed number of cycles to complete.

<figure><img src="/files/KR7cnYj4FMFEz8oxLBPC" alt="" width="375"><figcaption></figcaption></figure>

### General Purpose Registers

The results produced by the ALU need to be stored somewhere, rather than writing data back to the slow memory (RAM), the processor use inbuilt fast memory locations called registers to temporarily store data. This allows the processor to quickly access and reuse the data for subsequent calculations (e.g. 2+3+4). Some registers have a single general purpose register called the *accumulator*.&#x20;

### Dedicated Registers

* **Program Counter**: Holds address of the next instruction to be executed.
* **Current Instruction Register**: Holds the current instruction
* **Memory Address Register**: Holds address of instruction or data which is to be fetched or stored.
* **Memory Buffer Register**: Holds data and instructions moving between the processor and main memory.
* **Status Register**: Holds info about current state of operations. It is used to set flags (e.g. overflow) and detect error conditions.&#x20;

## The Processor

<figure><img src="/files/WSLhyqmG1oy9HwoU21xP" alt="" width="563"><figcaption></figcaption></figure>

### Fetch Decode Execute Cycle

Processors operate in defined stages that are used to carry out program instructions. The process is repeated over and over again for each instruction in the program.

### Fetch (steps 1 – 4)

<figure><img src="/files/1ZE4PQu16LJMyuHXEKUC" alt=""><figcaption></figcaption></figure>

### Decode (steps 5 – 7)

<figure><img src="/files/anKKneli6HsKycAAwJAD" alt=""><figcaption></figcaption></figure>

### Execute (Steps 8 – 10)

<figure><img src="/files/FD90mNk6LNF8YhmeQGtH" alt=""><figcaption></figcaption></figure>

### Factors affecting performance

The Fetch-Execute cycle is triggered from the clock pulses of the system clock. The faster the clock speed, the faster a computer can fetch, decode and execute instructions. A 4GHz processor would tick 4 billion times per second. However, increasing the clock speed to a very large number may make the processor emit a lot of heat, and it may also get damaged.&#x20;

#### Cache Memory

Cache is a small amount of superfast memory that stores data that is frequently used by the processor. It is larger and slower than a register, faster and smaller than RAM. Having larger amounts of cache memory can improve processing speed.

<figure><img src="/files/qNJD1KbhI3Xjfy6jeiRp" alt="" width="278"><figcaption></figcaption></figure>

### Other Factors

* **Number of Cores**: More processors can be linked on a single chip, thus allowing more instructions to be executed simultaneously
* **Word Length**: Allowing large word length would allow the processor to process simultaneously.&#x20;
* **Address and Data Bus width**: This will allow more data to be transferred at once and access to more memory locations.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cs.arkb.me/organisation-architecture/the-processor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
