Unit 2: Arithmetic and logic unit




Arithmetic and Logic Unit (ALU)

The Arithmetic and Logic Unit (ALU) is a core component of the CPU responsible for performing:

  • Arithmetic operations (addition, subtraction, multiplication, division)
  • Logic operations (AND, OR, NOT, XOR, comparisons)

The ALU works under the control of the Control Unit (CU) and uses data stored in registers.

Look-Ahead Carry Adder (Carry Look-Ahead Adder – CLA)

Problem with Ripple Carry Adder

In a Ripple Carry Adder, the carry must propagate through each full adder one by one, which causes delay.

Example:

  • For n-bit addition, delay ∝ n

To overcome this delay, Carry Look-Ahead Adders are used.

Concept of Carry Look-Ahead Adder

The Carry Look-Ahead Adder reduces delay by calculating carry signals in advance.

It uses two signals:

  1. Generate (G)
  2. Propagate (P)

For each bit position i:

  • Generate:

    Gi = Ai · Bi
  • Propagate:

    Pi = Ai ⊕ Bi

Carry equation:

Ci+1 = Gi + Pi · Ci

Advantages of CLA

  • Very fast addition
  • Reduces carry propagation delay
  • Used in high-performance processors

Disadvantages of CLA

  • Complex hardware
  • More logic gates required
  • Cost increases with bit size

Multiplication in ALU

Multiplication is performed using shift and add operations.

Signed Operand Multiplication

Signed Numbers Representation

Signed numbers are usually represented using 2’s complement.

Rules:

  • Positive number → same binary
  • Negative number → 2’s complement

Signed Multiplication Process

Steps:

  1. Determine sign of result
  2. Multiply magnitudes
  3. Apply sign to result

However, direct multiplication is inefficient, so optimized algorithms are used.

Booth’s Algorithm

Booth’s Algorithm is an efficient algorithm for signed binary multiplication using 2’s complement representation.

It reduces the number of additions/subtractions.

Key Idea of Booth’s Algorithm

Booth’s algorithm examines:

  • Current bit (Qn)
  • Previous bit (Qn-1)

Booth’s Algorithm Rules

QnQn-1Operation
00No operation
01Add multiplicand
10Subtract multiplicand
11No operation

After operation:

  • Arithmetic right shift is performed

Advantages

  • Efficient for large numbers
  • Handles positive and negative numbers
  • Reduces number of operations

Disadvantages

  • Algorithm complexity
  • Difficult to understand for beginners

Array Multiplier

An Array Multiplier uses a regular array of adders and AND gates to perform multiplication.

Working Principle

Steps:

  1. Partial products are generated using AND gates
  2. Partial products are added using adders
  3. Final result is obtained

Features of Array Multiplier

  • Parallel operation
  • Fixed structure
  • High speed

Advantages

  • Fast multiplication
  • Simple and regular layout
  • Suitable for VLSI implementation

Disadvantages

  • Large hardware requirement
  • High power consumption

Division in ALU

Binary Division Concept

Binary division is similar to decimal long division.

Types:

  • Restoring Division
  • Non-restoring Division

Restoring Division Algorithm

Steps:

  1. Subtract divisor from partial remainder
  2. If result is negative, restore (add divisor back)
  3. Shift quotient and remainder

Non-Restoring Division

  • Avoids restoration step
  • Faster than restoring division
  • Uses conditional add/subtract

Division Issues

  • Slower than addition and multiplication
  • Hardware complexity
  • Overflow handling required

Logic Operations in ALU

The ALU performs basic logic operations bit-by-bit.

Basic Logic Operations

OperationSymbolDescription
AND·Output is 1 if both inputs are 1
OR+Output is 1 if any input is 1
NOT¬Inverts the bit
XOROutput is 1 if inputs are different

Logical Applications

  • Masking bits
  • Setting or clearing bits
  • Data comparison
  • Decision making in programs

Comparison Operations

ALU compares two values using:

  • Less than
  • Greater than
  • Equal to

Flags affected:

  • Zero flag
  • Carry flag
  • Sign flag
  • Overflow flag

Summary Table

OperationTechnique Used
AdditionCarry Look-Ahead Adder
MultiplicationBooth’s Algorithm, Array Multiplier
DivisionRestoring / Non-Restoring
LogicAND, OR, NOT, XOR

Conclusion

The ALU is responsible for all arithmetic and logical computations in a processor.
Advanced techniques like Carry Look-Ahead Adders, Booth’s Algorithm, and Array Multipliers improve speed and efficiency.
Understanding these concepts is essential for mastering computer organization and architecture.

Floating Point Arithmetic, ALU Design, and IEEE Standard

A floating point number is used to represent real numbers (numbers with fractional parts), such as:

  • 3.14
  • −0.125
  • 2.5 × 10³

Floating point representation allows a very large range of values using limited bits.

Floating Point Number Representation

A floating point number consists of three parts:

  1. Sign (S) – indicates positive or negative
  2. Exponent (E) – represents scale (power of base)
  3. Mantissa / Significand (M) – represents precision

General form:

(1)S×M×2E

Floating Point Arithmetic Operations

Floating Point Addition / Subtraction

Steps Involved:

  1. Compare Exponents - Make both exponents equal by shifting the mantissa of the smaller exponent.
  2. Align Mantissas - Right shift mantissa of the smaller exponent.
  3. Add/Subtract Mantissas - Perform arithmetic on aligned mantissas.
  4. Normalize the Result - Adjust mantissa so that it is in normalized form.
  5. Rounding - Apply rounding rules.
  6. Check for Overflow / Underflow - Handle exponent limits.

Floating Point Multiplication

Steps:

  1. Sign Calculation- Result sign = XOR of operand signs.
  2. Exponent Addition - Add exponents and subtract bias.
  3. Mantissa Multiplication - Multiply mantissas.
  4. Normalization- Adjust mantissa and exponent.
  5. Rounding - Apply rounding rules.

Floating Point Division

Steps:

  1. Sign Calculation - XOR of signs.
  2. Exponent Subtraction - Subtract divisor exponent from dividend exponent.
  3. Mantissa Division - Divide mantissas.
  4. Normalization & Rounding - Adjust result.

Problems in Floating Point Arithmetic

  • Rounding errors
  • Overflow
  • Underflow
  • Loss of precision

Arithmetic & Logic Unit (ALU) Design

Purpose of ALU Design

The design of ALU focuses on:

  • Speed
  • Accuracy
  • Hardware efficiency

ALU design integrates:

  • Arithmetic circuits
  • Logic circuits
  • Control logic

Basic Components of ALU Design

1. Arithmetic Unit

  • Adders (CLA, Ripple Carry)
  • Subtractors
  • Multipliers
  • Dividers

2. Logic Unit

  • AND, OR, NOT, XOR gates

3. Shifter

  • Logical shift
  • Arithmetic shift
  • Rotate operations

4. Control Unit

  • Selects operation using control signals

Block Diagram Description (Textual)

  • Inputs from registers → ALU
  • Control signals select operation
  • Output stored back in registers
  • Status flags updated

Status Flags in ALU

FlagMeaning
Zero (Z)Result is zero
Carry (C)Carry generated
Sign (S)Result is negative
Overflow (V)Overflow occurred

Floating Point Unit (FPU)

  • Specialized unit for floating point operations
  • Integrated with ALU or separate
  • Improves performance for real-number calculations

IEEE Standard for Floating Point Numbers (IEEE 754)

Need for IEEE Standard

  • Uniform representation across systems
  • Portability of programs
  • Consistent arithmetic results

IEEE 754 Floating Point Formats

(a) Single Precision (32-bit)

FieldBits
Sign1
Exponent8
Mantissa23

Bias = 127

(b) Double Precision (64-bit)

FieldBits
Sign1
Exponent11
Mantissa52

Bias = 1023

Normalized Numbers

For normalized numbers:

  • Leading bit of mantissa is 1 (implicit bit)
  • Increases precision

Special Values in IEEE 754

ValueDescription
+0, −0Zero
+∞, −∞Overflow
NaNNot a Number
Denormalized numbersVery small values

Rounding Modes

IEEE 754 supports:

  1. Round to nearest (default)
  2. Round toward zero
  3. Round toward +∞
  4. Round toward −∞

Advantages of IEEE Floating Point Standard

  • Platform independence
  • High precision
  • Defined error handling
  • Reliable scientific computation

Comparison: Fixed vs Floating Point

FeatureFixed PointFloating Point
RangeLimitedVery large
PrecisionFixedVariable
HardwareSimpleComplex
ApplicationsEmbeddedScientific, AI

Conclusion

Floating point arithmetic enables representation of real numbers with high precision and wide range.
The ALU design integrates arithmetic, logic, and control to ensure efficient computation.
The IEEE 754 standard ensures uniformity, accuracy, and portability in floating point operations.