8. Arithmetic Logic Unit (ALU)

This is where the CPU processes data either by manipulating it or acting upon it. It consists of two parts:

  1. Arithmetic part - which does exactly what you think it should - it performs calculations on the data e.g. 3 + 2 = 5
  2. Logic part - this deals with logic and comparisons. For example, it works out if one value is greater, less than or equal to another.

The result can be stored anywhere in memory with the relevant command. But for efficient programming, the result tends to be stored in the accumulator register whilst the status of any calculations or logic operations are recorded in the Program Status Word register (called different things by different makers).

An ALU can be shown as a symbol :-

An ALU arithmetic logic unit

The basic ALU operates on integers rather than floating point numbers. Two numbers (operands), A and B, are presented to the input of the ALU, and also an instruction - formally called an 'opcode', such as 'add', 'subtract', 'multiply', 'divide', 'compare'. The ALU carries out the requested operation on A and B and produces an output result.

Along with the result, a set of status flags are set which include 'Zero', 'Carry', 'Negative', 'Overflow'.

The ALU can directly handle integers of the same width as the data bus. So with a 16 bit data bus, the ALU can directly handle 16 bit integers. To handle larger integers, the ALU would have to take more than one step. Which is why a 32 bit cpu will always be more efficient than a 16 bit cpu for handling 32 bit integers.

In order to handle floating point numbers, a number of ALUs are combined to form a 'Floating Point Unit' (FPU). As you can imagine, this can take up a lot of real-estate on the chip.

So sometimes, instead of using up that space, the FPU is created as a partner chip called a 'co-processor'. When a floating point calculation needs to be made, the CPU sends it off to the co-processor which then sends back the result to the CPU. But of course, there are modern CPUs with an internal FPU.

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: What is an Arithmetic Logic Unit

 

Copyright © www.teach-ict.com