CALD-assignment 1
CALD-assignment 1
Assignment NO#1.
Main Concepts:
An Arithmetic Logic Unit (ALU) is a crucial element inside a CPU accountable for performing
mathematics and logical operations on enter information. It normally includes diverse sub-
components inclusive of adders, subtractors, comparators, multiplexers, and good judgment
gates.
Working Concept:
Input Registers:
• Input registers store the operands (binary numbers) that are to be operated
upon.
• They hold the input data temporarily before it's processed by the ALU.
• Registers are sequential storage elements capable of storing binary data.
Control Unit:
• The control unit decodes instructions fetched from memory and generates
control signals based on the opcode.
• These control signals determine which operation the ALU should perform
(addition, subtraction, logical operations, etc.).
• Control signals are sent to various components within the ALU to coordinate
their actions.
Multiplexers (MUX):
• Multiplexers select one of several input data sources and route it to the output
based on control signals.
• In the context of an ALU, multiplexers choose between different data inputs
(operands) based on the operation selected by the control unit.
• They play a crucial role in directing the flow of data within the ALU.
Adders/Subtractors:
• Adders perform addition of binary numbers, while subtractors perform
subtraction.
• They consist of logic gates (such as XOR, AND, OR) arranged in a way to
compute the sum or difference of two binary numbers.
• For addition, the sum of corresponding bits of the two numbers is calculated
along with any carry from the previous bit.
• For subtraction, two's complement arithmetic is often used, where the
subtraction operation is converted to an addition operation by taking the two's
complement of the subtrahend and adding it to the minuend.
Comparators:
• Comparators compare two binary numbers and produce output signals
indicating the relationship between them (e.g., greater than, less than, equal).
• They typically consist of combinational logic circuits that compare
corresponding bits of the two numbers.
• Output signals from comparators are used for conditional operations, such as
branching in a program based on the result of a comparison.
Logic Gates:
• Logic gates perform basic logical operations such as AND, OR, NOT, XOR.
• They are used for bitwise logical operations in the ALU, such as bitwise AND,
bitwise OR, and bitwise XOR.
• These operations are essential for performing logical calculations and
manipulating binary data.
Output Registers:
• Output registers store the result of the ALU operation temporarily before it's
written back to memory or registers.
• They hold the output data until it's needed for further processing or until it's
transferred to another component within the CPU.
Adder:
• Inputs: A (Operand 1), B (Operand 2), Cin (Carry-in)
• Outputs: Sum (Result), Cout (Carry-out)
Truth Table:
A B Cin Sum Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Subtractor:
• Inputs: A (Minuend), B (Subtrahend), Bin (Borrow-in)
• Outputs: Difference (Result), Bout (Borrow-out)
Truth Table:
A B Bin Difference Bout
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 0 0
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
Multiplexer:
• Inputs: Data inputs, Control signals
• Output: Selected data input
Truth Table: (Example for 2:1 MUX)
Control Input A Input B Output
0 ... ... ...
1 ... ... ...
Comparator:
• Inputs: A, B
• Outputs: A>B, A<B, A=B
Truth Table:
A B A>B A<B A=B
0 0 0 0 1
0 1 0 1 0
1 0 1 0 0
1 1 0 0 1
D-Flip Flop:
• Inputs: D (Data input), CLK (Clock)
• Outputs: Q(t) (Output at time t), Q(t+1) (Output at time t+1)
Truth Table:
D CLK Q(t) Q(t+1)
0 0 0 0
0 1 0 0
1 0 0 0
1 1 0 1
Diagram
TRUTH TABLE OF ALU:
Application:
• ALUs find applications in various fields, including:
• Mathematical calculations in scientific computations and financial modeling.
• Data processing in digital signal processing (DSP) and image processing.
• Control flow in microcontrollers, embedded systems, and CPUs.
• Cryptography for encryption and decryption algorithms.
• Graphics processing in gaming consoles, GPUs, and rendering engines.