Carry Look Ahead (CLA)
Full Adder Bi Ai Cin Cout Si © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology Full Adder Bi Ai Cin Cout Si
Carry Ripple Adder A0 B0 S0 A1 B1 S1 A2 B2 S2 A3 B3 S3 C0=0 C1 C2 C3 © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology Carry Ripple Adder A0 B0 S0 A1 B1 S1 A2 B2 S2 A3 B3 S3 C0=0 C1 C2 C3 C4
© Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology
Reduction Changing the goal to: Calculate the Carry vector © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology Reduction Changing the goal to: Calculate the Carry vector We can calculate S out of A,B,C in O(1) We’d like to improve the complexity of calculating C (less than linear)
Three Cases 1 Generate: Gi ? 1 Propagate: Pi ? Kill Gi Pi ? © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology Three Cases 1 ? Generate: Gi 1 ? Propagate: Pi ? Kill Gi Pi
חישובCout בהינתן Cin ותכונה © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology חישובCout בהינתן Cin ותכונה תכונה G P Cout Generate 1 Propogate Cin Kill Gi Pi Ci+1= Gi V (Pi Λ Ci) Ci Ci+1
G/P gate Gi Pi Gi 1 Pi 1 Pi 1 Ai Bi Gi = Ai Λ Bi Pi = Ai Bi © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology G/P gate Gi 1 Pi 1 Pi 1 Ai Bi Gi Pi Gi = Ai Λ Bi Pi = Ai Bi
Calculate using 2 G/P pairs Ci Gi Pi Gi+1 Pi+1 Ci+1 Ci+2 Ci+2=1 Gi+1 V (Gi Λ Pi+1) Ci+2=Ci Pi Λ Pi+1 Ci+2=0 otherwise Gi Pi G’ P’ Gi+1 Pi+1 G’ = Gi+1 V (Gi Λ Pi+1) P’ = Pi Λ Pi+1 © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology
חישוב וקטורי G ו-P: O(log(n)) A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 G0-1P0-1 G2-3P2-3 G4-5P4-5 G6-7P6-7 G0-3P0-3 G4-7P4-7 G0 P0 G1 P1 G2 P2 G3 P3 G4 P4 G5 P5 G6 P6 G7 P7 חישוב וקטורי G ו-P: O(log(n)) © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology
חישוב של Cj+1 בהינתן Ci ובלוק Gi-jPi-j Cj+1 = Gi-j V (Pi-j Λ Ci) © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology
תלות של Cj+1 ב-Ci ,Gi-j ו-Pi-j Cj+1 = Cj+1(Ci , Gi-j , Pi-j) = Gi-j V (Pi-j Λ Ci) C7 C5 C3 C1 C6 C4 C2 C0=0 C6 C2 G6-7P6-7 G4-5P4-5 G2-3P2-3 G0-1P0-1 C4 C0=0 C8 C0=0 C4 G4-7P4-7 G0-3P0-3 חישוב ה-carries בהינתן וקטורי G ו-P: O(log(n)) © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology
log(n) +log(n) = 2log(n) = O(log(n)) C0=0 A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 G0 P0 G1 P1 G2 P2 G3 P3 C1 C2 C3 C4 G4 P4 G5 P5 G6 P6 G7 P7 C5 C6 C7 C8 G0-1P0-1 G2-3P2-3 G4-5P4-5 G6-7P6-7 G0-3P0-3 G4-7P4-7 log(n) +log(n) = 2log(n) = O(log(n)) © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology
אין מסלול מ-Ci ל-G או P Gj Pj Gi Pi Gj Pj Gi Pi G0-1P0-1 Gi-j Pi-j © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology אין מסלול מ-Ci ל-G או P Gj Pj Gi Pi Gj Pj Gi Pi G0-1P0-1 Gi-j Pi-j G0-1P0-1 Cj+1 Ci Gi-j Pi-j Ci Cj+1
Timeline of Calculations for n=8 C0 is 0 from the beginning. 1) GiPi for each 0 ≤ i < 8 2) C1 (by C0 and G0P0) G0-1P0-1, G2-3P2-3, G4-5P4-5, G6-7P6-7 3) C2 (by C0 and G0-1P0-1) G0-3P0-3, G4-7P4-7 // Now all G...P... are known Ai Bi Gi Pi 4) C3 (by C2 and G2P2) C4 (by C0 and G0-3P0-3) 5) C5 (by C4 and G4P4) C6 (by C4 and G4-5P4-5) 6) C7 (by C6 and G6P6) © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology
Final stage A0 B0 S0 C0 A1 B1 S1 C1 A2 B2 S2 C2 An-1 Bn-1 Sn-1 Cn-1 ... Cn Overall complexity: O(log(n))+1=O(log(n)) = 2⋅log2n + 1 © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology
No! 2∙log2n + 1 < n n ≥ 6 Example 2 from .pdf Ripple-Carry n Adder Calculation Time Ripple-Carry n Carry-Look-Ahead 2∙log2n + 1 CLA is better when: 2∙log2n + 1 < n n ≥ 6 © Dima Elenbogen 2010, Technion – Israel Institute of Technology
למעשה אותה פונקציה בוליאנית שאלה © Yohai Devir 2007, Dima Elenbogen 2011, Technion – Israel Institute of Technology רשמו את כל הפונקציות הבוליאניות מהצורה :{0,1}←{0,1}* המתארות את היחידות של מחבר CLA. למעשה אותה פונקציה AND למעשה אותה פונקציה AND למעשה אותה פונקציה בוליאנית Si = Ai Bi Ci
Example 3 from .pdf G* = Gi+2 + Gi+1Pi+2 + GiPi+1Pi+2 © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology Example 3 from .pdf Ci Gi Pi Gi+1 Pi+1 Ci+1 Gi+2 Pi+2 Ci+3 Ci+2 G* = Gi+2 + Gi+1Pi+2 + GiPi+1Pi+2 P* = Pi Pi+1 Pi+2
Comparator A==B, A>B © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology Comparator A==B, A>B Propogate Generate A0 B0 A1 B1 A2 B2 A3 B3 EQ4 EQ1 EQ2 EQ3 EQ0=1 GR4 GR1 GR2 GR3 GR0=0
Comparator A==B, A>B © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology Comparator A==B, A>B A0 B0 A1 B1 EQ0-1 GR0-1 EQ0 GR0 GR1 EQ1 EQ0-1 A0A1==B0B1 EQ0-1 = EQ1 Λ EQ0 GR0-1 A0A1 > B0B1 GR0-1 = GR1 V (GR0 Λ EQ1)
log(n) + 1 = O(log(n)) A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 © Yohai Devir 2007, Dima Elenbogen 2010, Technion – Israel Institute of Technology A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 log(n) + 1 = O(log(n))