2023-07-10 11:58:40 +01:00
|
|
|
---
|
|
|
|
tags: [CPU]
|
|
|
|
---
|
|
|
|
|
|
|
|
# Arithmetic Logic Unit (ALU)
|
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
The ALU is the centerpiece or core of the
|
2024-02-17 11:57:44 +00:00
|
|
|
[CPU](CPU_architecture.md) architecture, where the
|
2024-02-02 15:58:13 +00:00
|
|
|
binary calculations occur. All the other components on the CPU chip are
|
|
|
|
appendanges to the execution that occurs within the ALU.
|
2023-07-10 11:58:40 +01:00
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
The ALU comprises
|
2024-02-17 11:57:44 +00:00
|
|
|
[logic gates](Logic_gates.md) that
|
2024-02-02 15:58:13 +00:00
|
|
|
execute the instructions passed from memory and where the data stored by the
|
|
|
|
registers is acted upon. A processor's ALU is just a complex combinatorial logic
|
|
|
|
circuit.
|
2023-07-10 11:58:40 +01:00
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
It executes arithmetic and logical operations on binary numbers and where you
|
|
|
|
will find operations conducted by
|
2024-02-17 11:57:44 +00:00
|
|
|
[full-adders and half adders](Half_adder_and_full_adder.md)
|
2024-02-02 15:58:13 +00:00
|
|
|
etc.
|
2023-07-10 11:58:40 +01:00
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
More specifically, the ALU is responsible for the _execute_ phase of the
|
2024-02-17 11:57:44 +00:00
|
|
|
[fetch, decode, execute cycle](Fetch_decode_execute.md).
|
2023-07-10 11:58:40 +01:00
|
|
|
|
2023-07-12 07:02:55 +01:00
|
|
|
## ALU execution lifecycle
|
2023-07-11 07:30:38 +01:00
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
1. **Inputs**: The ALU receives two operands and a control signal as inputs. The
|
|
|
|
operands are the data on which the operations will be performed. The control
|
|
|
|
signal tells the ALU which operation it needs to perform.
|
|
|
|
2. **Perform operation**: The ALU carries out the requested operation. For
|
|
|
|
instance, if the control signal indicates an addition operation, the ALU sums
|
|
|
|
the two operands.
|
|
|
|
3. **Output**: The ALU then sends the operation to another part of the CPU for
|
|
|
|
further processing or storage. The ALU also outputs a status bit that can be
|
|
|
|
used by other parts of the CPU to make decisions. For instance if the additon
|
|
|
|
results in a value that is too large to be stored, the ALU will set an
|
|
|
|
overflow flag.
|