170 likes | 319 Views
Fast Arithmetics. Full Adder. B i. A i. Cin. Cout. S i. Note: MSB is rightmost. Carry Ripple Adder. A 0. B 0. A 1. B 1. A 2. B 2. A 3. B 3. C 0 =0. C 1. C 2. C 3. C 4. S 0. S 1. S 2. S 3. Reduction. Changing the goal to: Calculate the Carry vector
E N D
Full Adder Bi Ai Cin Cout Si
Note: MSB is rightmost Carry Ripple Adder A0 B0 A1 B1 A2 B2 A3 B3 C0=0 C1 C2 C3 C4 S0 S1 S2 S3
Reduction • Changing the goal to: Calculate the Carry vector • In one time unit we can calculate S out of A,B,C • No effect on complexity
Note: MSB is rightmost A3 A1 A2 A0 B0 B3 B1 B2 C0 C1 C2 C3 S0 S1 S2 S3
Note: MSB is rightmost Current problem A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 C0=0 C1 C2 C3 C4 C5 C6 C7
1 1 ? 0 0 ? 1 0 ? Three Cases Generate: Cout = 1 Kill : Cout = 0 Propagate: Cout = Cin
G/P gate Ai Bi G = A∙B P = A xor B G P
Note: MSB is rightmost A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 G0 P0 G1 P1 G2 P2 G3 P3 G4 P4 G5 P5 G6 P6 G7 P7 C1 C2 C3 C4 C5 C6 C7 C8 C0=0 1+O(N) !
Note: MSB is rightmost C2 C4 C6 C8 G0 P0 G1 P1 G2 P2 G3 P3 G4 P4 G5 P5 G6 P6 G7 P7 If we could have calculated every 2nd Carry C0=0 C1 C3 C5 C7
Note: MSB is rightmost Calculate every 2nd Gi Pi Gi+1 Pi+1 Ci+2=1 iff Gi+1 or (Gi and Pi+1) Ci+2=0 iff Gi+1=0 and Pi+1=0 Ci+2=Ci iff Pi and Pi+1 Ci+2 Ci Ci+1 Gi Pi Gi+1 Pi+1 G’ = Gi+1 + Gi∙Pi+1 P’ = Pi∙Pi+1 G’ P’
Note: MSB is rightmost G0 P0 G1 P1 G2 P2 G3 P3 G4 P4 G5 P5 G6 P6 G7 P7 C2 C4 C3 C6 C0=0 C8 A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 G0 P0 G1 P1 G2 P2 G3 P3 G4 P4 G5 P5 G6 P6 G7 P7 C8 C1 C2 C3 C4 C5 C6 C7 C0=0 2+O(N/2)+1 !
Note: MSB is rightmost A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 G0 P0 G1 P1 G2 P2 G3 P3 G4 P4 G5 P5 G6 P6 G7 P7 C1 C2 C3 C4 C5 C6 C7 C8 C0=0 G0 P0 G1 P1 G2 P2 G3 P3 G4 P4 G5 P5 G6 P6 G7 P7 C2 C4 C3 C6 C8 C0=0 C0=0 C4 C8 log(n) +log(n) = 2log(n) = O(log(n))
Note: MSB is rightmost C0 A3 A1 A2 A0 B2 B3 B0 B1 C1 C2 C3 S0 S1 S2 S3 Final stage Overall complexity: O(log(n))+1=O(log(n))
Note: MSB is rightmost Comparator A==B, A>B A0 B0 A1 B1 A2 B2 A3 B3 EQ1 EQ2 EQ3 EQ4 EQ0=1 GR1 GR2 GR3 GR4 GR0=0
Note: MSB is rightmost Comparator A==B, A>B A0 B0 A1 B1 ALL-EQ1 iff A0A1==B0B1 ALL-EQ1 = EQ1∙EQ0 ALL-GR1 iffA0A1 > B0B1 ALL-GR1 = GR1 + GR0∙EQ1 GR0 EQ0 ALL-EQ1 ALL-GR1
Note: MSB is rightmost A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 A5 B5 A6 B6 A7 B7 log(n) + 1 = O(log(n))