17
Kuliah Rangkaian Kuliah Rangkaian Digital Digital Kuliah 7: Unit Aritmatika Kuliah 7: Unit Aritmatika Teknik Komputer Teknik Komputer Universitas Gunadarma Universitas Gunadarma

Kuliah Rangkaian Digital Kuliah 7: Unit Aritmatika Teknik Komputer Universitas Gunadarma

Embed Size (px)

Citation preview

Kuliah Rangkaian Digital Kuliah Rangkaian Digital Kuliah 7: Unit AritmatikaKuliah 7: Unit Aritmatika

Teknik Komputer Teknik Komputer Universitas GunadarmaUniversitas Gunadarma

Topic #7 – Arithmetic UnitsTopic #7 – Arithmetic Units

ComparatorComparator

AddersAdders Half-adder & Full-adderHalf-adder & Full-adder Carry-ripple adder & carry-look-ahead adderCarry-ripple adder & carry-look-ahead adder Overflow detectionOverflow detection

SubtractorSubtractor

MultiplierMultiplier

(Equality) Comparators (using XOR)(Equality) Comparators (using XOR)

1-bit comparator1-bit comparator

4-bit comparator4-bit comparator

Adds two 1-bit input to produce a sum and a carry-outAdds two 1-bit input to produce a sum and a carry-out Does not account for carry-inDoes not account for carry-in

X

YS

Cout

Half adderHalf adder

S = X’·Y + X·Y = XYCout = X·Y

Inputs Outputs

Y

0

1

0

1

S

0

1

1

0

X

0

0

1

1

Cout

0

0

0

1

Full adderFull adder

Building block to realize binary arithmetic operationsBuilding block to realize binary arithmetic operations

1-bit-wide adder with carry-in, produces sum and carry-1-bit-wide adder with carry-in, produces sum and carry-outout

Truth table:Truth table:X Y Cin S Cout

0 0 0 0 00 0 1 1 00 1 0 1 00 1 1 0 11 0 0 1 01 0 1 0 11 1 0 0 11 1 1 1 1

S

Cin

X

0 1

00 01 11 10

Y

Cin

XY

0

1

2

3

6

7

4

5

1

1 1

1

Cin

X

0 1

00 01 11 10

Y

Cin

XY

0

1

2

3

6

7

4

5

1

11 1

Cout

S = X’·Y’·(Cin) + X·Y’·(Cin)’ + X·Y’·(Cin)’ + X·Y·(Cin) = X Y (Cin)

Cout = XY + X(Cin) + Y(Cin)

Designing full adderDesigning full adder

Resulting circuitResulting circuit

XY

YC-in

C-outXC-in

X

X

Y

C-in

Y

C-in

Y Y’Y

X X’X

C-in C-in’C-in

X’Y’C-in

XY’C-in’

Sum SX’YC-in’

XYC-in

X’

X’

X

X

Y’

Y

Y

C-in

Y

C-in’

C-in’

C-in’

Full Adder

X Y

S

C-inC-out

Alternative: full adder using AND-ORAlternative: full adder using AND-OR

Ripple adderRipple adder

Speed limited by carry chainSpeed limited by carry chain 22 per full adder per full adder 2n 2n for an n-bit adder for an n-bit adder

Approach: eliminate or reduce carry chainApproach: eliminate or reduce carry chain Carry look-ahead: compute Cin directly from external inputsCarry look-ahead: compute Cin directly from external inputs

Q: Do we need C4 for a 4-bit 2’s complement addition?

Let CLet Ci+1i+1 = (X = (Xii·Y·Yii)+ (X)+ (Xii+Y+Yii)· C)· Ci i = G= Gii + P + Pii · C · Cii

For a 4-bit adder …For a 4-bit adder …

CC11 = G = G00 + P + P00·C·C00

CC22 = G = G11 + P + P11·C·C11 = G = G11 + P + P11·G·G00 + P + P11·P·P00·C·C00

CC33 = G = G22 + P + P22·G·G11 + P + P22·P·P11·G·G00 + P + P22·P·P11·P·P00·C·C00

CC44 = G = G33 + P + P33·G·G22 + P + P33·P·P22·G·G11 + P + P33·P·P22·P·P11·G·G0 0 + P+ P33·P·P22·P·P11·P·P00·C·C00

where Gwhere Gii = X = Xii · Y · Yii P Pii = X = Xi i + Y+ Yii

This is a 3 level circuit including generating the Gs and PsThis is a 3 level circuit including generating the Gs and Ps Rule of thumbRule of thumb: one carry look-ahead circuit every 4-bit: one carry look-ahead circuit every 4-bit

Carry look-ahead adderCarry look-ahead adder

Carry look-ahead circuit

Gs and Ps are also usefulfor generating the sums

16-bit carryripple adder

16-bit carrylook-ahead

adder

SubtractionSubtraction

Recall our discussion on subtraction for 2’s complement Recall our discussion on subtraction for 2’s complement ……

X – Y = X + Y + 1X – Y = X + Y + 1 Invert all bits of Y and set CInvert all bits of Y and set Cinin to 1 to 1

Example: 4-bit subtractor using 4-bit adderExample: 4-bit subtractor using 4-bit adder

Add a control circuit inAdd a control circuit in

ALU s.t. same circuit canALU s.t. same circuit can

be used for both additionbe used for both addition

and subtractionand subtraction

4-bit Adder

X3 X2 X1 X0

D3 D2 D1 D0

C-inC-outC4

Y3 Y2 Y1 Y0

C0 = 1

S3 S2 S1 S0

MultipliersMultipliers

8x8 multiplier8x8 multiplier

Full-adder arrayFull-adder array

Faster carry chainFaster carry chain