3.0 Arithmetic Unit - Part 1
3.0 Arithmetic Unit - Part 1
3.0 Arithmetic Unit - Part 1
v The Arithmetic and Logic Unit (ALU) is the CPU component that performs actual operations on data.
v All operations are performed by logic gates.
v The basic arithmetic operations are addition, subtraction, multiplication, and division of integers and
floating-point numbers.
Integer Representation
v Numbers are represented in binary using a positional number system.
v A positional number system represents numbers by concatenating symbols.
Ø The number of different symbols used is called the radix or base.
Ø A symbol in the representation is called a digit. A binary digit is called a bit.
Ø The value of a number is the sum of the value of each digit multiplied by the weight of its position.
Ø The position number is assigned from a reference mark, the dot (.), with position 0 immediately to
the left of the dot and increasing to the left.
Ø The weight is equal to the radix raised to the position number of the digit.
101101.012 ⇒ radix = 2
Symbol 1 0 1 1 0 1 0 1
Position 5 4 3 2 1 0 –1 –2
Weight 25 24 23 22 21 20 2–1 2–2
Value = 1×25 + 0×24 + 1×23 + 1×22 + 0×21 + 1×20 + 0×2–1 + 1×2–2 = 45.25
Negative Integer Representation
Ø There are 3 common schemes for representing negative integers.
Ø All schemes assign the most significant bit (msb) as a sign bit (negative value if sign bit is 1). ⇒
This requires an agreement on the width of the representation.
Ø Positive integers have the same representation.
Ø Negative integer representation varies according to scheme.
Name +4510 Representation Method –4510 Representation
Sign-Magnitude 0101101 Set sign bit 1101101
1’s Complement 0101101 Complement all bits 1010010
2’s Complement 0101101 1’s Complement + 1 1010011
Ø Due to ease of use and range, 2’s complement is most commonly used to represent integers.
Integer Addition
v In a positional number system, numbers are added according to weight, from smallest to largest (right
to left). If the result of an addition exceeds one digit (bit), the higher digit is added to the next
position – carry.
FA : .... : FA FA HA
C3 C2 C1
C n Sn–1 S2 S1 S0
Full-Adder
Ø A full-adder (FA) takes an extra input, the carry-in Cin from the result of the previous digit.
C in B A
A B Cin Cout S
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1 S
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
S = A B C in + A BC in + AB Cin + ABC in
Cout
C out = AB + AC in + BC in
v Typical ALU design includes a capability to add a carry-in to the least significant bit. Hence, a typical
multi-bit adder is implemented as a cascade of full-adders, one for each bit.
An–1Bn–1 Ai Bi A1 B1 A0 B0 C0
Carry-in
C n–1 C i+1 Ci C2 C1
FA : .... : FA : .... : FA FA
C i+1 C2 C1
Cn
Carry-out Sn–1 Si S1 S0
v The final carry-out Cn may be used for cascading adders or as an overflow indicator.
Design Considerations
v Size – the number of gates used in implementing the adder.
Ø 8 gates (3 NOT, 4 AND, and 1 OR) are needed for the sum.
G and P circuit
G3 P3 G2 P 2 G1 P 1 G 0 P0
C4 Carry Lookahead C0
A3 B 3 A 2 B2 A1 B1 A0 B0
FA FA FA FA
C3 C2 C1
S3 S2 S1 S0
Ø Propagation delays
§ All inputs Ax and Bx, as well as the carry-in C0, have delays of 0δ.
§ All generate and propagate functions Gx and Px have delays of 1δ.
§ All generated carries C1 to C4 have delays of max(τGx, τPx, τC0) + 2δ = 3δ..
§ τS0 = max(τA0, τB0, τC0) + 3δ = 3δ.
§ τS1 = τS2 = τS3 = max(τAx, τBx, τCx) + 3δ = 6δ.
§ The total delay of the 4-bit adder is max(τS0, τS1, τS2, τS3, τC4) = 6δ.
Ø Gate counts
§ 32 gates (4 adders × 8 gates) are needed for the sums S0 to S3.
§ 4 AND gates are needed for the generate functions G0 to G3.
§ 4 OR gates are needed for the propagate functions P0 to P3.
§ 2 gates (1 OR and 1 AND) are needed for C1.
§ 3 gates (1 OR and 2 AND) are needed for C2.
§ 4 gates (1 OR and 3 AND) are needed for C3.
§ 5 gates (1 OR and 4 AND) are needed for C4.
§ The adder requires a total of 54 gates.
HALJ Arithmetic Unit (Part 1) 4
Integer Subtraction
v Integer subtraction is performed by adding the 2’s complement of the subtrahend.
Ø The 2’s complement is taken by complementing all bits of the subtrahend (Y) and setting the
carry-in.
Ø Complementing can be performed by taking the exclusive OR (XOR) with 1.
Y3 Y2 Y1 Y0
Add/Sub
A3 A2 A1 A0
B3 B2 B1 B0
Carry-out S3 S2 S1 S0