Download presentation
Presentation is loading. Please wait.
Published byJoan Griffin Modified over 9 years ago
1
Arithmetic-Logic Units
2
Logic Gates AND gate OR gate NOT gate
3
Logic Gates NOR gate NAND gate XOR gate
4
Half Adder s c a b a b c s 0 000 0 101 1 001 1 110
5
Full Adder c in a b c out s 0 0 000 0 0 101 0 1 001 0 1 110 1 0 001 1 0 110 1 1 010 1 1 111 s=c in xor a xor b c out =ab+c in (a xor b)
6
Full Adder c in a b c out s s=c in xor a xor b c out = ab+c in (a xor b)
7
Ripple Carry Adder
8
Ripple Carry Adders Each gates causes a delay our example: 3 gates for carry generation book has example with 2 gates Carry might ripple through all n adders O(n) gates causing delay intolerable delay if n is large Carry lookahead adders
9
Faster Adders c in a b c out s 0 0 000 0 0 101 0 1 001 0 1 110 1 0 001 1 0 110 1 1 010 1 1 111 c out =ab+c in (a xor b) =ab+ac in +bc in =ab+(a+b)c in = g + p c in Generate g = ab Propagate p = a+b
10
Fast Adders Iterate the idea, generate and propagate c i+1 = g i + p i c i = g i + p i (g i-1 + p i-1 c i-1 ) = g i + p i g i-1 + p i p i-1 c i-1 = g i + p i g i-1 + p i p i-1 g i-2 +…+ p i p i-1 …p 1 g 0 +p i p i-1 …p 1 p 0 c 0 Two level AND-OR circuit Carry is known early! Assignment: Draw the schematic of Carry- lookahead adder and compare its delay to Ripple carry adder in terms of n
11
Carry Lookahead Adders Based on the previous identity Fast because critical path is shorter O(log n) gate delays [assuming 2-input gates] More complex to implement Design is less regular Layout of one bit adder cells depend on i Compromise couple blocks of carry lookahead adders
12
Building an ALU Addition Subtraction AND OR What is missing? Zero flag & Overflow flags? From 32-bit ALU
13
Determine a<b Calculate b-a If MSB equals 1, then a<b 0, then a>=b
14
subtraction output available Connect MSB set output
15
LSB indicates whether a<b 0 if false 1 if true How to detect zero?
16
Conclusions We can build an ALU to support the MIPS instruction set key idea: use multiplexor to select the output we want we can efficiently perform subtraction using two’s complement we can replicate a 1-bit ALU to produce a 32-bit ALU Important points about hardware all of the gates are always working the speed of a gate is affected by the number of inputs to the gate the speed of a circuit is affected by the number of gates in series (on the “critical path” or the “deepest level of logic”) We focused on basic principles. We noted that clever changes to organization can improve performance (similar to using better algorithms in software) faster addition, next time: faster multiplication
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.