1.77k likes | 2.05k Views
Lecture 18: Datapath Functional Units. Outline. Multi-input Adders Comparators Shifters Multipliers More complex operations. Carry-Save Adders (CSA). You can use a carry save adder to add three n -bit operands A 0 , A 1 , and A 2 without performing any carry propagation.
E N D
Outline • Multi-input Adders • Comparators • Shifters • Multipliers • More complex operations 18: Datapath Functional Units
Carry-Save Adders (CSA) • You can use a carry save adder to add three n-bit operands A0, A1, and A2 without performing any carry propagation. • You can also add one n-bit operand to an n-digit carry-save operand. • Result is in carry-save format. 18: Datapath Functional Units
Carry-Save Adders • Parallel arrangement of full-adders => constant delay. • Multi-operand carry-save adders also possible (m>3) • Array or tree arrangement. 18: Datapath Functional Units
Multi-Operand Adders • Add three or more (m>2) n-bit operands. • Yield -bit result in irredundant number representation • Array adders • Linear arrangement of CPAs • Linear arrangement of CSAs and a final CPA • The final CPA has to be fast. If it is an RCA, the performances of the two alternatives are equal. 18: Datapath Functional Units
4-Operand CPA Array 18: Datapath Functional Units
4-Operand CSA Array 18: Datapath Functional Units
Multi-input Adders • Suppose we want to add k N-bit words • Ex: 0001 + 0111 + 1101 + 0010 = 10111 • Straightforward solution: k-1 N-input CPAs • Large and slow 18: Datapath Functional Units
Carry Save Addition • A full adder sums 3 inputs and produces 2 outputs • Carry output has twice weight of sum output • N full adders in parallel are called carry save adder • Produce N sums and N carry outs 18: Datapath Functional Units
CSA Application • Use k-2 stages of CSAs • Keep result in carry-save redundant form • Final CPA computes actual result 18: Datapath Functional Units
(m,2)-Compressors • 1-bit adders. Similar to (m,k)-counters. • Compresses m bits down to 2 by forwarding (m-3) intermediate carries to next higher position. • No horizontal carry propagation. • Built from full adders ((3,2) compressors) or (4,2) compressors arranged in linear or tree structures, 18: Datapath Functional Units
(m,2)-Compressors • Example: 4-operand adder using (4,2) compressors. 18: Datapath Functional Units
(m,2)-Compressors • Structure of a (4,2) compressor 18: Datapath Functional Units
(m,2)-Compressors • Advantages of (4,2)-compressors over FAs for realizing (m,2)-compressors: • Higher compression rate. • Less deep and more regular trees. • Example: (8,2) compressor. 18: Datapath Functional Units
Tree adders (Wallace Tree) • Adder tree: n-bit m-operand carry-save adder composed of n tree structured (m,2) compressors. • Fastest multi-operand adders using an adder tree and a fast final CPA. 18: Datapath Functional Units
Adder Arrays and Trees • Some FAs can often be replaced by HAs or eliminated altogether. • Number of FAs does not depend on adder structure, but number of HAs does. • An m-operand adder accomdates (m - 1) carry inputs. • Adder trees (T = O(logn)) are faster than adder arrays (T = O(n)) at the same amount of gates (A = O(mn)). • Adder trees are less regular and have more complex routing than adder arrays => larger area, difficult layout => limited use in layout generators. 18: Datapath Functional Units
Sequential Adders • Bit-serial adder • Accumulators • With CPA • With CSA and final CPA • Allows higher clock rates • Final CPA too slow • Pipelining or multiple cycles 18: Datapath Functional Units
Complement and Subtraction • 2’s complement • 2’s complement subtracter • 2’s complement adder/subtracter • 1’s complement adder 18: Datapath Functional Units
Subtraction 18: Datapath Functional Units
Increment/Decrement • Adds a single bit cin to an n-bit operand A • Corresponds to addition with B=0 (FA -> HA) • Example: Ripple-carry incrementer using half-adders 18: Datapath Functional Units
Increment/Decrement • Or, use incrementer slices • Prefix problem Ci:k = Ci:j+1Cj:k => AND prefix structure 18: Datapath Functional Units
Increment/Decrement • Decrementer • Incrementer-decrementer 18: Datapath Functional Units
Fast Incrementers • 4-bit incrementer using multi-input gates • 8-bit parallel-prefix incrementer (Sklansky-AND prefix structure) 18: Datapath Functional Units
Gray Incrementer • Increments in Gray number system • Prefix problem => AND-prefix structure 18: Datapath Functional Units
Counting • Count clock cycles => counter • Divide clock frequency => frequency divider (cout) • Binary counter • Sequential incrementer/decrementer • Incrementer speed-up techniques applicable • Down-and up-down counters using incrementers or incrementer-decrementers 18: Datapath Functional Units
Example • Ripple-carry up-counter using counter slices (HA+FF), cin is count enable. 18: Datapath Functional Units
Synchronous Counters 18: Datapath Functional Units
Synchronous Counters 18: Datapath Functional Units
Asynchronous Counters • Uses toggle flip-flops. • Lower toggle rate => lower power 18: Datapath Functional Units
Gray Counter • Counter using Gray incrementers 18: Datapath Functional Units
Fast Counters 18: Datapath Functional Units
Fast Counters 18: Datapath Functional Units
Ring Counters • Shift register connected to ring • State is not encoded => n FF for counting n states. • Must be initialized correctly. • Applications: • Fast dividers (no logic between FF) • State counter for one-hot coded FSMs 18: Datapath Functional Units
Johnson Counter • Inverted feedback • n FF for counting 2n states. 18: Datapath Functional Units
3-bit LFSR 18: Datapath Functional Units
3-bit LFSR 18: Datapath Functional Units
8-bit LFSR 18: Datapath Functional Units
Comparators • Comparison operations 18: Datapath Functional Units
Comparators • 0’s detector: A = 00…000 • 1’s detector: A = 11…111 • Equality comparator: A = B • Magnitude comparator: A < B 18: Datapath Functional Units
1’s & 0’s Detectors • 1’s detector: N-input AND gate • 0’s detector: NOTs + 1’s detector (N-input NOR) 18: Datapath Functional Units
Equality Comparison 18: Datapath Functional Units
Equality Comparator • Check if each bit is equal (XNOR, aka equality gate) • 1’s detect on bitwise equality 18: Datapath Functional Units
Magnitude Comparison 18: Datapath Functional Units
Magnitude Comparator • Compute B – A and look at sign • B – A = B + ~A + 1 • For unsigned numbers, carry out is sign bit 18: Datapath Functional Units
Comparators • Subtractor (A-B) • Optimized comparator • Removing redundancies in subtractor (unused si) • Single-tree structure => speed up at no cost 18: Datapath Functional Units
Comparators • Example: ripple comparator using comparator slices 18: Datapath Functional Units
Signed vs. Unsigned • For signed numbers, comparison is harder • C: carry out • Z: zero (all bits of A – B are 0) • N: negative (MSB of result) • V: overflow (inputs had different signs, output sign B) • S: N xor V (sign of result) 18: Datapath Functional Units
Decoder • Decodes binary number An-1:0 to vector Zm-1:0 (m= 2n) 18: Datapath Functional Units
Encoder • Encodes vector Am-1:0 to binary number Zn-1:0 (m =2n) 18: Datapath Functional Units
Detection Operations • All-zeroes detection • All-ones detection • Leading zeroes detection • For scaling, normalization, priority encding 18: Datapath Functional Units