130 likes | 246 Views
Computer Science 101. More Devices: Arithmetic. From 1-Bit Equality to N -Bit Equality. 1 0. A. =. A = B. B. 1100 1100. Two bit strings are equal iff the pair of bits at each position are equal. 1100110101100011 1100110101101011. From 1-Bit Equality to N -Bit Equality. A 0. =.
E N D
Computer Science 101 More Devices: Arithmetic
From 1-Bit Equality to N-Bit Equality 1 0 A = A = B B 1100 1100 Two bit strings are equal iff the pair of bits at each position are equal 1100110101100011 1100110101101011
From 1-Bit Equality to N-Bit Equality A0 = A0 = B0 B0 A1 = 3 2 1 0 A1 = B1 1100 (A) 1100 (B) B1 3 2 1 0 A2 = A2 = B2 B2 A3 = A3 = B3 B3 Add a = circuit for each column of bits
From 1-Bit Equality to N-Bit Equality A0 = A0 = B0 B0 A1 = 3 2 1 0 A1 = B1 1100 (A) 1100 (B) B1 3 2 1 0 A2 = A2 = B2 B2 A3 = A3 = B3 B3 AND all the results
From 1-Bit Addition to N-Bit Addition 0 + 0 0 1 + 0 1 0 + 1 1 1 + 1 10 Rules: The rules require us to carry a 1 to the next column We also must carry a 1 from the previous column 1 1 1011 + 0011 1110
From 1-Bit Addition to N-Bit Addition 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 0 + 0 0 1 + 0 1 0 + 1 1 1 + 1 10 0 + 0 1 1 + 0 10 0 + 1 1 0 1 + 1 11 A one-bit adder will always add a column of three bits and always carry to the next column So, let’s carry a 0 or 1 from each previous column and to each next column We now have 8 rules! 0 0 1 1 0 1011 + 0011 1110
A 1-Bit Adder 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 0 + 0 0 1 + 0 1 0 + 1 1 1 + 1 10 0 + 0 1 1 + 0 10 0 + 1 10 1 + 1 11 0 0 1 1 0 Cin 1011 + 0011 1110 + S A Cout B Has three inputs: A, B, and Cin (Carry in) Has two outputs: S (Sum) and Cout (Carry out)
Truth Table for 1-Bit Adder 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 0 + 0 0 1 + 0 1 0 + 1 1 1 + 1 10 0 + 0 1 1 + 0 10 0 + 1 10 1 + 1 11 Now apply sum of products algorithm!
Boolean Expression for S _ _ _ _ _ _ ABCin + ABCin + ABCin + ABCin Cin + S A Cout B _ _ ABCin _ _ ABCin _ _ ABCin ABCin
Boolean Expression for Cout _ _ _ _ _ _ ABCin + ABCin + ABCin + ABCin Cin + S A _ _ _ ABCin + ABCin + ABCin + ABCin Cout B _ ABCin _ ABCin _ ABCin ABCin
Construct the Circuit _ _ _ _ _ _ ABCin + ABCin + ABCin + ABCin Cin + S _ _ _ ABCin + ABCin + ABCin + ABCin A Cout B S Cin A YIKES!!!! Cout B
From 1-Bit Addition to N-Bit Addition 0 Carry in of adder0 is always 0 + S0 A0 Cout0 B0 Cin1 + S1 A1 Cout1 1 1 B1 1011 + 0011 1110 Cin2 + S2 A2 Cout2 B2 Cin3 + S3 Carry out of adderN - 1 can indicate overflow A3 Cout3 B3