comp_orga Lec_3
comp_orga Lec_3
Organization
Lec_3
Building an ALU (Part 1):
Dr. Abdallah Ramadan Fawzy
An Arithmetic Logic Unit (ALU) is the primary
manipulator of state information in computers
State
State Manipulations
Storage
▪ We start building our computer!
▪ We’ll start with the arithmetic/logic unit (ALU)
In Lab 3 you will build a 32-bit ALU with the above operations
This truth table specifies a circuit we call a half
adder
C = XY
S = X’Y + XY’
=XY
XOR
▪ The carry-out bit has twice the magnitude of the sum bit
Specify the remaining bit positions’ behaviors
with a truth table
X Y Cin Cout S
0 + 0+ 0= 00 0 0 0
0 + 0+ 1= 01 0 0 1
0 + 1+ 0= 01 0 1 0
0 + 1+ 1= 10 0 1 1
1 + 0+ 0= 01 1 0 0
1 + 0+ 1= 10 1 0 1
1 + 1+ 0= 10 1 1 0
1 + 1+ 1= 11 1 1 1
This truth table specifies a circuit
we call a Full Adder
X Y Cin Cout S
S = X Y Cin 0 0 0 0 0
Cout = XY + (X Y)Cin 0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
We can use hierarchical design to build a full
adder from a half adder
Half Adder
Equations
S = X Y Cin C = XY
Cout= XY + (X Y)Cin S =X Y
We can use hierarchical design
to build multi- bit adders
a) 0
What is the value of S1?
b) 1
Implementing Subtraction
▪ Datapath
▪ These generally carry the numbers we’re crunching
▪ E.g., the X and Y inputs and the output S
▪ Control
▪ These generally control how data flows and what operations are performed
▪ E.g., the SUB signal.
Logical Operations
MUX
Multiplexors use control bits to select
data
▪ Examples:
▪ 4-to-1 mux: 4 data input bits, 2-bit control input
▪ Y = S1’S0’I0 + S1’S0I1 + I2 + S1S0I3