0% found this document useful (0 votes)
12 views22 pages

DSD - Lecture 1.2

Uploaded by

Jihad Al Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views22 pages

DSD - Lecture 1.2

Uploaded by

Jihad Al Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Digital System Design

Lecture - 1.2
What is an ALU

• Arithmetic logic unit (ALU) is a digital circuit used to perform


arithmetic and logic operations.
• Represents the fundamental building block of the central processing
unit (CPU) of a computer

Prepared By - Mohsena Ashraf 2


How Does an ALU work?

• Most of the operations of a CPU are performed by one or more


ALUs, which load data from input registers.
• A register is a small amount of storage available as part of a CPU.
• The control unit tells the ALU what operation to perform on that
data and the ALU stores the result in an output register.
• The control unit moves the data between these registers, the ALU,
and memory.

Prepared By - Mohsena Ashraf 3


Functions of an ALU

• Processor’s core component


• Try to faster the hardware
• A combinational logic circuit
• Can perform multiple operations in runtime
• Performs 8 Arithmetic Operations
• Performs 4 Logical Operations

Prepared By - Mohsena Ashraf 4


Operations in ALU
• Arithmetic
• Addition (F = A + B)
• Addition with Carry (F = A + B + 1)
• Subtraction (F = A – B or F = A + B’ + 1)
• Subtraction with Borrow (F = A - B -1 or F = A + B’)
• Increment (F = A + 1)
• Decrement (F = A - 1)
• Transfer (F = A)
• Transfer with Carry (F = A ; Cout = 1)

5
Operations in ALU (Contd.)
• Logical
• And (F = A . B)
• Or (F = A + B)
• XOR (F = A xor B)
• NOT (F = A’)

6
A 4-bit ALU

Fig: Block Diagram of a 4-bit ALU


7
A 4-bit ALU (Contd.)
• has a number of selection lines to select a particular operation
• S2 distinguishes between arithmetic and logical operations
• S1, S0 are two function select inputs which specify the particular
arithmetic or logic operation to be generated
• The input and output carries have meaning only during an
arithmetic operation
• Basic component of the arithmetic section is a parallel adder
• Cin goes to the adder in the least significant bit position
• Cout comes from the adder in the most significant bit position

---For More, See Section 9.3 of Digital Logic and Computer Design by M.
Morris Mano
Prepared By - Mohsena Ashraf 8
ALU Design X Y

S2 S1 S0 Cin X Y F Cin Cout


0 0 0 0 A 0 A
0 0 0 1 A 0 A+1
F
0 0 1 0 A B A+B
0 0 1 1 A B A+B+1 ▪ X=A
0 1 0 0 A ▪ When Y = B,
S1 = 0, S0 = 1
0 1 0 1 A So,
A-1
Y = Sഥ1S0 B
0 1 1 0 A all 1
=2n-1+A
0 1 1 1 A all 1 2n-1+1+A

9
Now,
Yi = Sഥ1S0 Bi +S1Sഥ0 ഥ
Bi + S1S01
Yi = Sഥ1S0 Bi +S1Sഥ0 ഥ
Bi + S1S0 (Bi + ഥ
B i)
= S0 Bi (S1 + Sഥ1) + S1Bഥi(S0 + Sഥ0)

Yi = S0 Bi + S1Bഥi

Cin remains unchanged i.e., Zi = Cin

The PA works as ALU then.

10
Effects of Output Carry

• The output carry of an arithmetic circuit or ALU has special


significance, especially after a subtraction operation.
• To investigate the effect of output carry, we expand the arithmetic
circuit to n bits so that Cout = 1, when the output of the circuit is
equal to or greater than 2n.
• An output carry of 1 after an addition operation denotes an
overflow condition.
• The table in the next slide lists the conditions for having an output
carry in the circuit.

Prepared By - Mohsena Ashraf 11


Effects of Output Carry (Contd.)

---For More, Table 9.2 of


Digital Logic and
Computer Design by M.
Morris Mano
Prepared By - Mohsena Ashraf 12
Design of Logic Circuit

• All logic operations can be done by AND, OR and NOT


• For 3 operations, we need 2 selection variables
• 2 selection lines can select among 4 logic operations
• So we choose the XOR operation also

Prepared By - Mohsena Ashraf 13


Design of Logic Circuit (Contd.)
---For More, Section
9.5 of Digital Logic
and Computer
Design by M. Morris
Mano

The circuit must be repeated n times for an n-bit logic circuit

Prepared By - Mohsena Ashraf 14


Combining Logic and Arithmetic Circuits

• Can be combined with the arithmetic circuit to produce one


arithmetic logic unit
• S1 and S0 can be made common along with a third variable, S2
• S2 used to differentiate between the arithmetic and logic section
• S2=0 selects the arithmetic output while S2=1 selects the logical
output
• Still not the best design

Prepared By - Mohsena Ashraf 15


Combining Logic and Arithmetic Circuits (Contd.)

Prepared By - Mohsena Ashraf 16


Combining Logic and Arithmetic Circuits (Contd.)

Disadvantages :
• Requires a lot of ICs
• Need to build both the arithmetic and logic circuit distinctively
• More processing time with more overhead

Prepared By - Mohsena Ashraf 17


A More Efficient ALU

• Easier to generate logic operations in an already available


arithmetic circuit
• Cin always 0 (or, don’t care) when selection variable S2=1
• When S2=1,combination of S1 and S0 selects the 4 logical
operations
• When S2=0,combination of S1, S0 and Cin selects the 8 arithmetic
operations

Prepared By - Mohsena Ashraf 18


A More Efficient ALU (Contd.)

Steps:
1. Design the arithmetic section independent of the logic section
2. Determine the logic operations obtained from the arithmetic
circuit in step 1, assuming that the input carries to all stages are 0
3. Modify the arithmetic circuit to obtain the required logic
operations

Prepared By - Mohsena Ashraf 19


Final Function Table of the ALU
S2 S1 S0 Cin X Y F X Y

0 0 0 0 A 0 A
0 0 0 1 A 0 A+1 Cin Cout
0 0 1 0 A B A+B
0 0 1 1 A B A+B+1
F
0 1 0 0 A

0 1 0 1 A

A-1 ---For More, Section


0 1 1 0 A all 1 9.6 of Digital Logic
=2n-1+A
and Computer
0 1 1 1 A all 1 2n-1+1+A Design by M. Morris
1 0 0 X A+B 0 AvB Mano
1 0 1 X A B AB
1 1 0 X A + B’ B’ A^B
1 1 1 X A 1 A’
20
Now,
Xi = Ai + S2S1’S0’Bi + S2S1S0’Bi’
Yi = S0Bi + S1Bi’
Zi = S2’Cin [Cin only works when S2 is zero]

21
Practice Problems
• 9.10 - 9.14, 9.16 - 9.18

Prepared By - Mohsena Ashraf 22

You might also like