binary adder v2013

57
KOLA ZA REALIZACIJU OSNOVNOH ARITMETIČKIH OPERACIJA ARITMETIČKA KOLA

Upload: bogisigurica

Post on 31-Jan-2016

235 views

Category:

Documents


0 download

DESCRIPTION

Full/half adder

TRANSCRIPT

Page 1: Binary Adder v2013

KOLA ZA REALIZACIJUOSNOVNOH ARITMETIČKIH

OPERACIJA

ARITMETIČKA KOLA

Page 2: Binary Adder v2013

Binary Adder-Subtractor

• Half adder– 0+0=0 ; 0+1=1 ; 1+0=1 ; 1+1=10

– two input variables: x, y

– two output variables: C (carry), S (sum)

– truth table x y C S0 0 0 00 1 0 11 0 0 11 1 1 0

Page 3: Binary Adder v2013

S = x'y+xy'C = xy

the flexibility for implementation

S=x⊕y

S = (x+y)(x'+y')

S' = xy+x'y'S = (C+x'y')'

C = xy = (x'+y')'

Page 4: Binary Adder v2013
Page 5: Binary Adder v2013

• Full-Adder– The arithmetic sum of three

input bits

– three input bits• x, y: two significant bits

• z: the carry bit from the previous lower significant bit

– Two output bits: C, S

x y z C S0 0 0 0 00 0 1 0 10 1 0 0 10 1 1 1 01 0 0 0 11 0 1 1 01 1 0 1 01 1 1 1 1

Page 6: Binary Adder v2013

C

Page 7: Binary Adder v2013

S = x'y'z+x'yz'+ xy'z'+xyzC = xy + xz + yz =xy + (x+y)z

S = z⊕ (x⊕y)= z'(xy'+x'y)+z(xy'+x'y)'= z'xy'+z'x'y+z((x'+y)(x+y'))= xy'z'+x'yz'+xyz+x'y'z

C = z(xy'+x'y)+xy= xy'z+x'yz+ xy

Page 8: Binary Adder v2013

Binary adder - Ripple-Carry Adder

Page 9: Binary Adder v2013

• Carry propagation– when the correct outputs are available

– the critical path counts (the worst case)

– (A0,B0,C0) > C1 > C2 > C3 > (C4,S3)

– > 8 gate levels

tadder = (N-1)tcarry + tsum

Page 10: Binary Adder v2013

• Reduce the carry propagation delay– employ faster gates

– look-ahead carry (more complex mechanism, yet faster)

– carry propagate: Pi = Ai⊕Bi Pi = Ai+Bi

– carry generate: Gi = AiBi

– sum: Si = Pi⊕Ci

– carry: Ci+1 = Gi+PiCi

– C1 = G0+P0C0

– C2 = G1+P1C1 = G1+P1(G0+P0C0) == G1+P1G0+P1P0C0

– C3 = G2+P2C2 = G2+P2G1+P2P1G0+ P2P1P0C0

Page 11: Binary Adder v2013

POTPUNI SABIRAČMODIFIKOVANE ARHITEKTURE

iii bag ⋅= iii bap +=

iiii cgps ⊕⋅= ( )iiii cgpc +⋅=+1

Page 12: Binary Adder v2013

LookAhead- Basic Idea

Co k, f A k Bk Co k, 1–, ,( ) Gk PkCo k 1–,+= =

AN-1, BN-1A1, B1

P1

S1

• • •

• • • SN-1

PN-1Ci, N-1

S0

P0Ci,0 Ci,1

A0, B0

Page 13: Binary Adder v2013

– Logic diagram

Page 14: Binary Adder v2013

• 4-bit carry-look ahead adder– propagation delay

Page 15: Binary Adder v2013

ČETVOROBITNI SABIRAČ SA CLA(PARALELNIM PRENOSOM)

Page 16: Binary Adder v2013

Look-Ahead: Topology

Co k, Gk Pk Gk 1– Pk 1– Co k 2–,+( )+=

Co k, Gk Pk Gk 1– Pk 1– … P1 G0 P0Ci 0,+( )+( )+( )+=

Expanding Lookahead equations:

All the way:

Co,3

Ci,0

VDD

P0

P1

P2

P3

G0

G1

G2

G3

Page 17: Binary Adder v2013

Binary subtractor• A-B = A+(2’s complement of B) M=0 : S=A+B;

• 4-bit Adder-subtractor M=1 : S=A+B’+1

Page 18: Binary Adder v2013

• Overflow– The storage is limited

– Add two positive numbers and obtain a negative number

– Add two negative numbers and obtain a positive number

– V=0, no overflow; V=1, overflow

Page 19: Binary Adder v2013

4-5 Decimal Adder

• Add two BCD's– 9 inputs: two BCD's and one carry-in

– 5 outputs: one BCD and one carry-out

• Design approaches– A truth table with 2^9 entries

– use binary full Adders• the sum <= 9+9+1 = 19

• binary to BCD

Page 20: Binary Adder v2013

• The truth table

Page 21: Binary Adder v2013

• Modifications are needed if the sum > 9– C = 1

• K = 1

• Z8Z4 = 1

• Z8Z2 = 1

– modification: -(10)d or +6

Page 22: Binary Adder v2013

• Block diagram

Page 23: Binary Adder v2013

AKUMULACIONI SABIRA Č

AKUMULATOR R.

Page 24: Binary Adder v2013

FUNKCIJE ARITMETIČKO-LOGIČKE JEDINICE (ALU SN74181

Page 25: Binary Adder v2013

LOGIČKA ŠEMA ALU SN74181

Page 26: Binary Adder v2013

Multipliers

Page 27: Binary Adder v2013

A * B = A+A+A+A+A+A+ … +A

B puta se dodaje A

Višestruko sabiranje – B puta se dodaje A

Page 28: Binary Adder v2013

Množač realizovan akumulacionim sabiranjem

Page 29: Binary Adder v2013

Binary MultiplierPartial products – AND operations

Page 30: Binary Adder v2013

The Binary Multiplication

x

+

Partial products

Multiplicand

Multiplier

Result

1 0 1 0 1 0

1 0 1 0 1 0

1 0 1 0 1 0

1 1 1 0 0 1 1 1 0

0 0 0 0 0 0

1 0 1 0 1 0

1 0 1 1

Page 31: Binary Adder v2013

The Array Multiplier (X4b*Y 4b)

Y0

Y1

X3 X2 X1 X0

X3

HA

X2

FA

X1

FA

X0

HA

Y2X3

FA

X2

FA

X1

FA

X0

HA

Z1

Z3Z6Z7 Z5 Z4

Y3X3

FA

X2

FA

X1

FA

X0

HA

Z2

Z0

Page 32: Binary Adder v2013

The MxNArray Multiplier— Critical Path

HA FA FA HA

HAFAFAFA

FAFA FA HA

Critical Path 1

Critical Path 2

Critical Path 1 & 2

Page 33: Binary Adder v2013

Wallace-Tree Multiplier

6 5 4 3 2 1 0 6 5 4 3 2 1 0

Partial products First stage

Bit position

6 5 4 3 2 1 0 6 5 4 3 2 1 0

Second stage Final adder

FA HA

(a) (b)

(c) (d)

Page 34: Binary Adder v2013

Wallace-Tree Multiplier

6 5 4 3 2 1 0 6 5 4 3 2 1 0

Partial products First stage

Bit position

6 5 4 3 2 1 0 6 5 4 3 2 1 0

Second stage Final adder

FA HA

(a) (b)

(c) (d)

Page 35: Binary Adder v2013

Wallace-Tree Multiplier

Partial products

First stage

Second stage

Final adder

FA FA FA

HA HA

FA

x3y3

z7 z6 z5 z4 z3 z2 z1 z0

x3y2x2y3

x1y1x3y0 x2y0 x0y1x0y2

x2y2x1y3

x1y2x3y1x0y3 x1y0 x0y0x2y1

Page 36: Binary Adder v2013

TABLICA MNOŽENJA U ROM-u M · N = P

a0

a1

a2

a3

a4

a5

a6

a7

d0

d1

d2

d3

d4

d5

d6

d7

ROM

256*8

m0

m1

m2

m3

n0

n1

n2

n3

p4

p5

p6

p7

p0

p1

p2

p3

N

M

P

Za tablicu množenja dva 8-o bitna broja potreban je ROM kapaciteta 64K*16Za tablicu množenja dva 16-o bitna broja potreban je ROM kapaciteta 4G*32

Page 37: Binary Adder v2013

Constructing Big Mult’s from Small

• Can synthesize a 2b x 2b multiplier from four b x b multipliers and a three operand addition operation

AH AL

BLBH

AL BL

AL BH

BLAH

AH BH

4b product

b bits3b bits

AL BL

AL BH

BLAH

AH BH

Page 38: Binary Adder v2013

Množač 8-o bitnih brojeva realizovan 4-o bitnim tablicama množenja i sabiračima

Page 39: Binary Adder v2013

Redno-paralelni množač

Page 40: Binary Adder v2013

Četvorobitni redno-paralelni množač

Page 41: Binary Adder v2013

Sekvenca rada registara množača

Page 42: Binary Adder v2013

Generator kontrolnih signala prethodnog množača

Page 43: Binary Adder v2013
Page 44: Binary Adder v2013

Kolo za deljenje binarnih brojeva A/B

Page 45: Binary Adder v2013

Primer deljenja binarnih brojeva 1010000 / 0100

Page 46: Binary Adder v2013

Primer deljenja binarnih brojeva 101 / 1000

Page 47: Binary Adder v2013
Page 48: Binary Adder v2013

Table Lookup Arithmetic Def’n

• The u-bit string is obtained by concatenating the input values to form the table address.

• The n-bit value is the contentof the table corresponding to that address.

• Given an m-variable functionf(xm-1, xm-2, …, x1, x0)

the table lookupevaluation of f requires the construction of a 2u x n table that holds, for each combination of input values (needing a total of u-bits to represent), the desired n-bit result.

Page 49: Binary Adder v2013

Arithmetic by Table Lookup• Advantages

– memory is denser and can be made more robust than random logic

– reduces the cost of hardware development

– more flexible (allows last minute design changes)

– reduces the number of building blocks

• Disadvantages– slow for large tables

– table size grows exponentiallyin input size

Page 50: Binary Adder v2013

Direct Table Lookup

• Unary(single variable) functions (1/x, ln x, x2) limited to 12 to 16 bits of operand precision (212

to 216 table)

• Binary functions (xy, x/y, xy) limited to 8 bits of operand precision (28+8=16table)

Operand(s)u bits

Result(s)n bits

2u x nTable

(ROM or RAM)

Page 51: Binary Adder v2013

Indirect Table Lookup

SmallerTable(s)

(ROM or RAM)

PostprocessingLogic

Result(s)n bits

Operand(s)u bits Pr

e-pr

oces

sing

Logi

c

• One way to reduce the table size is to see if the binary function can be converted into a unaryfunction (requires pre- and postprocessing logic)

Much smaller than u !

Page 52: Binary Adder v2013

Constructing Big Mult’s from Small

• Can synthesize a 2b x 2b multiplier from four b x b multipliers and a three operand addition operation

AH AL

BLBH

AL BL

AL BH

BLAH

AH BH

4b product

b bits3b bits

AL BL

AL BH

BLAH

AH BH

Page 53: Binary Adder v2013

Množač 8-o bitnih brojeva realizovan 4-o bitnim tablicama množenja i sabiračima

Page 54: Binary Adder v2013

Indirect Table Lookup Example

• Pre- and postprocessing hardware should be simple and fast

• Consider the multiplication identity that converts the problem to one of squaring

X * Y = ¼ [(X + Y)2 – (X – Y)2]

– Preprocessing does X+Y and X-Y– Two tables to lookup (X+Y)2 and (X-Y)2

– Postprocessing does subtract and 2-bit right shift

Page 55: Binary Adder v2013

Indirect Multiplication

2** ROM(X+Y)2

Right shifter (¼)

X*Y (2n-bits)

X (n-bits)

Y (n-bits)

Subtractor

2** ROM(X-Y)2Subtractor

Adder

Page 56: Binary Adder v2013

Indirect Multiplication

n +1 bits

2ncontentbits

2n+1addr bits

2** ROM(X+Y)2

Right shifter (¼)

X*Y (2n-bits)

X (n-bits)

Y (n-bits)

Subtractor

2** ROM(X-Y)2Subtractor

Adder

Page 57: Binary Adder v2013