Docsity

Computer Arithmetic: Lecture 3 - Basic Adders and Counters - Prof. Krzysztof Gaj, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download Computer Arithmetic: Lecture 3 - Basic Adders and Counters - Prof. Krzysztof Gaj and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Basic Adders and Counters

ECE 645: Lecture 3

Required Reading

Chapter 5, Basic Addition and Counting Sections 5.1-5.5, pp. 75-85.

Behrooz Parhami, Computer Arithmetic: Algorithms and Hardware Design

Half-adder

x y

c s

HA

x + y = ( c s ) 2

2 1

x y c s 0 0 1 1

0 1 0 1

0 0 0 1

0 1 1 0

Half-adder

Alternative implementations (1)

s = xy + xy

b)

a)

s = x โŠ• y

c = xy

c = x + y

c) c = xy

s = xc + yc = xc โ‹… yc

Half-adder

Alternative implementations (2)

Full-adder

x y

cout s

FA

x + y + cin = ( cout s ) 2

2 1

x y cout s 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 0 1 0 0 1

cin

0 1 0 1 0 1 0 1

cin

x y

A A1^ XOR^

D

0 1

Cin

Cout

S p

g

Full-adder

Alternative implementations (4)

Implementation used to generate fast carry logic in Xilinx FPGAs

x y cout 0 0 1 1

0 1 0 1

y

y

cin cin

p = x โŠ• y g = y s= p โŠ• cin = x โŠ• y โŠ• cin

Latency of a k -bit ripple-carry adder

Tripple-add = TFA(x,yโ†’cout) +
+ ( k -2) โ‹… TFA(cinโ†’cout) +
+ TFA(cin โ†’s)

Latency โ‰ˆ k โ‹… TFA

Latency โˆ k

Bit-serial

adder

ai bi

si

c 0

ci start

clk

Digit-serial

adder

d d

d

ai bi

si

c 0

ci start

clk

Addition of a constant (1)

xk-1 xk-2... x 1 x 0 yk-1 yk-2... y 1 y 0

variable

  • constant

xk-1 xk-2... xh+1 xh xh-1... x 0 yk-1 yk-2... yh+1 1 0... 0

variable

  • constant

xh xh-1... x 0

sk-1 sk-2... s 1 s 0

sk-1 sk-2... sh+

Addition of a constant (2)

HA/^... MHA

HA/ MHA

HA/ MHA

HA/ MHA

xk-1 xk-2... xh+2 xh+1 xh^ xh-1... x 0

..

sk-1 sk-2... (^) sh+2 sh+1 xh xh-1... x 0

If yi = 0 Half-adder (HA) yi = 1 Modified half-adder (MHA)

ck

Modified half-adder

x y

c s

MHA

x + y + 1 = ( c s ) 2

2 1

x y c s 0 0 1 1

0 1 0 1

0 1 1 1

1 0 0 1

Possible solutions to the

carry propagate problem

  1. Detect the end of propagation rather than wait for the worst-case time
  2. Speed-up propagation via
  • look-ahead
  • carry skip
  • carry select, etc
  1. Limit carry propagation to within a small number of bits
  2. Eliminate carry propagation through the redundant number representation

Analysis of carry propagation

Probability of carry generation = 41 (xiyi = 11)

Probability of carry propagation = 2 (xiyi = 01 or 10) 1

Probability of carry anihilation = 21 (xiyi = 00 or 11)

j j-1....... i+1 i 1 0 โ€ฆ 1 โ€ฆ0 โ€ฆ 1 1 1 1 โ€ฆ 0 โ€ฆ1 โ€ฆ 0 1

Probability of carry propagating from position i to position j

=

11 or 00 (^) 01 or 10 1 2

1 j โˆ’^ i โˆ’ โ‹… 21 probability of propagation

probability of anihilation

=

j โˆ’ i 2

1

Expected length of the carry chain
that starts at position i (1)

Expected length( i , k ) =

k i
k i
k j i
j i
j i
โˆ’^ โˆ’

Length of the carry chain

Probability of the given length

Probability of propagation till the end of adder

Distance till the end of adder

Expected length of the carry chain
that starts at position i (2)

Expected length( i , k ) =

k i

For i << k

Expected length of the carry propagation is โ‰ˆโ‰ˆโ‰ˆโ‰ˆ 2