Professional Documents
Culture Documents
Arithmetic Circuits: COMP541
Arithmetic Circuits: COMP541
Arithmetic Circuits: COMP541
Arithmetic Circuits
Montek Singh
(Not covered)
1
Today’s Topics
Adder circuits
ripple-carry adder (revisited)
more advanced: carry-lookahead adder
Subtraction
by adding the negative
Overflow
2
Iterative Circuit
Like a hierarchy, except functional blocks per bit
3
Adders
Great example of this type of design
Design 1-bit circuit, then expand
Let’s look at
Half adder – 2-bit adder, no carry in
Inputs are bits to be added
Outputs: result and possible carry
Full adder – includes carry in, really a 3-bit adder
4
Half Adder
Produces carry out
does not handle carry in
5
Full Adder
Three inputs
third is carry in
Two outputs
sum and carry out
6
Two Half Adders (and an OR)
7
Ripple-Carry Adder
8
Lab 2: Hierarchical 4-Bit Adder
We used hierarchy in Lab 2
Design full adder
Used 4 of them to make a 4-bit adder
Used two 4-bit adders to make an 8-bit adder
…
9
Specifying Addition in Behavioral Verilog
// 4-bit Adder: Behavioral Verilog
10
What’s the problem with this design?
Delay
Approx how much?
Imagine a 64-bit adder
Look at carry chain
11
Delays (post-synthesis simulation)
12
Multibit Adders
Several types of carry propagate adders (CPAs) are:
Ripple-carry adders (slow)
Carry-lookahead adders (fast)
Prefix adders (faster)
A B
N N
Adder symbol (right)
Cout Cin
+
N
S
Carry Lookahead Adder
Note that add itself just 2 level
sum is produced with a delay of only two XOR gates
carry takes three gates, though
14
Four-bit Ripple Carry
Reference
Adder function
separated from
carry
15
Propagate
The P signal is called propagate
P=AB
Means to propagate incoming carry
16
Generate
The G is generate
G = AB, so new carry created
So it’s ORed with incoming carry
17
Said Differently
If A B and there’s incoming carry, carry will be
propagated
And S will be 0, of course
18
Ripple Carry Delay: 8 Gates
Key observation:
G and P are produced by each adder stage
without needing carry from the right!
need only 2 gate delays for all G’s and P’s to be generated!
critical path is the carry logic at the bottom
the G’s and P’s are “off the critical path”
19
Turn Into Two Gate Delays
Refactor the logic
changed from deep (in delay) to wide
for each stage, gather and squish together all the logic to the right
20
C1 Just Like Ripple Carry
21
C2 Circuit Two Levels
G from before and P to pass on This checks two propagates and a carry in
22
C3 Circuit Two Levels
Generate from
level 0 and two
propagates
23
What happens as scaled up?
Can I realistically make 64-bit adder like this?
Have to AND 63 propagates and Cin!
Compromise
Hierarchical design
More levels of gates
use a tree of AND’s
delay grows only logarithmically
24
Making 4-Bit Adder Module
25
Group Propagate
26
Group Generate
27
Hierarchical Carry
A B A B
4-bit adder 4-bit adder
S G P Cin S G P Cin
C8 C4
Look Ahead C0
29
Other Adder Circuits
What if hierarchical lookahead too slow
Other styles exist
Prefix adder (explained in text) had a tree to computer
generate and propagate
Pipelined arithmetic units – multicycle but enable faster clock
speed
These are for self-study
30
Adder-Subtractor
Need only adder and complementer for input to
subtract
31
Design of Adder/Subtractor
Adds 1 to
make 2’s
complement
32
Overflow
Two cases of overflow for addition of signed numbers
Two large positive numbers overflow into sign bit
Not enough room for result
Two large negative numbers added
Same – not enough bits
Carry out by itself doesn’t indicate overflow
33
Overflow Examples
4-bit signed numbers:
34
Overflow Detection
Basic condition:
if two +ve numbers are added and sum is –ve
if two -ve numbers are added and sum is +ve
35
Summary
Today
adders and subtractors
overflow
36